# PowerShellScripting Documentation Site

A collection of PowerShell scripts for enterprise IT administration, covering Active Directory, Microsoft 365, Exchange Online, Entra ID, and Intune management tasks that i've created over the years.

License: GPL v3 PowerShell Gallery Platform

# Table of Contents

  • Table of Contents
    • Script Categories
    • Interactive Scripts
  • Usage
    • Basic Usage
  • Scripts available
    • Active Directory (ad)
    • Exchange / E365 (e365)
    • Entra ID / Azure AD (entra)
    • General utilities (general)
    • Intune (intune)
    • OneDrive / SharePoint (onedrive)
  • Configuration
    • Environment Variables
    • Authentication
    • Customisation
  • Testing
    • Validation
  • Logging and Troubleshooting
    • Logging Standards
    • Common Issues
    • Support Resources
  • Accessibility
  • Contributing
    • Development Guidelines
  • Changelog
    • Recent Updates
    • Version History
  • License
  • Like to say thank you?
  • Contact and Support
    • Project Maintainer
    • Getting Help
    • Support Guidelines

# Script Categories

Details of all scripts, and links to their documentation, can be found in the Scripts section below.

  • Active Directory: Scripts for user and computer management in on-premises AD environments
  • Exchange 365: Email and mailbox management for cloud and hybrid environments
  • Entra ID: Identity and access management for Azure AD/Entra ID
  • General: Utility scripts for common administrative tasks
  • Intune: Detection and remediation scripts to keep your house in order
  • Microsoft 365: Microsoft 365 Relevant scripts
  • Onedrive: Onedrive for Business and SharePoint bulk file upload/download scripts

# Interactive Scripts

Many scripts include GUI interfaces for ease of use:

  • User creation wizards with form-based input
  • Device selection interfaces
  • Progress indicators for long-running operations

# Usage

# Basic Usage

Each script is designed to be run independently. Navigate to the appropriate folder and execute the script:

# Example: Run user creation script
.\ad\user\creation\User-Creation.ps1

# Example: Run Intune bulk sync
.\intune\devices\Intune-BulkSync.ps1

# Scripts available

# Active Directory (ad)

Script Summary Documentation
ad/computer/FindMachineOU.ps1 Locates the organisational unit (OU) for a given computer in Active Directory. FindMachineOU
ad/user/creation/AD-CopyGroups.ps1 Copies group memberships from one AD user to another. AD-CopyGroups
ad/user/creation/User-Creation-Bulk.ps1 Bulk creation of AD users from a CSV file. User-Creation-Bulk
ad/user/creation/User-Creation.ps1 Creates a new AD user with a GUI interface. User-Creation
ad/user/creation/User-Departure.ps1 Processes the departure of an AD user, disabling and archiving the account. User-Departure
ad/user/reconcillation/Employee-Departure-Reconciliation.ps1 Reconciles all departed employees against AD from a HR provided file, and provides notifications where follow up actions are needed. Employee-Departure-Reconciliation
ad/user/reconcillation/Employee-Listing.ps1 Lists employees in AD for reporting or reconciliation. Employee-Listing

# Exchange / E365 (e365)

Script Summary Documentation
e365/E365-Mailbox-ConvertToShared.ps1 Converts a user mailbox to a shared mailbox in Exchange Online. E365-Mailbox-ConvertToShared
e365/E365-Quarantine-ExportRecord.ps1 Exports quarantine records from Exchange Online. E365-Quarantine-ExportRecord
e365/Exchange-QuarantineTABL-DataDownload.ps1 Downloads quarantine data from Exchange Online for analysis. Exchange-QuarantineTABL-DataDownload
e365/NewTransportRuleExecName.ps1 Creates or manages Exchange Online transport rules. NewTransportRuleExecName

# Entra ID / Azure AD (entra)

Script Summary Documentation
entra/AutomateCompromisedAccountRemediation.ps1 Automates remediation steps for compromised Entra ID (Azure AD) accounts. AutomateCompromisedAccountRemediation
entra/Entra-UserExternal-Create.ps1 Creates an external user in Entra ID (Azure AD). Entra-UserExternal-Create
entra/User-Management-External.ps1 Manages external users in Entra ID (Azure AD). User-Management-External

# General utilities (general)

Script Summary Documentation
general/ScriptSelector.ps1 Provides an interactive menu to select and launch other scripts. ScriptSelector
general/module-management/Module-PowerShell7-Require.ps1 Ensures required PowerShell 7 modules are installed and imported. Module-PowerShell7-Require
general/module-management/Update-Module.ps1 Updates specified PowerShell modules to the latest version. Update-Module
general/password-generation/Password-Generator-Silent.ps1 Generates a password silently for use in automation. Password-Generator-Silent
general/password-generation/Password-Generator.ps1 Generates a password with user interaction or options. Password-Generator

# Intune (intune)

Script Summary Documentation
intune/devices/Intune-BulkSync.ps1 Performs bulk synchronisation of devices in Microsoft Intune. Intune-BulkSync
M365-Version — DetectRemediate M365 Apps version detection and remediation. M365-Version
Teams-Old — DetectRemediate Legacy Teams detection and remediation. Teams-Old
WinUpdate-23H2to24H2Force — DetectRemediate Detect and remediate readiness for forced Windows update. WinUpdate-23H2to24H2Force
WinUpdate-Outstanding — DetectRemediate Windows Update detection and remediation. WinUpdate-Outstanding
WinUpdate-Pause — DetectRemediate Windows Update pause detection and remediation. WinUpdate-Pause
Win-Storage — DetectRemediate Detect and remediate low storage space on Windows devices. Win-Storage

