So my script is pretty simple. I have a command that I need to execute with OpenVPN, so I need to cd
to that folder and execute: .\openvpn.exe $someCommand
.
Problem is, I get this error when I try to use cd
or Set-Location
:
Set-Location : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Path'. Specified method is not supported.
After searching for a solution I found a workaround with Get-ChildItem -Path $path
and then using the $_.Directory
attribute, but that didn't work either.
Basically I have something like this:
$openVpnPath = "C:\Program Files\OpenVPN\bin"
Invoke-Command -ScriptBlock {
Set-Location $openVpnPath,
".\openvpn.exe $conf"
}
The location is a regular path. If you're wondering why there's a comma at the end of Set-Location
it's because I read that I can execute 2 commands in the same Invoke-Command
block. Was I wrong?
Thanks :)