I am trying to create a couple of files that I can save on my local desktop to launch PowerShell sessions.
The Windows Server 2008 and Windows Server 2012 are both Server Core installations.
Currently, I can open Powershell and type:
Enter-PSSession -computername Win2012SrvCore -credential administrator
Using this, I can connect and run commands and everything is great.
What I have tried to do is:
Create file called Win2012SrvCore1.ps1
with the following:
$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
Create file called Win2012SrvCore2.ps1
with the following:
PowerShell.exe -Command Enter-PSSession -computername Win2012SrvCore -credential administrator
Each ps1
file will launch and close quickly with some red text that I cannot read.
I have tried to add PAUSE
to each script but that doesn't seem to stop the window from closing.
What I would like to do is create scripts that I can double click and open to the powershell prompt, similar to a saved RDP session.
I have configured ps1 files to execute:
C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe
Any help would be greatly appreciated.