Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Securescore/Secure Score Demo API.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@ $cred = Get-Credential
$mycred = new-object Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential($cred.UserName,$cred.Password)

# Defining Azure AD tenant name, this is the name of your Azure Active Directory, where xxxxxxxxxxxxxxxxxxx is the ID of your O365 Tenant
$adTenant = "xxxxxxxxxxxxxxxxxxxxxxxxxx.onmicrosoft.com
$adTenant = "xxxxxxxxxxxxxxxxxxxxxxxxxx.onmicrosoft.com"

# Load Active Directory Authentication Library (ADAL) Assemblies
$adal = ${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll
$adalforms = ${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll
$adal = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
$adalforms = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"
[System.Reflection.Assembly]::LoadFrom($adal)
[System.Reflection.Assembly]::LoadFrom($adalforms)

# Use the Client ID of native App that was registered in the Azure App Portal, where xxxxxx-xxxx-xxxx-xxxxxxx is the ID of your Client app
$clientId = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"

# Set redirect URI for Azure PowerShell
$redirectUri = urn:ietf:wg:oauth:2.0:oob
$redirectUri = "urn:ietf:wg:oauth:2.0:oob"

# Set Resource URI to Azure Service Management API
$resourceAppIdURI = https://graph.microsoft.com/
$resourceAppIdURI = "https://graph.microsoft.com/"

# Set Authority to Azure AD Tenant
$authority = https://login.windows.net/$adTenant
$authority = "https://login.windows.net/$adTenant"

# Create AuthenticationContext tied to Azure AD Tenant
$authContext = New-Object Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext -ArgumentList $authority
$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority

# Acquire token
$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $mycred)

# Building Rest Api header with authorization token
$authHeader = @{

Content-Type’=‘application\json
'Content-Type'='application\json'

Authorization=$authResult.CreateAuthorizationHeader()
'Authorization'=$authResult.CreateAuthorizationHeader()
}

# Execute the REST query, where X = the integer value of 1-90 of the number of days history you wish to retrieve.
Expand Down