0

I am trying to create a script to connect to my exchange server remotely and create some alias for commonly used commands.

I connect to exchange using:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<ServerFQDN>/PowerShell/ -Authentication Kerberos -Credential $UserCredential

Import-PSSession $Session -DisableNameChecking

If I add to the bottom of this script:

New-Alias -Name "GR" -Value Get-Recipient

I see no error message, but no alias is created. If I run my script to connect to Exchange, and then run the New-Alias command in the terminal, the alias creates as expected.

I assume I am missing something fundamental regarding Sessions or scope, and any help gratefully received.

  • > Aliases created by using `New-Alias` are not saved after you exit the session or close PowerShell. – Santiago Squarzon Dec 12 '21 at 15:21
  • You could create files storing your aliases and call them when you launch your connection. The answer regarding how to achieve this can be found here – NeoTheNerd Dec 14 '21 at 11:08

0 Answers0