This PowerShell script, authored by Tycho Löke, automates the process of retrieving and downloading all scripts associated with your Intune account via the Microsoft Graph API.
The downloaded scripts are saved locally at C:\temp
by default.
✅ Automated Intune Script Retrieval – Fetches all scripts linked to your Intune tenant.
✅ Secure Authentication – Uses a pop-up login window for seamless authentication with Microsoft Graph.
✅ Optimized Module Usage – Only loads Microsoft.Graph.DeviceManagement instead of the full Microsoft Graph SDK.
✅ User-Friendly Logging – Displays script names and status updates in real-time.
✅ Efficient & Non-Destructive – Prevents redundant installations and unnecessary re-execution.
Before running the script, ensure you meet the following requirements:
- Azure Active Directory (AAD) – Must have an Intune subscription.
- Admin Role – Requires Global Admin or Intune Admin role in AAD.
- PowerShell with Elevated Permissions – Run as Administrator.
- Internet Connectivity – Needed to install required PowerShell modules.
Clone this repository or download the script file manually.
git clone https://github.com/your-repo/intune-script-retriever.git
cd intune-script-retriever
- Open PowerShell with elevated permissions (
Run as Administrator
).
Run the script using:
.\Intune-Script-Retriever.ps1
- A pop-up login window will appear.
- Sign in with your AAD Global Admin or Intune Admin credentials.
✅ The script checks for required modules (NuGet
& Microsoft.Graph.DeviceManagement
).
✅ If missing, it installs them automatically.
✅ The script connects to the Microsoft Graph API via pop-up login.
✅ Retrieves all Intune scripts and displays their names.
✅ Downloads and saves scripts locally to C:\temp
.
✅ Displays a success message once all scripts are downloaded.
- The script now uses the pop-up login method (
-UseWebLogin
) instead of device authentication. - It only loads
Microsoft.Graph.DeviceManagement
, reducing load times. - Scripts are saved in ASCII encoding for compatibility.
- If a script with the same name already exists, it will be overwritten.
- To change the save location, modify the
$ScriptPath
variable in the script.
- Verify that you have the correct AAD permissions and an active Intune subscription.
- Ensure you have internet connectivity and that your PowerShell execution policy allows module installation.
- Check the PowerShell output and verify if required permissions or dependencies are missing.
Want to improve this script? Contributions are welcome!
To contribute:
- Fork the repository.
- Create a feature branch (
git checkout -b feature-name
). - Submit a Pull Request with your changes.
This project is licensed under the MIT License – feel free to use, modify, and distribute it.