Skip to content

Commit d10d72b

Browse files
authored
Merge pull request #24501 from MicrosoftDocs/main
Publish main to live, Tuesday 10:30AM PST, 02/20
2 parents 290c62a + 0a0d540 commit d10d72b

34 files changed

Lines changed: 459 additions & 395 deletions

.openpublishing.redirection.frontline.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
"redirect_url":"/microsoft-365/frontline/shifts-for-teams-landing-page",
66
"redirect_document_id":true
77
},
8+
{
9+
"source_path":"microsoft-365/frontline/schedule-owner-for-shift-management.md",
10+
"redirect_url":"/microsoft-365/frontline/shifts-frontline-manager-worker-roles",
11+
"redirect_document_id":true
12+
},
813
{
914
"source_path":"microsoft-365/frontline/get-up-and-running.md",
1015
"redirect_url":"/microsoft-365/frontline/flw-team-collaboration",

microsoft-365/commerce/subscriptions/allowselfservicepurchase-powershell.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,14 @@ The following table lists the available products and their **ProductId**. It als
9393

9494
| Product | ProductId | Is trial without payment method enabled? |
9595
|-----------------------------|--------------|--------------|
96-
| Cllipchamp Premium | CFQ7TTC0N8SS | No |
96+
| Clipchamp Premium | CFQ7TTC0N8SS | No |
9797
| Power Apps per user* | CFQ7TTC0LH2H | No |
9898
| Power Automate per user* | CFQ7TTC0LH3L | No |
9999
| Power Automate RPA* | CFQ7TTC0LSGZ | No |
100100
| Power BI Premium (standalone)* | CFQ7TTC0H6RP | No |
101101
| Power BI Pro* | CFQ7TTC0H9MP | No |
102102
| Project Plan 1* | CFQ7TTC0HDB1 | Yes |
103103
| Project Plan 3* | CFQ7TTC0HDB0 | No |
104-
| Python in Excel | CFQ7TTC0S3X1 | Yes |
105104
| Teams Exploratory | CFQ7TTC0J1FV | Yes |
106105
| Teams Premium Introductory Pricing | CFQ7TTC0RM8K | Yes |
107106
| Visio Plan 1* | CFQ7TTC0HD33 | Yes |

microsoft-365/enterprise/block-user-accounts-with-microsoft-365-powershell.md

Lines changed: 42 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Block Microsoft 365 user accounts with PowerShell"
33
ms.author: kvice
44
author: kelleyvice-msft
55
manager: scotv
6-
ms.date: 07/16/2020
6+
ms.date: 02/14/2024
77
audience: Admin
88
ms.topic: article
99
ms.service: microsoft-365-enterprise
@@ -13,13 +13,15 @@ search.appverid:
1313
ms.collection:
1414
- scotvorg
1515
- Ent_O365
16+
- must-keep
1617
f1.keywords:
1718
- CSH
1819
ms.custom:
1920
- Ent_Office_Other
2021
- PowerShell
2122
- seo-marvel-apr2020
2223
- has-azure-ad-ps-ref
24+
- azure-ad-ref-level-one-done
2325
ms.assetid: 04e58c2a-400b-496a-acd4-8ec5d37236dc
2426
description: How to use PowerShell to block and unblock access to Microsoft 365 accounts.
2527
---
@@ -30,60 +32,79 @@ description: How to use PowerShell to block and unblock access to Microsoft 365
3032

3133
When you block access to a Microsoft 365 account, you prevent anyone from using the account to sign in and access the services and data in your Microsoft 365 organization. You can use PowerShell to block access to individual or multiple user accounts.
3234

33-
## Use the Azure Active Directory PowerShell for Graph module
35+
## Block access to individual user accounts
3436

35-
First, [connect to your Microsoft 365 tenant](connect-to-microsoft-365-powershell.md#connect-with-the-azure-active-directory-powershell-for-graph-module).
37+
>[!NOTE]
38+
> The Azure Active Directory module is being replaced by the Microsoft Graph PowerShell SDK. You can use the Microsoft Graph PowerShell SDK to access all Microsoft Graph APIs. For more information, see [Get started with the Microsoft Graph PowerShell SDK](/powershell/microsoftgraph/get-started).
3639
37-
### Block access to individual user accounts
40+
First, [connect to your Microsoft 365 tenant](connect-to-microsoft-365-powershell.md).
41+
42+
Blocking and unblocking user accounts requires the **User.ReadWrite.All** permission scope or one of the other permissions listed in the ['List subscribedSkus' Graph API reference page](/graph/api/subscribedsku-list).
43+
44+
```powershell
45+
Connect-Graph -Scopes User.ReadWrite.All
46+
```
3847

3948
Use the following syntax to block an individual user account:
4049

4150
```powershell
42-
Set-AzureADUser -ObjectID <sign-in name of the user account> -AccountEnabled $false
51+
$params = @{
52+
accountEnabled = $false
53+
}
54+
Update-MgUser -UserId <sign-in name of the user account> -BodyParameter $params
4355
```
4456

4557
> [!NOTE]
46-
> The *-ObjectID* parameter in the **Set-AzureAD** cmdlet accepts either the account sign-in name, also known as the User Principal Name, or the account's object ID.
58+
> The *-UserId* parameter in the **Update-MgUser** cmdlet accepts either the account sign-in name, also known as the User Principal Name, or the account's object ID.
4759
4860
This example blocks access to the user account *[email protected]*.
4961

5062
```powershell
51-
Set-AzureADUser -ObjectID [email protected] -AccountEnabled $false
63+
$params = @{
64+
accountEnabled = $false
65+
}
66+
Update-MgUser -UserId "[email protected]" -BodyParameter $params
5267
```
5368

5469
To unblock this user account, run the following command:
5570

5671
```powershell
57-
Set-AzureADUser -ObjectID [email protected] -AccountEnabled $true
72+
$params = @{
73+
accountEnabled = $true
74+
}
75+
Update-MgUser -UserId "[email protected]" -BodyParameter $params
5876
```
5977

6078
To display the user account UPN based on the user's display name, use the following commands:
6179

6280
```powershell
6381
$userName="<display name>"
64-
Write-Host (Get-AzureADUser | where {$_.DisplayName -eq $userName}).UserPrincipalName
82+
Write-Host (Get-MgUser -All | where {$_.DisplayName -eq $userName}).UserPrincipalName
6583
6684
```
6785

6886
This example displays the user account UPN for the user *Caleb Sills*.
6987

7088
```powershell
7189
$userName="Caleb Sills"
72-
Write-Host (Get-AzureADUser | where {$_.DisplayName -eq $userName}).UserPrincipalName
90+
Write-Host (Get-MgUser -All | where {$_.DisplayName -eq $userName}).UserPrincipalName
7391
```
7492

7593
To block an account based on the user's display name, use the following commands:
7694

7795
```powershell
7896
$userName="<display name>"
79-
Set-AzureADUser -ObjectID (Get-AzureADUser | where {$_.DisplayName -eq $userName}).UserPrincipalName -AccountEnabled $false
80-
97+
$user = Get-MgUser -Filter "displayName eq '$userName'"
98+
$params = @{
99+
accountEnabled = $false
100+
}
101+
Update-MgUser -UserId $user.Id -BodyParameter $params
81102
```
82103

83104
To check the blocked status of a user account use the following command:
84105

85106
```powershell
86-
Get-AzureADUser -ObjectID <UPN of user account> | Select DisplayName,AccountEnabled
107+
Get-MgUser -ObjectID <UPN of user account> -Property "displayName,accountEnabled" | Select displayName, accountEnabled
87108
```
88109

89110
### Block multiple user accounts
@@ -101,71 +122,21 @@ In the following commands, the example text file is *C:\My Documents\Accounts.tx
101122
To block access to the accounts listed in the text file, run the following command:
102123

103124
```powershell
104-
Get-Content "C:\My Documents\Accounts.txt" | ForEach {Set-AzureADUser -ObjectID $_ -AccountEnabled $false}
125+
$params = @{
126+
accountEnabled = $false
127+
}
128+
Get-Content "C:\My Documents\Accounts.txt" | ForEach {Update-MgUser -UserId $_ -BodyParameter $params}
105129
```
106130

107131
To unblock the accounts that are listed in the text file, run the following command:
108132

109133
```powershell
110-
Get-Content "C:\My Documents\Accounts.txt" | ForEach {Set-AzureADUser -ObjectID $_ -AccountEnabled $true}
111-
```
112-
113-
## Use the Microsoft Azure Active Directory module for Windows PowerShell
114-
115-
First, [connect to your Microsoft 365 tenant](connect-to-microsoft-365-powershell.md#connect-with-the-microsoft-azure-active-directory-module-for-windows-powershell).
116-
117-
### Block individual user accounts
118-
119-
Use the following syntax to block access for an individual user account:
120-
121-
```powershell
122-
Set-MsolUser -UserPrincipalName <sign-in name of user account> -BlockCredential $true
123-
```
124-
125-
>[!Note]
126-
>PowerShell Core doesn't support the Microsoft Azure Active Directory module for Windows PowerShell module and cmdlets that have *Msol* in their name. You have to run these cmdlets from Windows PowerShell.
127-
128-
This example blocks access to the user account *fabricec\@litwareinc.com*.
129-
130-
```powershell
131-
Set-MsolUser -UserPrincipalName [email protected] -BlockCredential $true
132-
```
133-
134-
To unblock the user account, run the following command:
135-
136-
```powershell
137-
Set-MsolUser -UserPrincipalName <sign-in name of user account> -BlockCredential $false
134+
$params = @{
135+
accountEnabled = $true
136+
}
137+
Get-Content "C:\My Documents\Accounts.txt" | ForEach {Update-MgUser -UserId $_ -BodyParameter $params}
138138
```
139139

140-
To check the blocked status of a user account run the following command:
141-
142-
```powershell
143-
Get-MsolUser -UserPrincipalName <sign-in name of user account> | Select DisplayName,BlockCredential
144-
```
145-
146-
### Block access for multiple user accounts
147-
148-
First, create a text file that contains one account on each line like this:
149-
150-
```powershell
151-
152-
153-
154-
```
155-
156-
In the following commands, the example text file is *C:\My Documents\Accounts.txt*. Replace this file name with the path and file name of your text file.
157-
158-
To block access for the accounts that are listed in the text file, run the following command:
159-
160-
```powershell
161-
Get-Content "C:\My Documents\Accounts.txt" | ForEach { Set-MsolUser -UserPrincipalName $_ -BlockCredential $true }
162-
```
163-
To unblock the accounts listed in the text file, run the following command:
164-
165-
```powershell
166-
Get-Content "C:\My Documents\Accounts.txt" | ForEach { Set-MsolUser -UserPrincipalName $_ -BlockCredential $false }
167-
```
168-
169140
## See also
170141

171142
[Manage Microsoft 365 user accounts, licenses, and groups with PowerShell](manage-user-accounts-and-licenses-with-microsoft-365-powershell.md)

0 commit comments

Comments
 (0)