Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $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:\ToolsPowershellsMyPowershell.ps1" }
- Exit-PSSession
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement