Power Shell Scripts
http://technet.microsoft.com/en-us/scriptcenter/dd742419
Explains Functions/Scripts/Args
http://devcentral.f5.com/weblogs/Joe/archive/2009/01/13/powershell-abcs---p-is-for-parameters.aspx
How to pass params:
param(
[string] $optionalparam1, #an optional parameter with no default value
[string] $optionalparam2 = "default", #an optional parameter with a default value
[string] $requiredparam = $(throw ""requiredparam required."), #throw exception if no value provided
[string] $user = $(Read-Host -prompt "User"), #prompt user for value if none provided
[switch] $switchparam; #an optional "switch parameter" (ie, a flag)
)
eg:
# Begin script foo.ps1
param([string]$foo = "foo", [string]$bar = $(Read-Host -promt "Bar Value"))
Write-Host "Arg: $foo"
Write-Host "Arg: $bar"
# End script foo.ps1
Explains Functions/Scripts/Args
http://devcentral.f5.com/weblogs/Joe/archive/2009/01/13/powershell-abcs---p-is-for-parameters.aspx
How to pass params:
param(
[string] $optionalparam1, #an optional parameter with no default value
[string] $optionalparam2 = "default", #an optional parameter with a default value
[string] $requiredparam = $(throw ""requiredparam required."), #throw exception if no value provided
[string] $user = $(Read-Host -prompt "User"), #prompt user for value if none provided
[switch] $switchparam; #an optional "switch parameter" (ie, a flag)
)
eg:
# Begin script foo.ps1
param([string]$foo = "foo", [string]$bar = $(Read-Host -promt "Bar Value"))
Write-Host "Arg: $foo"
Write-Host "Arg: $bar"
# End script foo.ps1
Comments