0

Requirement: must be run from local machine on remote machine with creds passed to the remote machine script.

$server = 'SRV1'
$credential = Get-Credential
$credentials = Get-Credential
Invoke-Command -ComputerName $server -Credential $credential -ScriptBlock {
    C:\foo.ps1 $credentials
 }

foo.ps1 requires functions that need $credentials

Inside foo.ps1

param($credentials)
Brandon Scott
  • 25
  • 1
  • 1
  • 5

1 Answers1

0

You can't use the Variable $credentials in the scriptBlock on the other computer without passing it as a parameter: Pass arguments to a scriptblock in powershell

Nicicalu
  • 759
  • 7
  • 16