Advanced remoting - passing local hash table

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of Bojan Zivkovic Bojan Zivkovic 9 months ago.

  • Author
    Posts
  • #35915
    Profile photo of Bojan Zivkovic
    Bojan Zivkovic
    Participant

    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?

  • #35916
    Profile photo of Bojan Zivkovic
    Bojan Zivkovic
    Participant

    Sorry, I solved.


    Set-ItemProperty @using:property

You must be logged in to reply to this topic.