Running a Powershell script using bigfix action script

Hi,
I am trying to run the following script with no success.
It will be tested on windows machines but something is getting messy with the curly brackets.


action uses wow64 redirection false
wait "c:\Windows\system32\windowspowershell\v1.0\powershell.exe" -command
try{
$BLV = Get-BitLockerVolume -MountPoint $env:SystemDrive
        $KeyProtectorID=""
        foreach($keyProtector in $BLV.KeyProtector){
            if($keyProtector.KeyProtectorType -eq "RecoveryPassword"){
                $KeyProtectorID=$keyProtector.KeyProtectorId
                break;
            }
        }

       $result = BackupToAAD-BitLockerKeyProtector -MountPoint "$($env:SystemDrive)" -KeyProtectorId $KeyProtectorID
return $true
}
catch{
     return $false
}

Your help will be appriciated.

Welcome to BigFix!

You could just use the PowerShell script type directly if you are on a recent version of BigFix. Otherwise, the curly-bracket is evaluated as a Relevance substitution; you need to escape the open-curly-bracket by doubling it as in

try {{
    Do something
 }

See Tip: Escaping curly brackets for substitutions in ActionScript for more examples

Ok using the powershell script type works well.
Thanks alot

1 Like