In my previous blog post, I have provided the steps to deploy Powershell script using Intune. For creating powershell script deployment on Intune admin center, you have to upload the script while creating the deployment. The script gets uploaded on Microsoft managed servers.
There could be a scenario when you have lost this script and do not have it any more. This could be due to permanent deletion of the script from your storage or you may not know the location where you have kept the source script files.
As of now there is no option to download your script files uploaded on Intune admin center. But there is way to retrieve the source script files. In this blog post, I will show you how you can get back powershell script files.
You can deploy MSI file using Line of business apps option and .exe files using Win32 app option. If you create an application deployment for deploying MSI or .exe files, you will have to upload the setup files on Intune admin center while creating the deployment.
Not only you can retrieve Powershell script files but also MSI and Win32 app setup files. I have provided the steps to retrieve MSI and Win32 app setup files from Intune in the blog post: Retrieve Uploaded LOB MSI / Win32 App Setup Files From Microsoft Intune.
Where Intune downloads powershell script on target device ?
You can deploy powershell script to end user devices using Intune by navigating to Microsoft Intune admin center > Devices > Scripts. The scripts are first downloaded on the device and then executed either in User context or Device context depending upon the settings configured from Intune admin center.
The Intune powershell scripts are downloaded at C:\Program Files (x86)\Microsoft Intune Management Extension\Policies\Scripts location and deleted after the script execution is completed. So you may generally find this folder empty.
In case you want to retrieve a script from this location, first you need to deploy the script on a device where this script has never been deployed and monitor this location. You will have to be quick to copy the script and paste it in another folder before it gets deleted by Intune Management Extension.
How to find the status of Powershell script deployed from Intune
After you have deployed powershell script deployed on the devices, you want to check its status and find out if its successful or failed. There are many ways to find out if the status. In the next sections, I will check the steps.
1. Check status of Powershell script execution from Windows registry
To confirm if powershell script deployed via Intune has been executed successfully, you can open Windows registry editor and check its status by using below steps. For checking Powershell script status using Windows registry, you will need Policy ID of the powershell script deployment. Let’s check the steps to find Policy Id:
Find Policy Id of Powershell script deployment
To find Policy Id of powershell script deployment using Intune admin center follow below steps:
- Login on Microsoft Intune admin center
- Go to Devices > Scripts under Policy section
- Click on the Script deployment and copy its Policy Identifier value using browser Address bar
- Go to Start and search for Registry Editor. Click on it to open registry editor
- Navigate to registry Key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IntuneManagementExtension\Policies
- Under it you will find a registry key with powershell script deployment Policy Id. Check the Result registry entry to find deployment status. As you can see from below screenshot, Result shows as Success.
2. Check status of Powershell script execution using Intune admin center
You can also check the status of powershell script execution from Intune admin center as well. Please follow below steps to confirm powershell script deployment status:
- Login on Microsoft Intune admin center
- Go to Devices > Scripts under Policy section
- Click on the Script deployment and go to Overview page to find the status
- To check device or user specific deployment status of the Powershell script, then you can click on Device status or User status under Monitor to find status per device/user.
3. Check status of Powershell script execution using Intune Management Extension logs
You can also check Powershell script execution status by using Intune Management Extension logs. Follow below steps to find out if your powershell script deployment via Intune is succeeded.
- Navigate to C:\ProgramData\Microsoft\IntuneManagementExtension\Logs
- Find most recent IntuneManagementExtension.log file and open it
- Best way to open .log files is by using a tool called CMTrace.
- Search for Policy Id and check Policy result. As you can see Policy result is showing as Success for this deployment.
Conclusion
In this blog post I have discussed about how you can retrieve powershell scripts which you have uploaded on Intune admin center. Along with that I have provided different options to find out the status of Powershell script deployment. This also helps while troubleshooting any script deployment Issues.