Skip to content

J-MaFf/PowerShellScripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

76 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PowerShell Scripts Collection

A comprehensive collection of PowerShell scripts for system administration, Active Directory management, user configuration, and network operations.

πŸ“‹ Table of Contents

πŸ” Overview

This repository contains a variety of PowerShell scripts designed for enterprise system administration tasks, including:

  • Date Format Management: Tools for managing and standardizing date formats across user profiles
  • Active Directory Operations: Scripts for user and computer management in AD environments
  • Network Administration: Network scanning, ping utilities, and IP configuration tools
  • Printer Management: Automated network printer setup and configuration
  • System Maintenance: Computer management, RDP fixes, and system diagnostics
  • Problem Steps Recorder Tools: PSR configuration and automation for support workflows
  • Web Reporting: HTML report generation and styling tools
  • Disaster Recovery: DR testing and verification scripts

πŸ“ Repository Structure

PowerShellScripts/
β”œβ”€β”€ Scripts/                       # All executable scripts organized by topic
β”‚   β”œβ”€β”€ ActiveDirectory/           # Active Directory management scripts
β”‚   β”‚   β”œβ”€β”€ Get-UserComputer.ps1           # Find last logon workstation
β”‚   β”‚   β”œβ”€β”€ Get-ComputerLastOnline.ps1     # Get computer last online status
β”‚   β”‚   β”œβ”€β”€ Add-UsersInOuToGroup.ps1       # Bulk group membership management
β”‚   β”‚   β”œβ”€β”€ Disable-AndMoveComputers.ps1   # Computer object cleanup
β”‚   β”‚   └── Set-ScheduledTaskAccount.ps1    # Scheduled task migration
β”‚   β”œβ”€β”€ DateFormat/                # Date format management scripts
β”‚   β”‚   β”œβ”€β”€ Get-UserDateFormats.ps1        # Retrieve date formats from remote servers
β”‚   β”‚   └── Set-UserDateFormats.ps1        # Set standardized date formats
β”‚   β”œβ”€β”€ RegionFormat/              # Region format management scripts
β”‚   β”‚   β”œβ”€β”€ Get-UserRegionFormats.ps1      # Retrieve region formats from remote servers
β”‚   β”‚   └── Set-UserRegionFormats.ps1      # Set standardized region formats
β”‚   β”œβ”€β”€ Network/                   # Network and connectivity tools
β”‚   β”‚   β”œβ”€β”€ Scan-Network.ps1               # Network discovery and analysis
β”‚   β”‚   β”œβ”€β”€ Ping-WithChime.ps1             # Enhanced ping with audio
β”‚   β”‚   β”œβ”€β”€ Get-ComputersViaIP.ps1         # Computer discovery via IP
β”‚   β”‚   β”œβ”€β”€ Reset-IPConfig.ps1             # Network configuration reset
β”‚   β”‚   β”œβ”€β”€ Fix-RDP.ps1                    # RDP troubleshooting
β”‚   β”‚   └── Test-MacAddress.ps1            # MAC address testing
β”‚   β”œβ”€β”€ Printers/                  # Printer management (consolidated)
β”‚   β”‚   β”œβ”€β”€ addNetworkPrinters.ps1         # Automated printer installation
β”‚   β”‚   β”œβ”€β”€ Diagnose-PrintError.ps1        # Print spooler diagnostics
β”‚   β”‚   └── Repair-PrintSpooler.ps1        # Print spooler repair
β”‚   β”œβ”€β”€ ProblemStepsRecorder/      # PSR automation tools
β”‚   β”‚   β”œβ”€β”€ Set-PSRLocation.ps1            # Configure PSR output location
β”‚   β”‚   └── Start-PSR.ps1                  # Launch PSR with custom settings
β”‚   β”œβ”€β”€ Reporting/                 # HTML and web reporting tools
β”‚   β”‚   β”œβ”€β”€ Test-PSWriteHTML.ps1           # HTML table generation
β”‚   β”‚   β”œβ”€β”€ table-style.css                # CSS styling for reports
β”‚   β”‚   └── wdw-snippet.html               # HTML template file
β”‚   └── WindowsUpdate/             # Windows Update management
β”‚       └── Uninstall-WindowsUpdate.ps1    # Remove Windows updates
β”‚
β”œβ”€β”€ Modules/                       # PowerShell modules
β”‚   β”œβ”€β”€ ActiveDirectoryUtils/      # Shared Active Directory helper functions
β”‚   β”œβ”€β”€ RegistryUtils/             # Shared registry helpers (DateFormat & RegionFormat)
β”‚   └── PersonalUtils/             # Copilot and terminal helpers
β”‚
β”œβ”€β”€ Tests/                         # Pester test files
β”‚   β”œβ”€β”€ ActiveDirectory/           # AD script tests
β”‚   β”œβ”€β”€ DateFormat/                # Date format script tests
β”‚   β”œβ”€β”€ RegionFormat/              # Region format script tests
β”‚   └── WindowsUpdate/             # Windows Update script tests
β”‚
β”œβ”€β”€ Data/                          # Input files and documentation
β”‚   β”œβ”€β”€ InputFiles/                # Configuration files and user lists
β”‚   └── Documentation/             # Reference documentation and guides
β”‚
└── Output/                        # Script execution outputs
    β”œβ”€β”€ DateFormats/               # Date format script results
    β”œβ”€β”€ RegionFormats/             # Region format script results
    β”œβ”€β”€ EndpointCentral/           # Endpoint Central outputs
    β”œβ”€β”€ DisasterRecovery/          # DR test results
    └── Reports/                   # General reports and logs

