msimecek / AAD-automations

Various scripts and tools for scripting around Azure Active Directory, B2C etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Login without interactive window

staycoolkhan opened this issue · comments

Hi Martin, Thanks for the this great work. Could you guide me how to login into azure without interactive browser window because I'm trying to explore how to aut0mate this via azure deveops pipeline

I found I could get the token these two methods

$TenantId = "$($Name).onmicrosoft.com" # Name is the tenant name
$graphToken = (Get-AzAccessToken -TenantId $TenantId -ResourceTypeName MSGraph -ErrorAction Stop).Token
# or 
$graphToken = $(az account get-access-token --tenant $TenantId --resource-type ms-graph --query accessToken -o tsv)

Connect-MgGraph -AccessToken $graphToken | Out-Null

I'm planning on doing a blog post and expanding on the ideas here. Hope that helps

Thanks Martin. Looking forward to see your blog post for a such great work.

Sorry, I didn't get a notification about this issue.

Thanks @Eonasdan for addressing it.