Import-PSSession is not working for Enable-RemoteMailBox. Example : $Session = New-PSSession -ConfigurationName Microsoft.Exchange -Connecti
Import-PSSession is not working for Enable-RemoteMailBox.
Example :
$Cred2 = Get-AutomationPSCredential -Name 'Credentials'
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://OnPrem-ExchangeServerURL/PowerShell/ -Authentication Kerberos -Credential $Cred2
Import-PSSession $Session -AllowClobber
Enable-RemoteMailbox -Identity $Email -RemoteRoutingAddress $SamAccountName@tenantname.mail.onmicrosoft.com
This commands fails to start the session - It stays into loop and does import the session.
Eventually, I want to import session in exchange server and change the mailbox to Remote via Enable-RemoteMailBox
Error Message:
The names of some imported commands from the module 'tmp_yd05zbqm.wbf' include unapproved verbs that might make them
less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose
parameter. For a list of approved verbs, type Get-Verb.

3 comments
-
Anonymous commented
Cool. That worked for me too. Thanks mate!
-
Maico Presente commented
Thank you Jeremy!!!!!
-
Jeremy McCourt commented
Okay, after a bit of troubleshooting I found a website with a suggestion.
wrap the Import-PSSession in an Import-Module.Import-Module (Import-PSSession -Session $session -DisableNameChecking -AllowClobber) -Global
From this, I was still getting an error on one of the functions, so I added a -verbose in the Import-Module
Import-Module -verbose (Import-PSSession -Session $session -DisableNameChecking -AllowClobber ) -Global
From that, I found a command that was throwing the error. So, I was only using two functions from the module anyway, so I specified those directly.
Import-Module -function Get-RetentionCompliancePolicy,Set-RetentionCompliancePolicy (Import-PSSession -Session $session -DisableNameChecking -AllowClobber ) -Global
From this, I was able to get the azure automation function to work, and not throw any errors. I hope this helps someone.