✨ Key Features

πŸ—“οΈ Date Format Management

  • Centralized Control: Manage date formats across multiple servers and user profiles
  • Bulk Operations: Process hundreds of users simultaneously
  • CSV Export: Comprehensive reporting with CSV output
  • Remote Execution: PowerShell remoting support for enterprise environments

🌍 Region Format Management

  • Localization Support: Manage Windows Settings region format (LocaleName) across servers
  • Culture Code Support: Apply any valid culture code (en-US, nl-NL, de-DE, etc.)
  • Bulk Operations: Process hundreds of users simultaneously
  • CSV Export: Track old and new region formats with timestamped reports
  • Remote Execution: PowerShell remoting with 1Password credential integration

πŸ‘₯ Active Directory Integration

  • User Information Retrieval: Get-UserInfo surfaces display name, password status, and last logon data straight from the module
  • Reusable Module Helpers: Import ActiveDirectoryUtils for functions like Get-UserInfo and Get-UserComputer
  • Self-Healing RSAT Support: Automatic RSAT installation attempts when the Active Directory module is missing; graceful "limited mode" warnings when installation isn't possible
  • Group Management: Add/remove users from AD groups with organizational unit filtering
  • Computer Management: Disable and move computer objects efficiently

🌐 Network Tools

  • Network Scanning: Comprehensive network discovery and analysis
  • IP Management: IP configuration reset and troubleshooting tools
  • Connectivity Testing: Enhanced ping utilities with audio notifications

πŸ–¨οΈ Printer Management

  • Automated Setup: Batch network printer installation
  • User-Specific Configuration: Per-user printer deployment tracking
  • Error Handling: Comprehensive logging and error reporting

πŸ”§ Prerequisites

  • PowerShell 7+ (Preferred) or Windows PowerShell 5.1 for legacy compatibility
  • Active Directory Module (for AD-related scripts)
  • Administrative Privileges (for most system-level operations)
  • PowerShell Remoting enabled (for remote server operations)

Required Modules

# Install required modules (ActiveDirectoryUtils will attempt RSAT install automatically)
Import-Module .\Modules\RegistryUtils\RegistryUtils.psd1
Import-Module .\Modules\ActiveDirectoryUtils\ActiveDirectoryUtils.psd1
```> **Heads up:** Importing `Modules\ActiveDirectoryUtils` validates that the RSAT Active Directory tools are present. If you're elevated it will install them for you; otherwise the module logs a warning and continues in a read-only limited mode.

## πŸ“¦ Installation

1. **Clone the repository:**

```powershell
git clone https://github.com/J-MaFf/PowerShellScripts.git
cd PowerShellScripts
  1. Import the custom modules:

    Import-Module .\Modules\RegistryUtils\RegistryUtils.psd1
    Import-Module .\Modules\ActiveDirectoryUtils\ActiveDirectoryUtils.psd1
  2. Set execution policy (if needed):

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

