Well known powershell sessions

From WikiWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
$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...