powershell authentication

testuser7 271 Reputation points
2021-10-26T16:17:07.49+00:00

Hello,

In my power-shell script, when I do Connect-AzureAD, does the browser-windows that open is similar to incognito/private browser ??

The reason I am asking this is because, I do not find my existing shared cookies or PRTs to signin.

I have to literally type my credentials every time.

Thanks.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,355 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,387 questions
0 comments No comments
{count} vote

Accepted answer
  1. Marilee Turscak-MSFT 33,706 Reputation points Microsoft Employee
    2021-10-26T18:08:26.277+00:00

    For Azure AD joined accounts, I believe you can try:

    $UPN = whoami /upn
    Connect-AzureAD -AccountId $UPN
    

    Otherwise credentials are required Connect-AzureAD in either the Connect-AzureAD command or via the login window. This is by design for security purposes. One option is to use the -Credentials parameter and pass the username/password, but then you would still be using the credentials in the script itself.

    There is a related discussion on this topic here that includes these options, along with some pre-written scripts: https://techcommunity.microsoft.com/t5/azure-active-directory-identity/connect-azuread-with-login-credentials/m-p/145012


0 additional answers

Sort by: Most helpful