πŸ“‚ Script Categories

Date Format Scripts

Script Description
Scripts/DateFormat/Get-UserDateFormats.ps1 Retrieves date format information from remote servers
Scripts/DateFormat/Set-UserDateFormats.ps1 Sets standardized date formats across user profiles

Region Format Scripts

Script Description
Scripts/RegionFormat/Get-UserRegionFormats.ps1 Retrieves region format (LocaleName) from remote servers
Scripts/RegionFormat/Set-UserRegionFormats.ps1 Sets standardized region formats across user profiles

New in Latest Release:

  • Optional -Credential parameter for secure credential passing without prompts
  • Enhanced 1Password support for both KFI and KGS domains
  • 72 comprehensive Pester tests (100% pass rate)
  • Improved error handling with clear status messaging

Active Directory Management

Script Description
Modules/ActiveDirectoryUtils Shared module exporting 8 functions: Get-UserInfo, Get-UserComputer, Get-ComputerLastLogon, Test-Admin-Privileges, and others
Scripts/ActiveDirectory/Get-UserComputer.ps1 Wrapper that prompts for elevation, accepts credentials, and calls Get-UserComputer
Scripts/ActiveDirectory/Get-ComputerLastOnline.ps1 Get computer last online status from Active Directory
Scripts/ActiveDirectory/Add-UsersInOuToGroup.ps1 Bulk group membership management
Scripts/ActiveDirectory/Disable-AndMoveComputers.ps1 Computer object management and cleanup
Scripts/ActiveDirectory/Set-ScheduledTaskAccount.ps1 Migrate scheduled tasks between accounts

Network & System Tools

Script Description
Scripts/Network/Scan-Network.ps1 Network discovery and port scanning
Scripts/Network/Ping-WithChime.ps1 Enhanced ping with audio notifications
Scripts/Network/Get-ComputersViaIP.ps1 Computer discovery via IP ranges
Scripts/Network/Reset-IPConfig.ps1 Network configuration reset utility
Scripts/Network/Fix-RDP.ps1 Remote Desktop Protocol troubleshooting
Scripts/Network/Test-MacAddress.ps1 MAC address testing and validation

Problem Steps Recorder (PSR) Tools

Script Description
Scripts/ProblemStepsRecorder/Set-PSRLocation.ps1 Configures PSR to save recordings to network location
Scripts/ProblemStepsRecorder/Start-PSR.ps1 Launches PSR with preconfigured settings and timestamped output

Reporting & Web Tools

Script Description
Scripts/Reporting/Test-PSWriteHTML.ps1 Creates HTML tables with PSWriteHTML module
Scripts/Reporting/table-style.css CSS styling for HTML table outputs
Scripts/Reporting/wdw-snippet.html HTML template/snippet file

Printer Management

Script Description
Scripts/Printers/addNetworkPrinters.ps1 Automated network printer installation
Scripts/Printers/User.bat User-level printer setup batch file
Scripts/Printers/Diagnose-PrintError.ps1 Comprehensive Print Spooler diagnostics and troubleshooting
Scripts/Printers/Repair-PrintSpooler.ps1 Print Spooler repair and recovery automation

Windows Update Management

Script Description
Scripts/WindowsUpdate/Uninstall-WindowsUpdate.ps1 Remove specific Windows updates with safety checks

🧩 Modules

