Skip to content

Instantly share code, notes, and snippets.

@invictus-korstiaan
Last active May 8, 2024 07:49
Show Gist options
  • Save invictus-korstiaan/74101206ddcb98dc6f95cc7952c3a0bc to your computer and use it in GitHub Desktop.
Save invictus-korstiaan/74101206ddcb98dc6f95cc7952c3a0bc to your computer and use it in GitHub Desktop.
Connect to Graph APP
$ClientId = "ID-of-your-app"
$TenantId = "ID-of-your-tenant"
$ClientSecret = "Secret-of-your-app”
# Convert the client secret to a secure string
$ClientSecretPass = ConvertTo-SecureString -String $ClientSecret -AsPlainText -Force
# Create a credential object using the client ID and secure string
$ClientSecretCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ClientId, $ClientSecretPass
# Connect to Graph
Connect-MgGraph -TenantId $tenantId -ClientSecretCredential $ClientSecretCredential
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment