Skip to content

Instantly share code, notes, and snippets.

@jkbryan
Created January 30, 2019 23:19
Show Gist options
  • Save jkbryan/35d705bb858fe4083e106ea49985b5fd to your computer and use it in GitHub Desktop.
Save jkbryan/35d705bb858fe4083e106ea49985b5fd to your computer and use it in GitHub Desktop.
Use the Service Principle created previosly to connect to services - Azure AD and AzureRM as examples
$TenantId = "<AzureADTenantID>"
$ApplicationId = "<AppID>"
$Cert=Get-ChildItem cert:\CurrentUser\My\"<CertificateThumbprint>"
# Connect to Azure AD:
Connect-AzureAD -TenantId $TenantId -ApplicationId $ApplicationId -CertificateThumbprint $Cert.Thumbprint
# e.g. Get-AzureADUsers
# Connect to AzureRM:
Connect-AzureRmAccount -CertificateThumbprint $Cert.Thumbprint -ApplicationId $ApplicationId -Tenant $TenantId -ServicePrincipal
# e.g. Get-AzureRMResourceGroup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment