-
Notifications
You must be signed in to change notification settings - Fork 100
/
GetSharePointURL.ps1
15 lines (14 loc) · 1.01 KB
/
GetSharePointURL.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$UserName = "user"
$password = "pass"
Import-Module .\Microsoft.IdentityModel.Clients.ActiveDirectory.dll -Force
$upCred = new-Object Microsoft.IdentityModel.Clients.ActiveDirectory.UserPasswordCredential($UserName, $Password);
$EndpointUri = 'https://login.windows.net/common'
$Context = New-Object Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext($EndpointUri)
$AADcredential = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.UserPasswordCredential" -ArgumentList $UserName, $Password
$authenticationResult = [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContextIntegratedAuthExtensions]::AcquireTokenAsync($Context ,"https://graph.microsoft.com","d3590ed6-52b3-4102-aeff-aad2292ab01c",$AADcredential).result
$Header = @{
'Content-Type' = 'application\json'
'Authorization' = $authenticationResult.CreateAuthorizationHeader()
}
$Result = Invoke-RestMethod -Headers $Header -Uri ("https://graph.microsoft.com/v1.0/me/drive/root") -Method Get
write-host $Result.webUrl