Skip to content

Latest commit

ย 

History

History
544 lines (428 loc) ยท 22 KB

File metadata and controls

544 lines (428 loc) ยท 22 KB

๐Ÿ› ๏ธ PowerShell Administrative Scripts Collection

PowerShell License Last Update Scripts Cross-Platform

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

๐Ÿš€ Quick Start

# 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

๐Ÿ“‹ System Requirements

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

๐Ÿ”ง System & Updates

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

Script Category Description Use Case
PSrepairIntuneManagementextention.ps1 Repair Intune Management Extension repair Win32 app issues
ReinstallCompanyPortal.ps1 Reinstall Company Portal via WinGet Portal reinstallation

๐Ÿ‘ฅ User & Group Management

Script Purpose Features Data Source
ADCompareUserGroups.ps1 Compare AD group memberships Side-by-side comparison Active Directory
IntuneCompareUser/IntuneCompareUser.ps1 Entra ID user comparison Multi-user analysis Microsoft Graph
Get-DuplicateEntraDevices.ps1 Find duplicate Entra ID devices Duplicate detection Microsoft Graph

๐Ÿ”„ Graph API & Remote Operations

Script API/Service Function Pagination
GraphApiOdataNextLink.ps1 Microsoft Graph Paging for large datasets (>1000 objects) โœ…
ExecuteRemoteScript.ps1 PSRemoting Multi-server script execution โŒ
PSrepairWMI.ps1 WMI Local/Remote WMI repository repair โœ…

๐Ÿฅ Remediation Scripts (Intune/SCCM/GPO Ready)

๐Ÿ›ก๏ธ Microsoft Defender Management

Detection Remediation Purpose Exit Codes
detectDefenderSignatur.txt โŒ Manual Check signature currency 0/1

๐Ÿข Dell Hardware Management

Detection Remediation Purpose Impact
detectDellCommandUpdate.ps1 remediatDellCommandUpdate.ps1 Remove Dell Command Update Reduces bloatware

๐Ÿ“‹ Microsoft Office Management

Detection Remediation Purpose Update Method
detectOfficeUpdates.ps1 remediatOfficeUpdates.ps1 Install Office updates Click-to-Run

๐Ÿ“ฑ Intune Device Synchronization

Detection Remediation Purpose Frequency
Detection.ps1 Remediation.ps1 Force Intune sync As needed

๐Ÿ“ฆ Intune Win32 App Management

Script Purpose Features Registry Impact
CheckLastSync.ps1 Sync trigger for all devices Bulk operations โŒ
detectIntuneWin32Apps.ps1 Win32 app error detection Registry analysis โŒ
remediateIntuneWin32Apps.ps1 Win32 app repair IME restart, registry cleanup โœ…

๐Ÿ”„ Windows Update Repair (Multi-Stage Process)

Stage Detection Remediation Purpose Severity
1 detectSTEP1.ps1 remediationSTEP1.ps1 Windows Update service reset ๐ŸŸก Medium
2 detectSTEP2.ps1 remediationSTEP2.ps1 SoftwareDistribution reset ๐ŸŸ  High
3 detectSTEP3.ps1 remediationSTEP3.ps1 Component Store repair ๐Ÿ”ด Critical
All detection.ps1 โŒ Manual Overall status check ๐Ÿ” Info

๐Ÿ” Troubleshooting & Diagnostics

๐ŸชŸ Windows 11 24H2 Specialized Tools

Script Purpose Collects Output Format
Collect-Win11_24H2_Diagnostics.ps1 Windows 11 24H2 specific diagnostics System logs, hardware info, configs ZIP Archive

๐Ÿ“– Documentation & Guides

File Content Target Audience
TroubleshootingGuide.md Comprehensive troubleshooting guide IT Professionals

๐ŸŽจ 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

๐ŸŽ“ Learning Resources

# 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

๐ŸŒŸ How to Contribute

  1. ๐Ÿด Fork the repository on GitHub
  2. ๐ŸŒฟ Feature Branch create: git checkout -b feature/amazing-new-feature
  3. ๐Ÿ’พ Commit your changes: git commit -am 'Add amazing new feature'
  4. ๐Ÿ“ค Push to branch: git push origin feature/amazing-new-feature
  5. ๐Ÿ”„ 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

Language Distribution Documentation Maintenance Enterprise Ready

๐Ÿ“ˆ Script 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

๐Ÿ“œ Open Source License

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

๐ŸŽฏ Ready for Enterprise Deployment

PowerShell Gallery Enterprise Ready Security Tested Documentation

๐Ÿ’ผ Professional | ๐Ÿš€ Continuously Updated | ๐Ÿ›ก๏ธ Security Focused | ๐Ÿข Enterprise Grade


This script collection is actively used in enterprise environments and continuously developed.