Created
February 20, 2012 18:15
-
-
Save Iristyle/1870431 to your computer and use it in GitHub Desktop.
WinRM alias for Microsoft.Powershell_Profile.ps1 to hide the ugliness that is starting a remote session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Start-RemoteSession | |
{ | |
param( | |
[parameter(Mandatory=$true)] | |
[string] $HostName, | |
[parameter(Mandatory=$true)] | |
[string] $UserName, | |
[parameter(Mandatory=$true)] | |
[string] $Password | |
) | |
$params = @{ | |
ComputerName = $HostName; | |
Credential = New-Object System.Management.Automation.PsCredential($UserName,(ConvertTo-SecureString $Password -AsPlainText -force)) | |
} | |
Enter-PSSession @params | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add to your Powershell profile - typically stored in %userprofile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Use in a session like:
Start-RemoteSession 'server' 'user' 'password'
Way easier than the wacky credential / secure string shenanigans.