Disable RemotePowerShell

Marc 631 Reputation points

I have to disable RemotePowerShell and following the microsoft documentation I did the steps below:

1) Connected to ExchangeOnline

Install-Module -Name ExchangeOnlineManagement

Connect-ExchangeOnline -UserPrincipalName adminUser Get-User -Identity email | Format-List RemotePowerShellEnabled

2) Execute the command

Set-User -Identity userEmail -RemotePowerShellEnabled $false

Unfortunatelly I am receiving the error below:

Write-ErrorMessage : Ex04C125|Microsoft.Exchange.Configuration.Tasks.ManagementObjectNotFoundException|unable find user or group ....

If I run the command on "exchange management shell" it works but when I check on exchange online I can see it is still enabled


Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
6,532 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
4,897 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Andy David - MVP 121.1K Reputation points MVP

    Is that a mailbox in ExO? Verify that:

    get-user <user>  

    If a UserMailbox it will display:

    Name RecipientType
    ---- -------------
    User UserMailbox

    0 comments No comments

  2. Marc 631 Reputation points

    Yes, it is.


  3. Marc 631 Reputation points

    It seems a Microsoft bag....

    The work around is to use "-UseRPSSession".
    The command should be: Connect-ExchangeOnline -UseRPSSession -UserPrincipalName .....

  4. Andy David - MVP 121.1K Reputation points MVP

    Sorry the delay, Yes, I can confirm, using the UseRPSSession switch allows this to work. Good catch!

    0 comments No comments