ActiveDirectoryUtils

  • Exports 8 AD utility functions including Get-UserInfo, Get-UserComputer, Get-ComputerLastLogon, Test-Admin-Privileges, and others
  • Attempts to install RSAT AD DS tools automatically during import when they're missing
  • Emits ⚠️ limited-mode warnings instead of throwing when AD cmdlets are unavailable
  • Shared helpers power the Scripts/ActiveDirectory/ script wrappers and the associated Pester tests (Tests/ActiveDirectory/*.Tests.ps1)

UserDateFormatUtils

  • Centralizes remoting helpers, credential cascades via 1Password CLI, and CSV export logic
  • Required by scripts under Scripts/DateFormat/β€”imported automatically by those entry points
  • Keeps timestamped exports under Output/DateFormats/ for easy auditing

RegistryUtils

  • Shared module for registry-based Windows Settings management (renamed from UserDateFormatUtils)
  • Exports functions for both DateFormat and RegionFormat operations
  • Includes Get-UserRegionFormat() and Set-UserRegionFormat() for region format management
  • Includes Get-UserSystemShortDateFormat() and Set-RemoteUserDateFormat() for date format management
  • Centralizes remoting helpers, credential cascades via 1Password CLI, and CSV export logic
  • Required by scripts under Scripts/DateFormat/ and Scripts/RegionFormat/
  • Keeps timestamped exports under Output/DateFormats/ and Output/RegionFormats/ for easy auditing

πŸš€ Usage Examples

Date Format Management

# Get date formats from default server (10.210.3.23)
$creds = Get-Credential -UserName 'KFI\admin-jmaffiola'
.\Scripts\DateFormat\Get-UserDateFormats.ps1 -Credential $creds

# Target specific users with pre-stored credentials
.\Scripts\DateFormat\Get-UserDateFormats.ps1 -TargetUsers @('bbenson', 'bbenson.kfi') -Credential $creds -OutputPath "C:\Reports\DateFormats.csv"

# Use a user list file
.\Scripts\DateFormat\Get-UserDateFormats.ps1 -UserListFile "C:\lists\users.txt" -Credential $creds

# Set date format to Month/Day/Year (M/d/yyyy)
.\Scripts\DateFormat\Set-UserDateFormats.ps1 -TargetUsers @('user1', 'user2') -DateFormat 'M/d/yyyy' -Credential $creds

# Set date format from file without credential prompts
.\Scripts\DateFormat\Set-UserDateFormats.ps1 -UserListFile "users.csv" -DateFormat 'yyyy-MM-dd' -Credential $creds

Features:

  • Optional Credential parameter eliminates interactive prompts
  • Pre-store credentials: $creds = Get-Credential then reuse in scripts
  • Automatic 1Password fallback (if OP_KFI or OP_KGS environment variables configured)
  • CSV export with timestamped filenames

Region Format Management

# Get region formats from default server (10.210.3.23)
$creds = Get-Credential -UserName 'KFI\admin-jmaffiola'
.\Scripts\RegionFormat\Get-UserRegionFormats.ps1 -Credential $creds

# Get region formats for specific users
.\Scripts\RegionFormat\Get-UserRegionFormats.ps1 -TargetUsers @('user1', 'user2') -Credential $creds

# Get region formats from a user list file
.\Scripts\RegionFormat\Get-UserRegionFormats.ps1 -UserListFile "C:\lists\users.txt" -Credential $creds

# Set region format to English (United States) - fixes Crystal Reports Dutch text issue
.\Scripts\RegionFormat\Set-UserRegionFormats.ps1 -RegionFormat 'en-US' -Credential $creds

# Set region format for specific users only
.\Scripts\RegionFormat\Set-UserRegionFormats.ps1 -TargetUsers @('user1', 'user2') -RegionFormat 'en-US' -Credential $creds

# Set region format from file with custom region
.\Scripts\RegionFormat\Set-UserRegionFormats.ps1 -UserListFile "users.csv" -RegionFormat 'de-DE' -Credential $creds

Supported Region Formats:

  • en-US - English (United States)
  • nl-NL - Dutch (Netherlands)
  • de-DE - German (Germany)
  • fr-FR - French (France)
  • es-ES - Spanish (Spain)
  • And many other valid Windows culture codes

Features:

  • Validates culture code before applying changes
  • Tracks old and new region formats in CSV reports
  • Optional Credential parameter eliminates interactive prompts
  • Automatic 1Password credential fallback
  • CSV export with timestamped filenames

Active Directory Operations

# Get user information
Get-UserInfo -username "jsmith"

# Module-based password expiry lookup (supports arrays and pipeline input)
Get-UserInfo -Username "jsmith"
'adoe','bwhite' | Get-UserInfo

# Find the last logon computer (prompts to elevate if needed)
.\Scripts\ActiveDirectory\Get-UserComputer.ps1 -UserName "jsmith" -ReturnAllEvents

# Provide delegated credentials when the current session isn't elevated
.\Scripts\ActiveDirectory\Get-UserComputer.ps1 -UserName "jsmith" -Credential (Get-Credential)

When run without administrative rights, Get-UserComputer.ps1 now offers to relaunch itself elevated while preserving the arguments you supplied. Supplying the optional -Credential parameter allows the script to query domain controller Security logs without prompting for elevation.

Get-UserInfo formats its results into a table for interactive readability. Add -Verbose to trace domain policy lookups, and copy the function from the module if you need to emit raw objects instead of formatted output.

Network Scanning

# Scan network with progress indicators
.\Scripts\Network\Scan-Network.ps1

# Enhanced ping with sound notifications
.\Scripts\Network\Ping-WithChime.ps1 -Target "192.168.1.1"

Printer Setup

# Add network printers from configuration file
.\Scripts\Printers\addNetworkPrinters.ps1

Problem Steps Recorder

# Configure PSR to save to network location
.\Scripts\ProblemStepsRecorder\Set-PSRLocation.ps1

# Start PSR with custom settings
.\Scripts\ProblemStepsRecorder\Start-PSR.ps1 -OutputPath "C:\Support\Recordings" -Prefix "Issue_" -Screenshots 25

Web Reporting

# Generate HTML table report
.\Scripts\Reporting\Test-PSWriteHTML.ps1 -OutputPath "C:\Reports\SystemReport.html"

πŸ“Š Output and Logging

Most scripts generate detailed output files in the Output/ directory:

  • CSV Reports: Structured data exports for analysis (in Output/DateFormats/ and Output/Reports/)
  • Transcript Logs: Complete execution logs with timestamps
  • Error Reports: Detailed error tracking and troubleshooting information
  • Progress Tracking: Real-time operation status updates

Outputs are organized by category:

  • Output/DateFormats/ - Date format management results
  • Output/RegionFormats/ - Region format management results
  • Output/EndpointCentral/ - Endpoint Central group operations
  • Output/DisasterRecovery/ - DR verification results
  • Output/Reports/ - General reports and logs

πŸ§ͺ Testing

This repository includes comprehensive Pester test suites:

# Run all tests
Invoke-Pester -Script 'Tests/' -Output Normal

# Run specific test suite
Invoke-Pester -Script 'Tests/DateFormat/' -Output Normal
Invoke-Pester -Script 'Tests/RegionFormat/' -Output Normal
Invoke-Pester -Script 'Tests/ActiveDirectory/' -Output Normal

# Test specific file
Invoke-Pester -Script 'Tests/DateFormat/Get-UserDateFormats.Tests.ps1' -Output Detailed
Invoke-Pester -Script 'Tests/RegionFormat/Set-UserRegionFormats.Tests.ps1' -Output Detailed

Current Test Coverage:

  • DateFormat Scripts: 72 tests (100% passing)
  • RegionFormat Scripts: 49 tests (100% passing)
  • ActiveDirectory Scripts: Comprehensive AD module tests
  • Includes parameter validation, error handling, output formatting, and module dependency tests

πŸ›‘οΈ Security Considerations

  • Scripts require appropriate permissions for their respective operations
  • Credential handling follows PowerShell best practices
  • Remote execution uses secure PowerShell remoting protocols
  • Administrative privileges are verified before system-level operations

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch
  3. Follow PowerShell best practices
  4. Include comprehensive help documentation
  5. Test scripts thoroughly
  6. Submit a pull request

Coding Standards

  • Use approved PowerShell verbs
  • Include comprehensive comment-based help
  • Implement proper error handling
  • Follow consistent naming conventions
  • Include parameter validation

πŸ“ Author

Joey Maffiola

  • System Administrator & PowerShell Developer
  • Focus on enterprise automation and infrastructure management

πŸ“„ License

This project is available for educational and professional use. Please review individual script headers for specific usage guidelines.


πŸ”§ Quick Start Checklist

  • Install required PowerShell modules
  • Set appropriate execution policy
  • Configure PowerShell remoting (if using remote scripts)
  • Verify Active Directory module availability
  • Test with non-production environment first
  • Review script parameters and documentation

πŸ“ž Support

For questions or issues:

  1. Check the script's comment-based help: Get-Help .\ScriptName.ps1 -Full
  2. Review the generated log files in Script output/
  3. Verify prerequisites and permissions
  4. Create an issue in this repository for bugs or feature requests

Last updated: November 21, 2025

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages