Unattended Login over Powershell Script to Azure AD without adding the password in plain text

Bühler Gabriel 81 Reputation points
2021-12-13T12:27:08.223+00:00

Hello Everyone

We currently have created a small application that automatically reads Users from a database, that should get added (or changed) automatically in our Azure Active Directory with a Powershell script. Now we would like to log onto the Azure AD with this script, without adding the password in plain text. Is there a possibility to log onto the Azure Active Directory unattended, without adding the password to the file itself?

Thank you for your Help.

Kind regards,

Gabriel

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Andy David - MVP 157.4K Reputation points MVP Volunteer Moderator
    2021-12-13T12:33:44.607+00:00

    Use Cert based auth instead. Dont use a service account with a password.

    https://learn.microsoft.com/en-us/graph/powershell/app-only?tabs=azure-portal


  2. Andy David - MVP 157.4K Reputation points MVP Volunteer Moderator
    2021-12-13T13:56:38.467+00:00

    Get-mguser works for all users.

    Example:

    Get-MgUser -All  
    Get-MgUser -UserId <user>  
    

    etc..

    https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.users/get-mguser?view=graph-powershell-beta

    0 comments No comments

  3. Limitless Technology 39,921 Reputation points
    2021-12-13T19:58:10.58+00:00

    Hello @Bühler Gabriel

    You can find different options to add authentication unattended to your script in this Microsoft article:

    https://learn.microsoft.com/en-us/powershell/azure/authenticate-azureps?view=azps-7.0.0

    Hope this helps with your query,

    ---------
    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

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.