Forum Discussion

dmarquesgn's avatar
dmarquesgn
Iron Contributor
Jun 02, 2023

Unattended scripts do not connect to Azure AD

Hi, I have a couple of scripts which should connect to Azure AD, to do whatever tasks and return some alarmistic over email. I'm using this type of connection: Connect-AzureAD -CertificateThumbpr...
  • LainRobertson's avatar
    Jun 02, 2023

    dmarquesgn 

     

    Hi.

     

    The first thing that comes to mind is: is the certification in your user store or the local machine store? If the scheduled task account can't see it and read the private key, that's one reason it could be failing.

     

    You may want to log output from the Connect-AzureAD commandlet within the scheduled task out to a file to learn more:

     

    $LogFile = "C:\Data\Temp\myScheduledTask.log";
    
    Connect-AzureAD -CertificateThumbprint "xxx" -ApplicationId "xxx" -TenantId "xxx" *> $LogFile;

     

    Cheers,

    Lain

Resources