Have a Question?
Remote script
$Credential = Get-Credential Invoke-Command -Computername "ServName" -ScriptBlock { $env:COMPUTERNAME} -Credential $Credential
Avec Argument
$Credential = Get-Credential $script = { try{ $adPC = Get-ADComputer -Identity $args[0]} catch{$adPC = "Computer not existe"} return $adPC} Invoke-Command -Computername "ServName" -ScriptBlock { $script} -Credential $Credential -ArgumentList "ComputerName"