Advanced remoting - passing local hash table

This topic contains 1 reply, has 1 voice, and was last updated by  Bojan Zivkovic 1 year, 6 months ago.

  • Author
    Posts
  • #35915

    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

    Bojan Zivkovic
    Participant

    Sorry, I solved.


    Set-ItemProperty @using:property

You must be logged in to reply to this topic.