Skip to content

Commit 77d457f

Browse files
committed
add Microsoft Graph PowerShell content
1 parent 8070339 commit 77d457f

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ To disable user sign-in, you need:
4848

4949
:::zone pivot="aad-powershell"
5050

51-
Use the following Azure AD PowerShell script to disable an unlisted app.
51+
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 Azure AD PowerShell cmdlet.
5252

5353
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.
5454

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.
56-
5755
```PowerShell
56+
# Connect to Azure AD PowerShell
57+
Connect-AzureAD -Scopes "Application.ReadWrite.All"
58+
5859
# The AppId of the app to be disabled
5960
$appId = "{AppId}"
6061
@@ -72,11 +73,25 @@ if ($servicePrincipal) {
7273

7374
:::zone pivot="ms-powershell"
7475

75-
Use the following Microsoft Graph PowerShell script to disable an unlisted app.
76+
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 Microsoft Graph PowerShell cmdlet.
7677

7778
Ensure you've installed the Microsoft Graph module (use the command `Install-Module Microsoft.Graph`).
7879

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+
```powershell
81+
# Connect to Microsoft Graph PowerShell
82+
Connect-MgGraph -Scopes "Application.ReadWrite.All"
83+
84+
# The AppId of the app to be disabled
85+
$appId = "{AppId}"
86+
87+
# Check if a service principal already exists for the app
88+
$servicePrincipal = Get-MgServicePrincipal -Filter "appId eq '$appId'"
89+
90+
# If Service principal exists already, disable it , else, create it and disable it at the same time
91+
if ($servicePrincipal) { Update-MgServicePrincipal -ServicePrincipalId $servicePrincipal.Id -AccountEnabled:$false }
92+
93+
else { $servicePrincipal = New-MgServicePrincipal -AppId $appId –AccountEnabled:$false }
94+
```
8095

8196
:::zone-end
8297

0 commit comments

Comments
 (0)