Skip to content

Conversation

Sartharon
Copy link

Description
Using -or comparison inside the Where-clause to exclude specified admins leads to having RemotePowerShell disabled for those users as well.
Example:
admin1 -ne admin1 -or admin1 -ne admin2
-> $false -or $true
-> $true

Using the -and comparison fixes this behavior, since neither admin1 nor (-ne + -and) admin2 should have their RemotePowerShell disabled.

Real world tests

  • Default State:
    image
  • After running the suggested cmdlet with administrator@lab.local and admin2@lab.local exempt
    Get-User | Where-Object {$_.UserPrincipalName -ne 'administrator@lab.local' -or $_.UserPrincipalName -ne 'admin2@lab.local'} | Set-USer -RemotePowerShellEnabled $false
    image
  • Using the corrected cmdlet with an -and comparison:
    image

@opbld30
Copy link

opbld30 commented Oct 10, 2022

Learn Build status updates of commit 08b9f1b:

✅ Validation status: passed

File Status Preview URL Details
exchange/docs-conceptual/control-remote-powershell-access-to-exchange-servers.md ✅Succeeded View (exchange-ps)

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

@chrisda
Copy link
Contributor

chrisda commented Oct 11, 2022

Already fixed yesterday #10027, thus now this PR results in merge conflicts.

Closing.

@chrisda chrisda closed this Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants