powershell-intune-samples icon indicating copy to clipboard operation
powershell-intune-samples copied to clipboard

Issue running Get-authtoken from Task Scheduler unattended

Open komman-ship-it opened this issue 3 months ago • 0 comments

The authresult is empty without any exceptions when ran using a task scheduler

  • works fine when run manually from powershell
  • Fails in manual/scheduled on Task manager
  • Run as with dedicated service account with local admin rights, run as batch user rights
  • Uses a UPN which has Intune admin rights
  • Script works great when running in powershell but fails to get response for auth result when called with " Start-Process powershell.exe -argumentList "-executionPolicy Bypass -File "

Anyone started noticing this recently? Appreciate any pointers

$authResult = [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContextIntegratedAuthExtensions]::AcquireTokenAsync($authContext, $resourceAppIdURI, $clientid, $userCredentials)

komman-ship-it avatar Oct 02 '25 16:10 komman-ship-it