I have a problem reverting back powershell execution policy on remote computer using variable.
$RestrykcjaNowa = 'Bypass'
$RestrykcjaZastana = Invoke-Command -ComputerName $Komputer -ScriptBlock { Get-ExecutionPolicy }
$RestrykcjaZastana
Invoke-Command -ComputerName $Komputer -ScriptBlock { Set-ExecutionPolicy -ExecutionPolicy $RestrykcjaNowa -Scope LocalMachine -Force } | Out-Null
But I got an error
Cannot bind argument to parameter 'ExecutionPolicy' because it is null
When I replace variable $RestrykcjaNowa with value Bypass in last command it goes smoothly.
I noticed that variable $RestrykcjaZastana is not displayed on the screen when called in 2nd line of the code and is of type int but i can't assign value Bypass to integer variable manually.
What is wrong with my approach?
$USING:RestrykcjaNowainstead.