-
Notifications
You must be signed in to change notification settings - Fork 3
Add README with Intune script samples and guidelines #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
johngagefaulkner
wants to merge
5
commits into
jbasuroy369:main
Choose a base branch
from
johngagefaulkner:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6949ee9
Add README with Intune script samples and guidelines
johngagefaulkner 43de916
Rename Detect - MultipleIntuneMDMCert.ps1 to Detect-MultipleIntuneMDM…
johngagefaulkner ee1bd78
Update Detect-OfficeUpdateChannel.ps1
johngagefaulkner 2bdf8f7
Update Detect-OfficeUpdateChannel.ps1
johngagefaulkner 2982df6
Update Detect-MultipleIntuneMDMCert.ps1
johngagefaulkner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| try { | ||
| # Get all certificates from Local Machine Personal store with Issuer matching Microsoft Intune MDM Device CA | ||
| $certificates = Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object { $_.Issuer -eq "CN=Microsoft Intune MDM Device CA" } | ||
| if (($certificates).Count -gt 1) { | ||
| # Remediation needed on exit code 1 | ||
| Write-Output "Remediation needed" | ||
| Exit 1 | ||
| } | ||
| else { | ||
| # Remediation not needed on exit code 0 | ||
| Write-Output "Remediation not needed" | ||
| Exit 0 | ||
| } | ||
| } | ||
| catch { | ||
| $errMsg = $_.Exception.Message | ||
| Write-Host $errMsg | ||
| Exit 1 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| # Intune Script Samples | ||
|
|
||
| PowerShell script samples for common Microsoft Intune and endpoint management scenarios. | ||
|
|
||
| This repository contains practical scripts you can use for: | ||
|
|
||
| - Intune proactive remediation detection logic | ||
| - Local endpoint configuration changes (services/registry) | ||
| - Intune connectivity validation from client devices | ||
| - Microsoft Graph reporting for Intune app assignments | ||
| - Forcing an MDM sync on Windows devices | ||
|
|
||
| Repository: https://github.com/jbasuroy369/Intune-Script-Samples | ||
|
|
||
| --- | ||
|
|
||
| ## Scripts included | ||
|
|
||
| | Script | Purpose | Typical Intune Use | | ||
| |---|---|---| | ||
| | `Detect - MultipleIntuneMDMCert.ps1` | Detects if more than one **Microsoft Intune MDM Device CA** certificate exists in `LocalMachine\My`. Exits `1` if remediation is needed. | Proactive Remediations (Detection script) | | ||
| | `Detect-OfficeUpdateChannel.ps1` | Detects Office Click-to-Run channel/version against Microsoft Office releases endpoint and validates Semi-Annual + latest version logic. | Compliance check / detection workflow | | ||
| | `Disable_PrintSpoolerService.ps1` | Stops and disables the **Print Spooler** service. | Hardening / device script / remediation | | ||
| | `Enable_PrintSpoolerService.ps1` | Enables and starts the **Print Spooler** service. | Rollback / device script / remediation | | ||
| | `Get-IntuneAllAppsAssignmentDetails.ps1` | Uses Microsoft Graph to enumerate Intune apps and export assignment details (name/type/version/assignment/group) to CSV. | Tenant reporting / operations | | ||
| | `Initiate-MDMSync.ps1` | Triggers an MDM sync session on Windows and waits for completion (with timeout loop). | Device action / troubleshooting | | ||
| | `SmartCardLogonEnforcement.ps1` | Enables smart card logon enforcement and related registry settings, with logging under IME log path. | Win32 app / security baseline customization | | ||
| | `SmartCardLogonEnforcement_Disable.ps1` | Reverts smart card logon enforcement settings and removes prior enforcement log file. | Rollback Win32 app | | ||
| | `Test-IntuneConnectivity.ps1` | Pulls current M365/Intune endpoints and tests outbound connectivity (with proxy handling and category-based output). | Network troubleshooting / readiness validation | | ||
|
|
||
| --- | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### General | ||
| - Windows endpoint | ||
| - PowerShell 5.1+ (some scripts may also run on lower versions, but 5.1+ is recommended) | ||
| - Appropriate local permissions (several scripts modify services/registry and typically require elevated context) | ||
|
|
||
| ### Script-specific | ||
| - `Get-IntuneAllAppsAssignmentDetails.ps1` | ||
| - Internet access to Microsoft Graph | ||
| - Microsoft Graph PowerShell module (`Microsoft.Graph`) | ||
| - Entra app registration with required Graph app permissions for reading Intune app and group data | ||
| - `Test-IntuneConnectivity.ps1` | ||
| - Internet/proxy access to: | ||
| - `https://endpoints.office.com/...` | ||
| - Intune / M365 service endpoints returned by that feed | ||
| - `Detect-OfficeUpdateChannel.ps1` | ||
| - Access to Office Click-to-Run registry keys and: | ||
| - `https://clients.config.office.net/releases/v1.0/OfficeReleases` | ||
|
|
||
| --- | ||
|
|
||
| ## Usage examples | ||
|
|
||
| > Run scripts in a test environment first. | ||
|
|
||
| ### Run locally | ||
| ```powershell | ||
| PowerShell.exe -ExecutionPolicy Bypass -File ".\Disable_PrintSpoolerService.ps1" | ||
| ``` | ||
|
|
||
| ### Detection/remediation pattern (Intune Proactive Remediations) | ||
| - Detection script returns: | ||
| - `0` = compliant / no remediation | ||
| - non-zero (for example `1`) = remediation required | ||
| - `Detect - MultipleIntuneMDMCert.ps1` already follows this pattern. | ||
|
|
||
| ### Graph export script | ||
| `Get-IntuneAllAppsAssignmentDetails.ps1` exports to: | ||
| - `C:\Temp\Get-IntuneAllAppsAssignmentDetails.csv` | ||
|
|
||
| Update these placeholders before use: | ||
| - `<Your Entra Registered App ID here>` | ||
| - `<Your Tenant ID here>` | ||
| - `<Your Entra Registered App Client Secret here>` | ||
|
|
||
| --- | ||
|
|
||
| ## Notes and cautions | ||
|
|
||
| - **Review before production use:** Some scripts directly change local security/service state (for example Spooler or smart card policies). | ||
| - **Test assignment scope:** In Intune, always validate with a pilot device group first. | ||
| - **Credential handling:** The Graph script currently uses a client secret inline placeholder; prefer secure secret storage (for example, Key Vault, managed identity patterns, secure runtime injection) for production workflows. | ||
| - **Logging:** Smart card scripts log to: | ||
| - `C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\` | ||
|
|
||
| --- | ||
|
|
||
| ## Suggested Intune packaging patterns | ||
|
|
||
| - **Simple device scripts:** `Disable_PrintSpoolerService.ps1`, `Enable_PrintSpoolerService.ps1`, `Initiate-MDMSync.ps1` | ||
| - **Proactive remediations:** `Detect - MultipleIntuneMDMCert.ps1` (+ your remediation counterpart) | ||
| - **Win32 app deployment:** Smart card enforcement scripts with explicit install/uninstall mappings and detection logic using registry/log signals | ||
| - **Admin reporting utility (run by admin/operator):** `Get-IntuneAllAppsAssignmentDetails.ps1` | ||
|
|
||
| --- | ||
|
|
||
| ## Contributing | ||
|
|
||
| Contributions are welcome. If you add scripts, consider including: | ||
| - Clear purpose and expected context (System/User, Intune type) | ||
| - Input parameters and output behavior | ||
| - Exit code behavior (especially for detection scripts) | ||
| - Safety/rollback notes | ||
|
|
||
| --- | ||
|
|
||
| ## License | ||
|
|
||
| No license file is currently present in this repository. | ||
| If you plan to reuse or redistribute these scripts, add an explicit `LICENSE` file to define usage terms. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.