Forum Discussion
Patrick Rote
Jan 18, 2022Iron Contributor
Connect to Azure AD from Powershell without prompt - what are my options?
Hi there, I want to schedule some script in PowerShell and i would need to login into Azure AD first. Is it possible to login to Azure AD without a prompt as the script needs to be automates/schedu...
Alan2022
May 26, 2022Iron Contributor
Hi Patrick Rote
# Save User Credentials
# New-StoredCredential -Target MyAccount -Username <Username> -Password <Password>
# User Authentication
$ua = Get-StoredCredential -Target MyAccount
$credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $ua.UserName,$ua.Password
# Login to your Azure Account
Connect-AzAccount -Tenant '<TenantID>' -Credential $credential
Still working until now.
- ERobillardApr 05, 2023Brass ContributorHspinto is correct, and the luck of Alan2022 will become useless after June 23. If you stuck with Connect-AzAccount your prize is getting to get to write this twice. Here's an article on upgrading from the AD API to MSGraph: https://learn.microsoft.com/en-us/powershell/microsoftgraph/migration-steps?view=graph-powershell-1.0