Author Posts

March 2, 2016 at 3:13 am

Hi, short question here. Is it possible to pass local hash table to remote computer and execute command there using that hash table (splatting). The following does not work:

`
if($enable) {$value = 0}
if($disable) {$value = 1}

$property = @{
Path = "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server"
Name = "fDenyTSConnections"
Value = $value
}

Invoke-Command -ComputerName SomeComputer -ScriptBlock {
Set-ItemProperty $using:property
}
`

I know $using:localvariable works with "simple" variable types such strings but is it possible to pass local hash table to remote computer via $using construction?

March 2, 2016 at 3:21 am

Sorry, I solved.


Set-ItemProperty @using:property