๐ ๏ธ PowerShell Administrative Scripts Collection
A comprehensive collection of PowerShell scripts for system administration, Microsoft Intune, Windows Updates, network diagnostics, user/group management, and remediation tasks in modern Windows enterprise environments.
๐ Latest Features & Highlights
๐ฅ๏ธ Cross-Platform Support - Scripts work on Windows with PowerShell 5.1+ and PowerShell Core 7+
๐ Comprehensive Intune Management - Complete suite for Intune management and troubleshooting
๐ฅ User & Group Comparison - Compare AD and Intune user group memberships
๐ฅ Advanced Remediation Scripts - For Intune, Office, Windows Update, Dell Management
๐ Duplicate Device Detection - Find and manage duplicate Entra ID devices
๐ง WMI Repair Toolkit - Local and remote WMI repository repair capabilities
๐ Remote Script Execution - Execute scripts on multiple servers simultaneously
# Clone repository
git clone https:// github.com / roalhelm/ PowershellScripts.git
cd PowershellScripts
# Repair Intune Management Extension
.\PSrepairIntuneManagementextention.ps1
# Fix Windows Update issues
.\REP_WindowsUpdate.ps1
# Compare user group memberships in AD
.\ADCompareUserGroups.ps1
# Compare Intune users
.\IntuneCompareUser\IntuneCompareUser.ps1
Requirement
Details
Usage
PowerShell
5.1 (Windows) or 7+ (Cross-Platform)
All scripts
Operating System
Windows 10/11, Server 2016+, macOS, Linux
Platform-specific features noted
Permissions
Administrator (Windows) / sudo (macOS/Linux)
System/Registry operations
Internet
Required
Cloud service tests, downloads
Required PowerShell Modules:
# Windows (PowerShell 5.1)
Install-Module PSWindowsUpdate, AzureAD, ActiveDirectory - Force - AllowClobber
# Cross-Platform (PowerShell 7+ on Windows, macOS, Linux)
Install-Module Microsoft.Graph - Force - AllowClobber
# For Graph API (Intune/Azure scripts)
Connect-MgGraph - Scopes " Device.Read.All" , " Group.ReadWrite.All"
๐ macOS / ๐ง Linux Specific Requirements:
# Install PowerShell 7+ on macOS
brew install --cask powershell
# Install PowerShell 7+ on Linux (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install -y powershell
# Launch PowerShell
pwsh
๐ฆ Complete Script Overview
Script
Description
Purpose
Admin Rights
DetectRuntime6.ps1
.NET Desktop Runtime 6 Detection
Intune Detection Script
โ
DriverUpdate.ps1
System driver updates via Windows Update
BitLocker-aware driver updates
โ
REP_WindowsUpdate.ps1
Windows Update component reset
Repair for update issues
โ
UnblockFiles.ps1
File unblocking (security zones)
Security zone removal
โ
๐ Microsoft Intune & MDM
๐ฅ User & Group Management
๐ Graph API & Remote Operations
๐ฅ Remediation Scripts (Intune/SCCM/GPO Ready)
๐ก๏ธ Microsoft Defender Management
๐ข Dell Hardware Management
๐ Microsoft Office Management
๐ฑ Intune Device Synchronization
๐ฆ Intune Win32 App Management
๐ Windows Update Repair (Multi-Stage Process)
๐ Troubleshooting & Diagnostics
๐ช Windows 11 24H2 Specialized Tools
๐ Documentation & Guides
๐จ HTML Report Features (CheckMicrosoftEndpointsV2.ps1)
๐ Professional Dashboard
๐ Statistical Cards - Tested endpoints, success/failure rate, performance metrics
๐ฏ Color-Coded Indicators - Instant visual assessment (Green/Yellow/Red)
๐ฑ Responsive Grid Layout - Perfect display on desktop, tablet, mobile
โฑ๏ธ Live Statistics - Test duration, timestamp, system information
๐ Detailed Service Analysis
๐ข Service Grouping - Clear organization by Microsoft services
โ
Status Badges - OK/FAILED with meaningful color coding
๐ Network Details - IP addresses for troubleshooting and firewall configuration
โก Performance Metrics - Latency (ms) and speed data with automatic assessment
๐จ Impact Analysis & Troubleshooting
โ ๏ธ Service Impact Warnings - What failures practically mean for business operations
๐ง Remediation Recommendations - Concrete action items for issues
๐ Performance Benchmarking - Automatic network quality assessment
๐ผ Practical Examples & Workflows
๐
Daily IT Administration
# Quickly diagnose and fix Intune issues
.\Remediations\RepairIntuneWin32Apps\detectIntuneWin32Apps.ps1
if ($LASTEXITCODE -ne 0 ) {
.\Remediations\RepairIntuneWin32Apps\remediateIntuneWin32Apps.ps1
}
# Systematically fix Windows Update issues
.\REP_WindowsUpdate.ps1
.\Remediations\RepairWinUpdate\detection.ps1
# Compare user groups
.\ADCompareUserGroups.ps1
# Find duplicate devices
.\Get-DuplicateEntraDevices.ps1
๐ Pre-Deployment Validation
# System readiness check
.\DetectRuntime6.ps1
.\DriverUpdate.ps1 - WhatIf
# Check Intune user assignments
.\IntuneCompareUser\IntuneCompareUser.ps1
๐ Compliance & Monitoring
# Automated remediation chain
.\Remediations\Intune- SyncDevice\Detection.ps1
.\Remediations\remediatOfficeUpdates\detectOfficeUpdates.ps1
.\Remediations\RepairWinUpdate\detection.ps1
# WMI health check
.\PSrepairWMI.ps1 - CheckOnly
๐ง Troubleshooting Workflows
# Comprehensive problem diagnosis
.\TroubleshootingGuide\Collect- Win11_24H2_Diagnostics.ps1
# Multi-stage Windows Update repair
.\Remediations\RepairWinUpdate\detectSTEP1.ps1
.\Remediations\RepairWinUpdate\remediationSTEP1.ps1
.\Remediations\RepairWinUpdate\detectSTEP2.ps1
.\Remediations\RepairWinUpdate\remediationSTEP2.ps1
๐ง Advanced Configuration & Best Practices
๐ Recommended Enterprise Directory Structure
C:\Scripts\PowershellScripts\
โโโ Core\
โ โโโ PSrepairIntuneManagementextention.ps1
โ โโโ REP_WindowsUpdate.ps1
โ โโโ PSrepairWMI.ps1
โโโ Reports\
โ โโโ Remediation\
โ โโโ Diagnostics\
โโโ Logs\
โ โโโ Remediation\
โ โโโ Diagnostics\
โโโ Config\
โ โโโ DeviceGroups.csv
โ โโโ UserGroups.csv
โโโ Automation\
โโโ ScheduledTasks\
โโโ RemediationScripts\
๐ Security & Permissions Matrix
Script Category
Windows Permission
Azure/Intune Permission
Network Access
Network Tests
Standard User
โ Not required
โ
HTTPS (443)
System Repair
๐ Administrator
โ Not required
โ ๏ธ Windows Update
Intune/Graph
Standard User
๐ Graph API Scopes
โ
Graph Endpoints
Registry Ops
๐ Administrator
โ Not required
โ Not required
WMI Repair
๐ Administrator
โ Not required
โ ๏ธ Remote WMI (if remote)
๐ Documentation & Support
๐ Script-Specific Help
# Detailed help for each script
Get-Help .\PSrepairIntuneManagementextention.ps1 - Full
Get-Help .\REP_WindowsUpdate.ps1 - Examples
Get-Help .\Remediations\RepairIntuneWin32Apps\remediateIntuneWin32Apps.ps1 - Parameter All
# View script documentation
Get-Help .\ADCompareUserGroups.ps1 - Detailed
Get-Help .\Get-DuplicateEntraDevices.ps1 - Examples
๐ Troubleshooting Resources
TroubleshootingGuide.md - Comprehensive problem-solving guide
Script Comments - Detailed inline documentation in each script
Error Handling - Detailed error messages with concrete solution suggestions
Exit Codes - Standardized return values for automation
# Example: Show all available scripts
Get-ChildItem - Path . - Filter " *.ps1" - Recurse | Select-Object Name, Length, LastWriteTime
# Example: Check script dependencies
$RequiredModules = @ (' PSWindowsUpdate' , ' Microsoft.Graph' , ' ActiveDirectory' )
$RequiredModules | ForEach-Object {
if (Get-Module - ListAvailable - Name $_ ) {
" โ
$_ available"
} else {
" โ $_ missing - Install-Module $_ -Force"
}
}
๐ Version History & Roadmap
๐ฎ Roadmap & Planned Features
๐ค Enhanced Remediation Automation - Intelligent troubleshooting workflows
๐ Integration APIs - REST API for SIEM/monitoring systems
๐ง Email Notifications - Automatic alert delivery
๐ Multi-Language Support - International localization
๐ Enhanced macOS/Linux Support - More cross-platform scripts
๐ Advanced Reporting - Enhanced diagnostic reports
๐ฅ๏ธ Cross-Platform Compatibility Guide
โ
Fully Compatible Scripts (Windows with PowerShell 5.1+)
Script
PowerShell 5.1+
PowerShell Core 7+
Notes
GraphApiOdataNextLink.ps1
โ
โ
Pure Graph API
IntuneCompareUser.ps1
โ
โ
Pure Graph API
Get-DuplicateEntraDevices.ps1
โ
โ
Pure Graph API
โ ๏ธ Windows-Only Scripts
Script
Reason
Alternative
PSrepairIntuneManagementextention.ps1
Windows-specific services
N/A
REP_WindowsUpdate.ps1
Windows Update components
N/A
PSrepairWMI.ps1
WMI (Windows-specific)
N/A
DriverUpdate.ps1
Windows drivers and BitLocker
N/A
๐ง Platform Detection Example
# How scripts detect platform and choose appropriate module
$isPwshCore = $PSVersionTable.PSEdition -eq ' Core'
if ($isPwshCore ) {
# PowerShell Core 7+ (Windows/macOS/Linux)
Import-Module Microsoft.Graph
Connect-MgGraph - Scopes " Device.Read.All" , " Group.ReadWrite.All"
} else {
# Windows PowerShell 5.1
Import-Module AzureAD
Connect-AzureAD
}
๐ ๏ธ Installation & Setup Guide
1๏ธโฃ Initial Repository Setup
# Step 1: Clone repository and setup
git clone https:// github.com / roalhelm/ PowershellScripts.git
cd PowershellScripts
# Step 2: Adjust execution policy (if required)
Set-ExecutionPolicy - ExecutionPolicy RemoteSigned - Scope CurrentUser - Force
# Step 3: Add directory to PATH (optional)
$currentPath = [Environment ]::GetEnvironmentVariable(" PATH" , " User" )
$scriptPath = (Get-Location ).Path
if ($currentPath -notlike " *$scriptPath *" ) {
[Environment ]::SetEnvironmentVariable(" PATH" , " $currentPath ;$scriptPath " , " User" )
}
2๏ธโฃ Dependencies & Prerequisites
# === Windows PowerShell 5.1 ===
$WindowsModules = @ (' PSWindowsUpdate' , ' AzureAD' , ' ActiveDirectory' )
$WindowsModules | ForEach-Object {
Install-Module $_ - Force - AllowClobber - Scope CurrentUser
Import-Module $_ - Force
}
# === PowerShell Core 7+ (Windows/macOS/Linux) ===
$CrossPlatformModules = @ (' Microsoft.Graph' )
$CrossPlatformModules | ForEach-Object {
Install-Module $_ - Force - AllowClobber - Scope CurrentUser
Import-Module $_ - Force
}
# Graph API authentication (for Intune/Azure scripts on all platforms)
Connect-MgGraph - Scopes @ (
" Device.Read.All" ,
" Group.ReadWrite.All" ,
" User.Read.All" ,
" Directory.AccessAsUser.All"
)
3๏ธโฃ First Run & Validation
# Step 1: Test remediation scripts (with caution!)
.\DetectRuntime6.ps1
.\Remediations\Intune- SyncDevice\Detection.ps1
# Step 2: Check user groups
.\ADCompareUserGroups.ps1
# Step 3: Find duplicate devices
.\Get-DuplicateEntraDevices.ps1
# Step 4: Test WMI health
.\PSrepairWMI.ps1 - CheckOnly
๐ Security, Compliance & Best Practices
๐ก๏ธ Enterprise Security Guidelines
Security Aspect
Recommendation
Implementation
Compliance
Execution Policy
RemoteSigned minimum
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
โ
Corporate Policy
Script Signing
Recommended for production
Use code signing certificate
โ
Enterprise Standard
Credential Management
Secure Store/Key Vault
$cred = Get-Credential instead of hardcoding
๐ Security Baseline
Audit Logging
All critical operations
Windows Event Log + Custom Logs
๐ Compliance Ready
Network Monitoring
Enable firewall logs
Monitor outbound connections
๐ Network Security
๐ Recommended Deployment Strategy
# 1. Test Environment Validation
$TestEnvironments = @ (" DEV" , " TEST" , " UAT" )
$TestEnvironments | ForEach-Object {
Write-Host " Testing in $_ environment..." - ForegroundColor Cyan
# Run remediation tests
.\Remediations\RepairWinUpdate\detection.ps1
}
# 2. Staged Rollout
$ProductionGroups = @ (" Pilot-Users" , " IT-Department" , " All-Users" )
# Implementation according to company policy
# 3. Monitoring & Feedback Loop
# Scheduled tasks for regular health checks
# Integration with existing monitoring (SCOM, PRTG, etc.)
๐ค Community & Contributing
๐ด Fork the repository on GitHub
๐ฟ Feature Branch create: git checkout -b feature/amazing-new-feature
๐พ Commit your changes: git commit -am 'Add amazing new feature'
๐ค Push to branch: git push origin feature/amazing-new-feature
๐ Pull Request create with detailed description
๐ Contribution Standards
๐ Code Style : PowerShell Best Practices and PSScriptAnalyzer compliance
๐ Documentation : Complete comment-based help for all functions
๐งช Testing : Validation in at least 2 different environments
๐ Backwards Compatibility : Compatibility with PowerShell 5.1+
๐ Security : No hardcoded credentials or unsafe practices
๐ Issue Reporting & Support
Use GitHub Issues for:
Issue Type
Label
Template
Response Time
๐ Bug Reports
bug
Bug Report Template
24-48h
๐ก Feature Requests
enhancement
Feature Request Template
1 week
๐ Documentation
documentation
Documentation Template
48h
โ Questions
question
Question Template
24h
๐จ Security Issues
security
Private Disclosure
Immediate
๐ Repository Statistics & Metrics
Category
Script Count
Lines of Code
Last Updated
Platform Support
System & Updates
4
800+
December 2025
Windows Only
Intune & MDM
2
400+
December 2025
Windows Only
User & Group Management
3
600+
December 2025
Windows โญ
Remediation Scripts
15+
1,000+
December 2025
Windows Only
Troubleshooting Tools
2
300+
December 2025
Windows Only
Graph API & Remote
3
500+
December 2025
Windows
Total
15+
3,600+
Actively maintained
Windows
๐ License & Legal Information
This project is licensed under the GNU General Public License v3.0
Key License Points:
โ
Commercial Use allowed
โ
Modification and Distribution allowed
โ
Patent Use protected
โ ๏ธ Source Code Disclosure required for distribution
โ ๏ธ Same License required for derivative works
๐จโ๐ป Author & Maintainer
Ronny Alhelm
๐ GitHub : @roalhelm
๐ง Contact : Via GitHub Issues (preferred)
๐ผ Professional : Enterprise PowerShell Solutions
๐ Acknowledgments & Credits
Microsoft Documentation Team - For comprehensive API documentation
PowerShell Community - For best practices and code reviews
Enterprise IT Feedback - For real-world requirements and use cases
Open Source Contributors - For testing, bug reports, and feature suggestions