how do I call a ps1 file that resides on a target machine? All tutorials mostly say that I run a local ps1 on a remote machine. I tried the following but it just does nothing :/
$username = "theusername" $password = "thepassword" $secpassword = ConvertTo-SecureString –String $password –AsPlainText -Force $credential = New-Object –TypeName "System.Management.Automation.PSCredential" –ArgumentList $username, $secpassword $so = New-PSSessionOption -SkipCACheck $session = New-PSSession -ConnectionUri "https://servername:5986/WSMAN" -SessionOption $so -Credential $credential Invoke-Command -Session $session -ScriptBlock { "powershell E:\\Tools\Powershells\MyPowershell.ps1" } Exit-PSSession
Invoke-Command -Session $session -ScriptBlock { & "local-path-to-my-script.ps1" }