How to use a PowerShell variable as command parameter?
Typically to use a variable to populate cmdlet parameters, you'd use a hash table variable, and splat it, using @
$newVar = @{option1 = $true} mycommand @newVar
Added example:
$AS_policy1 = @{Identity = "asdf"AllowBluetooth = $true}Set-ActiveSyncMailboxPolicy @AS_policy1
I had the same Problem and just found out how to resolve it. Solution is to use invoke-Expression: invoke-Expression $mycmdThis uses the $mycmd-string, replaces variables and executes it as cmdlet with given parameters