@@ -61,21 +61,21 @@ To prevent remote PowerShell access for a specific group of existing users, you
61
61
To disable access to remote PowerShell for any number of users based on an existing attribute, use the following syntax:
62
62
63
63
``` powershell
64
- $<VariableName> = <Get-Mailbox | Get-User> -ResultSize unlimited -Filter <Filter>
64
+ $<VariableName> = <Get-Mailbox | Get-User> -ResultSize Unlimited -Filter <Filter>
65
65
```
66
66
67
67
``` powershell
68
- $<VariableName> | foreach {Set-User -RemotePowerShellEnabled $false}
68
+ $<VariableName> | foreach {Set-User -Identity $_ - RemotePowerShellEnabled $false}
69
69
```
70
70
71
71
This example removes access to remote PowerShell for all users whose ** Title** attribute contains the value "Sales Associate".
72
72
73
73
``` powershell
74
- $DSA = Get-User -ResultSize unlimited -Filter "(RecipientType -eq 'UserMailbox') -and (Title -like '*Sales Associate*')"
74
+ $DSA = Get-User -ResultSize Unlimited -Filter "(RecipientType -eq 'UserMailbox') -and (Title -like '*Sales Associate*')"
75
75
```
76
76
77
77
``` powershell
78
- $DSA | foreach {Set-User -RemotePowerShellEnabled $false}
78
+ $DSA | foreach {Set-User -Identity $_ - RemotePowerShellEnabled $false}
79
79
```
80
80
81
81
### Use a list of specific users
@@ -87,7 +87,7 @@ $<VariableName> = Get-Content <text file>
87
87
```
88
88
89
89
``` powershell
90
- $<VariableName> | foreach {Set-User -RemotePowerShellEnabled $false
90
+ $<VariableName> | ForEach-Object {Set-User $_ -RemotePowerShellEnabled $false}
91
91
```
92
92
93
93
This example uses the text file C:\My Documents\NoPowerShell.txt to identify the users by their user principal name (UPN). The text file must contain one UPN on each line like this:
@@ -101,7 +101,7 @@ $NPS = Get-Content "C:\My Documents\NoPowerShell.txt"
101
101
```
102
102
103
103
``` powershell
104
- $NPS | foreach {Set-User -RemotePowerShellEnabled $false}
104
+ $NPS | foreach {Set-User -Identity $_ - RemotePowerShellEnabled $false}
105
105
```
106
106
107
107
## View the remote PowerShell access for users
@@ -121,17 +121,17 @@ Get-User -Identity "Sarah Jones" | Format-List RemotePowerShellEnabled
121
121
To display the remote PowerShell access status for all users, run the following command:
122
122
123
123
``` powershell
124
- Get-User -ResultSize unlimited | Format-Table -Auto Name,DisplayName,RemotePowerShellEnabled
124
+ Get-User -ResultSize Unlimited | Format-Table Name,DisplayName,RemotePowerShellEnabled -AutoSize
125
125
```
126
126
127
127
To display only those users who don't have access to remote PowerShell, run the following command:
128
128
129
129
``` powershell
130
- Get-User -ResultSize unlimited -Filter 'RemotePowerShellEnabled -eq $false'
130
+ Get-User -ResultSize Unlimited -Filter 'RemotePowerShellEnabled -eq $false'
131
131
```
132
132
133
133
To display only those users who have access to remote PowerShell, run the following command:
134
134
135
135
``` powershell
136
- Get-User -ResultSize unlimited -Filter 'RemotePowerShellEnabled -eq $true'
136
+ Get-User -ResultSize Unlimited -Filter 'RemotePowerShellEnabled -eq $true'
137
137
```
0 commit comments