Well known powershell sessions
Jump to navigation
Jump to search
$Credentials = Get-Credential
#optional
$options = New-PSSessionOption -SkipCNCheck -SkipCACheck -SkipRevocationCheck
$ExSession = New-PSSession –ConfigurationName Microsoft.Exchange –ConnectionUri "http://ExServer1.contoso.com/PowerShell/?SerializationLevel=Full" -Credential $Credentials –Authentication Kerberos -SessionOption $options
Import-PSSession $ExSession
Remove-PSSession $ExSession
to remember
in combination with applocker/srp's
Import-PSSession : Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
At line:1 char:1
+ Import-PSSession $Session
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-PSSession], ArgumentOutOfRangeException
+ FullyQualifiedErrorId : System.ArgumentOutOfRangeException,Microsoft.PowerShell.Commands.ImportPSSessionCommand
The "Import-PSSession $Session" imports to "C:\Users\user\AppData\Local\Temp\tmp_random.vtq\tmp_random.vtq.psm1" or something... Always random. Make exception where needed...