Import-PSSession : The runspace state is not valid for this operation

Written by Yashdeep Sahni |11-Apr-2019 | 0 Comments | 463 Views

Today after connecting to Office 365 via power shell, I want to get some info of the mailbox so tried to run the script Get-Mailbox. But it throws me an error every time I tried to run the command

Get-mailbox: The term ‘get-mailbox’ is not recognized as the name of a cmdlet

get-mailbox not recognized - paayi

 

To solve this upper problem, I researched that we need to run, Import-PSSession command which provides us with lots of more commands for that particular session. I just typed this command and got this error.

import-pssession error

 

I researched a lot but found no solution. After 15 mins my PowerShell connection timeout happened. Then I thought let's try one more time, but this time altogether. Below is the whole command what you need to post in your PowerShell window and hit run.

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri 
https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential 
-Authentication Basic –AllowRedirection
Import-PSSession $session

You will get this result

Result
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
WARNING: The names of some imported commands from the module 
'tmp_zdv2hsce.qkw' 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.

ModuleType Version Name ExportedCommands 
---------- ------- ---- ---------------- 
Script 1.0 tmp_zdv2hsce.qkw {Add-AvailabilityAddressSpace, Add-Distribution...

ran import-pssession command

 

Means It's successful. Please leave a comment or ask the question if you need more help.

 





Login/Sign Up

Comments




Related Posts



© Copyright 2019, All Rights Reserved. paayi.com

This site uses cookies. By continuing to use this site or clicking "I Agree", you agree to the use of cookies. Read our cookies policy and privacy statement for more information.