powershell authentication

testuser7 286 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 for business Windows Server User experience PowerShell
Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} vote

Accepted answer
  1. Marilee Turscak-MSFT 37,206 Reputation points Microsoft Employee Moderator
    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.