Skip to main content

Powershell

Table of Contents

PowerShell Automation Scripts
#

A collection of PowerShell scripts for automating various tasks across different products and vendors.

Overview
#

This repository contains PowerShell scripts designed to automate routine tasks for various software products and hardware vendors. Each script is organized by vendor/product category and may include detailed documentation for easy implementation.

Getting Started
#

Prerequisites
#

  • Windows PowerShell 5.1 or PowerShell Core 7.x
  • Vendor-specific modules for example VMware PowerCLI

Installation
#

  1. Clone the repository:

    git clone https://github.com/marcusfoelling/powershell-automation-scripts.git
    cd powershell-automation-scripts
    
  2. Set execution policy (if needed):

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
    
  3. Install required modules for example VMware PowerCLI

    Install-Module -Name VMware.PowerCLI
    

Script Documentation
#

The script may include:

  • Purpose: What the script does
  • Requirements: Prerequisites and dependencies
  • Parameters: Input parameters and their descriptions
  • Examples: Usage examples with sample output
  • Notes: Important considerations and limitations

Example Script Header:
#

<#
.SYNOPSIS
    Brief description of what the script does

.DESCRIPTION
    Detailed description of the script's functionality

.PARAMETER ParameterName
    Description of the parameter

.EXAMPLE
    PS> .\script-name.ps1 -Parameter "Value"
    Example of how to use the script

.NOTES
    Author: Your Name
    Version: 1.0
    Last Modified: Date
#>

Categories
#

Microsoft Products
#

  • Active Directory tasks
  • Microsoft System Center Operations Manager (SCOM) tasks
  • Windows Server configuration

VMware Products
#

  • vCenter automation and configuration
  • ESXi host management and configuration
  • Virtual machine operations and configuration

Network Equipment
#

  • tbd

Hardware Vendors
#

  • Dell server management
  • HP device automation

Generic Tools
#

  • System health monitoring
  • Troubleshooting
  • Reporting
  • tbd

Important Notes
#

  • Test First: Always test scripts in a development environment before production use
  • Credentials: Never hardcode credentials; use secure methods like credential objects
  • Logging: Some scripts includes appropriate logging functionality
  • Error Handling: Scripts may or may not include comprehensive error handling and rollback procedures

Contributing
#

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-script)
  3. Follow the established script format and documentation standards
  4. Test your script thoroughly
  5. Submit a pull request with detailed description

Contribution Guidelines
#

  • Use approved PowerShell verbs
  • Include comprehensive help documentation
  • Add error handling and logging
  • Test on multiple PowerShell versions where applicable

Support
#

  • Create an issue for bug reports or feature requests
  • Check existing issues before creating new ones
  • Provide detailed information including PowerShell version and error messages

Disclaimer: These scripts are provided as-is. Always review and test scripts before using them in production environments. The author is not responsible for any damage or data loss resulting from the use of these scripts.

2020

New-ScheduledSnapshot.ps1
This PowerShell script enables the creation of a scheduled snapshot for one or multiple VMware vCenter virtual machines (VMs). It automates the snapshot creation based on a defined schedule, which is especially useful for backup and maintenance purposes in virtualized environments.

2018

Get-VMDiskReport.ps1
This script creates a list (CSV file) of all virtual hard disks (VMDKs). This file can then be further processed or analyzed with tools like Excel.