# OneDrive / SharePoint (onedrive)

Script Summary Documentation
onedrive/onedrive-sharepont-uploaddownload.md Information on best way to bulk upload and download content from OneDrive OneDrive upload/download

# Configuration

# Environment Variables

Some scripts may require environment-specific configuration. Review each script's header for specific requirements.

# Authentication

  • Ensure you have appropriate administrative credentials
  • Some scripts require multi-factor authentication (MFA)
  • Consider using application passwords where applicable

# Customisation

Scripts include configurable parameters at the top of each file. Common customisations include:

  • Domain names and organisational units
  • Email domains and Exchange settings
  • Logging paths and retention policies
  • Timeout values and retry attempts

# Testing

# Validation

Before using scripts in production:

  1. Review the script header for version information and changelog
  2. Test in a non-production environment
  3. Verify all required modules are installed
  4. Check logging output for any warnings or errors

# Logging and Troubleshooting

# Logging Standards

All scripts are intended to follow consistent logging practices, which include:

  • Log files stored in $env:TEMP with timestamps where appropriate
  • Comprehensive error logging with context
  • Success and failure reporting
  • Progress indicators for long-running operations

Script documentation will provide examples of what logging is provided, and samples of logging output.

# Common Issues

  • Module Import Errors: Ensure required PowerShell modules are installed
  • Authentication Failures: Verify credentials and MFA settings
  • Permission Errors: Check administrative rights for target systems
  • Network Connectivity: Ensure access to required cloud services

# Support Resources

  • Check script headers for specific documentation links
  • Review Microsoft documentation for API changes
  • Consult PowerShell Gallery for module updates

# Accessibility

This project is committed to accessibility and inclusive design:

  • Scripts include progress indicators and clear status messages
  • Documentation uses descriptive text for all functionality
  • Error messages provide actionable guidance
  • GUI interfaces follow accessibility best practices
  • All documentation supports screen readers

# Contributing

Contributions to improve and expand this script collection are welcome. Please read the contribution guidelines:

  1. Code Standards: Follow PowerShell best practices and existing code style
  2. Documentation: Include comprehensive headers and inline comments
  3. Testing: Validate scripts in appropriate test environments
  4. Security: Ensure no hardcoded credentials or sensitive information

# Development Guidelines

  • Use Australian English (EN-AU) for documentation and comments
  • Include proper error handling and logging
  • Follow the established folder structure
  • Update this README when adding new functionality

# Changelog

# Recent Updates

Changelog for each script will be provided on its documentation page where relevant.

  • Integrated CleanMgr registry preparation for selected VolumeCaches and invoked CleanMgr (/sagerun:1).
  • Configured and triggered Storage Sense to remove temporary files and locally cached OneDrive content.
  • Added DISM component store cleanup (StartComponentCleanup) with explicit exit-code logging.
  • Added removal of user-specific temporary files (%USERPROFILE%\AppData\Local\Temp).
  • Enhanced event log cleanup:
    • Improved error handling for individual logs to ensure the script continues processing other logs.
  • Added removal of old user profiles from C:\Users based on retention days ($userProfileRetentionDays).
  • Centralised logging with Start-Transcript and Custom-WriteLog; log file located at $env:TEMP<scriptName>.log.
  • Improved error handling so individual step failures are logged as warnings and the script continues.
  • Exposed configuration variables for operational tuning:
    • $logsToClear: List of event logs to process.
  • Added initialisation of $freeSpaceGB to capture baseline free space before cleanup, ensuring accurate space-recovered reporting.
  • Validated archive directory existence before appending or moving logs.
  • Appended new logs to existing archive files or created new archive files as needed.
  • Executed Disk Cleanup silently using the /VERYLOWDISK argument.
  • Documented exit codes:
    • 0 = Success
    • 1 = General failure (useful for external monitoring; individual step failures do not necessarily change the final exit code unless a fatal condition is detected).

# Version History

See individual script headers for detailed version history and changelog information.

# License

This project is licensed under the GNU General Public License v3.0 — see the LICENSE file for full terms and conditions.

Copyright (c) 2025, Michael Harris, All rights reserved.

# Like to say thank you?

If these scripts have helped you in your IT administration tasks, consider:

  • Starring this repository
  • 🐛 Reporting issues or suggesting improvements
  • 📖 Contributing to the documentation
  • Buy me a coffee to support continued development

# Contact and Support

# Project Maintainer

# Getting Help

  • Issues: Report bugs or request features via GitHub Issues
  • Discussions: Join the conversation in GitHub Discussions
  • Documentation: Review script headers and Microsoft documentation links

# Support Guidelines

  • Provide clear descriptions of issues with relevant log files
  • Include PowerShell version and module information
  • Specify the target environment (on-premises, cloud, hybrid)
  • Follow the issue templates when reporting problems

This project makes reasonable efforts to follow Microsoft PowerShell best practices and maintains compatibility with enterprise IT environments.