passing parameters and secrets to powershell script #2279
Unanswered
lafayetteduarte
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone.
I´m trying to figure out how to pass parameters to my powershell scripts and , so far came up empty.
Tried to:
can anyone point me at an example or doc that shows how can i do that?
I am able to get the values from env variables but got no luck with any other method be that survey vars or simple vars in my environment settings.
My test script looks like this:
param(
[string]$param1
)
$info = ""
$info = [System.Net.Dns]::GetHostName()
Write-Host $info
Write-Host "################################"
Write-Host "Parameters and Default Values:"
Write-Host "################################"
foreach ($param in $MyInvocation.MyCommand.Parameters.keys) {
$value = Get-Variable -Name $param -ValueOnly -ErrorAction SilentlyContinue
if (-not $null -eq [string]$value) {
Write-Host "${param}: $value"
}
}
Write-Host "################################"
Write-Host ""
Write-Host "################################"
Write-Host "Loaded variables:"
Write-Host "################################"
Get-Variable | Out-String
Write-Host "################################"
Write-Host ""
Write-Host ""
Write-Host "################################"
Write-Host "env variables:"
Write-Host "################################"
Get-ChildItem env:* | sort-object name
Write-Host "################################"
Write-Host ""
Thank you in advance
Beta Was this translation helpful? Give feedback.
All reactions