This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Az module to login. Use allow no subscriptions if there is no active azure subcription assocaited with your tenant | |
| az login --allow-no-subscriptions | |
| #This app id corresponds to PnP Management Shell that is also used for CLI for Microsoft 365 | |
| $PnPPowerShellAppId = "31359c7f-bd7e-475c-86db-fdb8c937548e" | |
| #The guid 00000007-0000-0000-c000-000000000000 corresponds to Common Data Service/Dynamics CRM | |
| az ad app permission grant --id $PnPPowerShellAppId --api 00000007-0000-0000-c000-000000000000 --scope user_impersonation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from office365.runtime.auth.client_credential import ClientCredential | |
| from office365.sharepoint.client_context import ClientContext | |
| client_id = '--clientid--' | |
| client_secret = '--clientsecret---' | |
| site_url = 'https://contoso.sharepoint.com/sites/Web01' | |
| credentials = ClientCredential(client_id, | |
| client_secret) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from office365.runtime.auth.client_credential import ClientCredential | |
| from office365.sharepoint.client_context import ClientContext | |
| client_id = '--clientid--' | |
| client_secret = '--clientsecret---' | |
| site_url = 'https://contoso.sharepoint.com/sites/Web01' | |
| credentials = ClientCredential(client_id, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| clear | |
| # Application (client) ID, secret, tenant name and site | |
| $tenantPrefix = "CONTOSO"; #Pass 'Contoso' for contoso.onmicrosoft.com | |
| $clientId = "CLIENT ID"; #Pass the azure ad app id here | |
| $clientSecret = "CLIENT SECRET"; #Pass the azure ad app client secret | |
| $tenantName = $tenantPrefix +".onmicrosoft.com"; | |
| $tenantDomain = $tenantPrefix +".sharepoint.com"; | |
| $sitePath = "https://contoso.sharepoint.com/sites/Web01" | |
| $siteName = $sitePath.Split("/")[4] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| clear | |
| # Provide tenant prefix, Application (client) ID, and Client secret of the admin app | |
| $tenantPrefix = "contoso"; | |
| $clientId = "client-id"; | |
| $clientSecret = "client-secret"; | |
| $tenantName = $tenantPrefix +".onmicrosoft.com"; | |
| $tenantDomain = $tenantPrefix +".sharepoint.com"; | |
| #Provide the site url | |
| $sitePath = "https://contoso.sharepoint.com/sites/Web01" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| clear | |
| #Provie tenant prefix, Application (client) ID, and client secret of the IT admin app | |
| #IT admin app must have sites.fullcontrol app-only perms | |
| $tenantPrefix = "Contoso"; | |
| $clientId = "Client-Id"; | |
| $clientSecret = "Client-Secret"; | |
| $tenantName = $tenantPrefix +".onmicrosoft.com"; | |
| $tenantDomain = $tenantPrefix +".sharepoint.com"; | |
| #Site url |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #sample script |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| clear | |
| #Provie tenant prefix, Application (client) ID, and client secret of the IT admin app | |
| #IT admin app must have sites.fullcontrol app-only perms | |
| $tenantPrefix = "Contoso"; | |
| $clientId = "Client-ID"; | |
| $clientSecret = "Client-Secret"; | |
| $tenantName = $tenantPrefix +".onmicrosoft.com"; | |
| $tenantDomain = $tenantPrefix +".sharepoint.com"; | |
| #Provide site url |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Connect-MgGraph -Scopes "User.Read.All","Group.ReadWrite.All","Application.Read.All", "Application.ReadWrite.All", "Directory.Read.All", "Directory.ReadWrite.All", "Directory.AccessAsUser.All" | |
| $Apps = Get-MgApplication -All | |
| $today = Get-Date | |
| $credentials = @() | |
| $Apps | %{ | |
| $aadAppObjId = $_.Id | |
| $app = Get-MgApplication -ApplicationId $aadAppObjId | |
| $owner = Get-MgApplicationOwner -ApplicationId $aadAppObjId |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Connect-MgGraph -Scopes "User.Read.All","Group.ReadWrite.All","Application.Read.All", "Application.ReadWrite.All", "Directory.Read.All", "Directory.ReadWrite.All", "Directory.AccessAsUser.All" | |
| #https://graph.microsoft.com/v1.0/applications | |
| $Apps = Get-MgApplication -All | |
| $permissions = @() | |
| $Apps | %{ | |
| $app = $_ | |
| #https://graph.microsoft.com/v1.0/servicePrincipals?$filter=appId eq '00000003-0000-0ff1-ce00-000000000000' | |
| #Get-MgServicePrincipal -Filter "AppId eq '00000003-0000-0ff1-ce00-000000000000'" | |
| $app.RequiredResourceAccess | %{ | |
| $resource = $_ |