question

NM-0091 avatar image
0 Votes"
NM-0091 asked LuDaiMSFT-0289 commented

Powershell script package deployment using Intune failed on some machines

Hello,

I am trying to deploy a PowerShell script using Intune. The machines are joined to Azure AD. The deployment went fine on most of the machine but on few of them the script failed with the following error -

LogonUser failed with error code : 1008

AAD User check is failed, exception is System.ComponentModel.Win32Exception (0x80004005): An attempt was made to reference a token that does not exist
at Microsoft.Management.Services.IntuneWindowsAgent.AgentCommon.ImpersonateHelper.

AAD User check using device check in app is failed, now fallback to the Graph audience. ex = System.ComponentModel.Win32Exception (0x80004005): An attempt was made to reference a token that does not exist
at Microsoft.Management.Services.IntuneWindowsAgent.AgentCommon.DiscoveryService.<IsAADUserInternal>d__17.MoveNext()

Experts please, suggest.

mem-intune-generalmem-intune-device-configurations
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RahulJindal-2267 avatar image
0 Votes"
RahulJindal-2267 answered NM-0091 commented

Is a license assigned to the primary user of the device? Is the device shared by any chance?

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

All the users are assigned the same license. One device is only assigned to a single user.

But within the script a different account is used for some jobs.

0 Votes 0 ·

I see. Can you give some details on what is the script doing?

0 Votes 0 ·

The script is collection few logs and uploading to sharepoint.

0 Votes 0 ·
LuDaiMSFT-0289 avatar image
0 Votes"
LuDaiMSFT-0289 answered LuDaiMSFT-0289 converted comment to answer

@NM-0091 Thanks for posting in our Q&A.

To clarify this issue, we appreciate your help to check the sign in user in the failed device has the appropriate permissions to run the script.

If everything is normal, it is needed to do more log analysis. Please understand that the log message is general and not enough to find the root cause. With Q&A limitation, it is suggested to open an online support ticket to solve this issue more effectively. It is free. Here is the online support link:
https://docs.microsoft.com/en-us/mem/intune/fundamentals/get-support

Hope this issue will be solved as soon as possible.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

What kind of log can you please provide details.

0 Votes 0 ·
LuDaiMSFT-0289 avatar image
0 Votes"
LuDaiMSFT-0289 answered LuDaiMSFT-0289 commented

@NM-0091 For this issue, I have done the research again. It is suggested to try to restart the device and check if the Powershell script deployment is successful.

If it still fails, it is suggested to try the following actions:
1.If the local user login the device, please run the script as system with "Solution 2" in the affected device in the following link. And check if it is successful.
https://powershell-guru.com/powershell-tip-53-run-powershell-as-system/
Note: Non-Microsoft link, just for the reference.

2.If the Azure AD account login the device, please run the script directly in the affected device. And check if it is successful.

3.Please check the device is 32 bit or 64 bit and check use which credential to run the script. Make sure the device meets the settings about PowerShell script in intune.
116731-image.png

116741-image.png

4.Powershell script errors, we usually check messages in C:\ProgramData\Microsoft\IntuneManagementExtension\Logs
https://docs.microsoft.com/en-us/mem/intune/apps/intune-management-extension#intune-management-extension-logs
Please double confirm if there is any other error message.

If there is anything update, feel free to let us know.



image.png (8.4 KiB)
image.png (10.5 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@NM-0091 Haven't heard from you for a long time, I am currently standing by for further update from you and would like to know how things are going. If you have any questions or concerns on the recent information I've provided you, please don't hesitate to let me know.

0 Votes 0 ·