why can't use this variable in my script?
i run script with parameter "Untitled1.ps1 -filePath C:\scripts\test01 -logPath C:\scripts" and result is
step1 C:\scripts\test01 C:\scripts
step2 C:\scripts\test01 C:\scripts
step3 "$arg2"
Why step3 not show result " step3 C:script
script - Untitled1.ps1
Param
(
[CmdletBinding()]
[string]$filePath,
[string]$logPath
)
Write-Host step1 $filePath $logpath
function Test-Script
{
Param
(
[Parameter(Position=0)]
[string]$arg1,
[Parameter(Position=1)]
[string]$arg2
)
Write-Host step2 $arg1 $arg2
### DEFINE ACTIONS AFTER AN EVENT IS DETECTED
$action = {$arg2}
Write-Host step3 $action
}
Test-Script $filePath $logPath