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" | |
#Get-Command -Module Microsoft.Graph* *serviceprincipal* | |
#Get-MgUser | |
#Use below if you have exact name to get the service principal of the AAD application | |
$azureAdAppName = "MGT-App" | |
$sp = Get-MgServicePrincipal -Filter "DisplayName eq '$azureAdAppName'" | |
#Use below if you have partial name to get the service principal of the AAD application | |
#$sp = Get-MgServicePrincipal -Search "DisplayName:MGT" -ConsistencyLevel "eventual" |
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 = $_ |
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
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
#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"; | |
#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
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 | |
# 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
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
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) |
NewerOlder