Disable RemotePowerShell

Marc 631 Reputation points
2022-11-11T16:57:25.263+00:00

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

259616-pshell-desabled.png

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.
7,345 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.
5,362 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Andy David - MVP 141.5K Reputation points MVP
    2022-11-11T17:21:11.037+00:00

    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
    2022-11-11T17:26:21.677+00:00

    Yes, it is.

    259647-pshell-desabled2.png


  3. Marc 631 Reputation points
    2022-11-15T10:12:29.58+00:00

    It seems a Microsoft bag....

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


  4. Andy David - MVP 141.5K Reputation points MVP
    2022-11-15T12:33:15.947+00:00

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

    0 comments No comments