Import-PSSession fails in script, works in shell
问题 I'm new to Powershell scripting and I'm working on a user management Powershell script, but I have run into a strange error. The following code works when I run it from the shell, but not when it is run from a script: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://servername/Powershell/ -Authentication Kerberos -Credential $UserCredential -AllowRedirection Import-PSSession $Session When I run it in a script with a Param()