Launch remote PowerShell session using saved ps1 file

$passwd = convertto-securestring -AsPlainText -Force -String MYPASSWORD

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "administrator",$passwd

$session = new-pssession -computername Win2012SrvCore -credential $cred

Add one more line:

Import-PSSession $session

Then save the .PS1 file and create a shortcut to it as powershell.exe -noexit -File "C:\PS.ps1".

Leave a Comment