Search Results

Search found 7 results on 1 pages for 'icnivad'.

Page 1/1 | 1 

  • Powershell Remoting: Execute local function on two target servers

    - by icnivad
    I have a function foo on my local Machine. (In my profile, but calling c:\scripts\foo.ps1 would be also OK!) How do i load this on ServerA and ServerB so i can execute the function in the next statement? This is what i tried with no success.. $serverlist = "192.168.20.1", "192.168.20.12" foreach ($item in $serverlist) { New-PSSession -ComputerName "$item" -Credential $cred -Name ($item + "_session") Invoke-Command -ComputerName $item -Credential $cred -filepath scripts:\foo.ps1 Invoke-Command -ComputerName $item -Credential $cred -scriptblock {foo} }

    Read the article

  • Powershell Remoting Handover Variables

    - by icnivad
    I've opened a Remote Session s1, and like to run a function with Parameters i handover in my scriptblock: Simplified example with Write-Host: $a = "aaa" $b = "bbb" $c = "ccc" $d = "ddd" Write-Host "AAAAA: $a $b $c $d" #This works fine as it's locally Invoke-Command -Session $s1 -scriptblock {Write-Host "BBBBB: $a $b $c $d"} #These variables are empty What is the cleanest way to handover Variables (I normally receive from a local csv file) to the scriptblock?

    Read the article

1