Skip to content

Commit 8070339

Browse files
committed
Disable user sign in using PowerShell and Graph API
1 parent 6f18d6f commit 8070339

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

articles/active-directory/manage-apps/disable-user-sign-in-portal.md

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ ms.service: active-directory
88
ms.subservice: app-mgmt
99
ms.workload: identity
1010
ms.topic: how-to
11-
ms.date: 09/06/2022
11+
ms.date: 2/23/2023
1212
ms.author: jomondi
1313
ms.reviewer: ergreenl
1414
ms.custom: it-pro
1515
ms.collection: M365-identity-device-management
16+
zone_pivot_groups: enterprise-apps-all
17+
1618
#customer intent: As an admin, I want to disable user sign-in for an application so that no user can sign in to it in Azure Active Directory.
1719
---
1820
# Disable user sign-in for an application
@@ -28,10 +30,12 @@ In this article, you'll learn how to prevent users from signing in to an applica
2830
To disable user sign-in, you need:
2931

3032
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
31-
- One of the following roles: Global Administrator, Cloud Application Administrator, Application Administrator, or owner of the service principal.
33+
- One of the following roles: An administrator, or owner of the service principal.
3234

3335
## Disable how a user signs in
3436

37+
:::zone pivot="portal"
38+
3539
1. Sign in to the [Azure portal](https://portal.azure.com) as the global administrator for your directory.
3640
1. Search for and select **Azure Active Directory**.
3741
1. Select **Enterprise applications**.
@@ -40,11 +44,15 @@ To disable user sign-in, you need:
4044
1. Select **No** for **Enabled for users to sign-in?**.
4145
1. Select **Save**.
4246

43-
## Use Azure AD PowerShell to disable an unlisted app
47+
:::zone-end
48+
49+
:::zone pivot="aad-powershell"
4450

45-
Ensure you've installed the AzureAD module (use the command Install-Module -Name AzureAD). In case you're prompted to install a NuGet module or the new Azure Active Directory V2 PowerShell module, type Y and press ENTER.
51+
Use the following Azure AD PowerShell script to disable an unlisted app.
4652

47-
You may know the AppId of an app that doesn't appear on the Enterprise apps list. For example, you may have deleted the app or the service principal hasn't yet been created due to the app being pre-authorized by Microsoft), you can manually create the service principal for the app and then disable it by using the following cmdlet.
53+
Ensure you've installed the AzureAD module (use the command `Install-Module -Name AzureAD`). In case you're prompted to install a NuGet module or the new Azure AD V2 PowerShell module, type Y and press ENTER.
54+
55+
You may know the AppId of an app that doesn't appear on the Enterprise apps list. For example, you may have deleted the app or the service principal hasn't yet been created due to the app being pre-authorized by Microsoft, you can manually create the service principal for the app and then disable it by using the following cmdlet.
4856

4957
```PowerShell
5058
# The AppId of the app to be disabled
@@ -60,6 +68,41 @@ if ($servicePrincipal) {
6068
$servicePrincipal = New-AzureADServicePrincipal -AppId $appId -AccountEnabled $false
6169
}
6270
```
71+
:::zone-end
72+
73+
:::zone pivot="ms-powershell"
74+
75+
Use the following Microsoft Graph PowerShell script to disable an unlisted app.
76+
77+
Ensure you've installed the Microsoft Graph module (use the command `Install-Module Microsoft.Graph`).
78+
79+
You may know the AppId of an app that doesn't appear on the Enterprise apps list. For example, you may have deleted the app or the service principal hasn't yet been created due to the app being pre-authorized by Microsoft, you can manually create the service principal for the app and then disable it by using the following cmdlet.
80+
81+
:::zone-end
82+
83+
:::zone pivot="ms-graph"
84+
85+
You may know the AppId of an app that doesn't appear on the Enterprise apps list. For example, you may have deleted the app or the service principal hasn't yet been created due to the app being pre-authorized by Microsoft, you can manually create the service principal for the app and then disable it by using Microsoft Graph explorer.
86+
87+
To disable sign-in to an application, sign in to [Graph Explorer](https://developer.microsoft.com/graph/graph-explorer) with one of the roles listed in the prerequisite section.
88+
89+
You'll need to consent to the `Application.ReadWrite.All` permission.
90+
91+
Run the following query to disable user sign-in to an application.
92+
93+
```http
94+
PATCH https://graph.microsoft.com/v1.0/servicePrincipals/2a8f9e7a-af01-413a-9592-c32ec0e5c1a7
95+
96+
Content-type: application/json
97+
98+
{
99+
"accountEnabled": false
100+
}
101+
```
102+
103+
:::zone-end
104+
105+
63106

64107
## Next steps
65108

0 commit comments

Comments
 (0)