Skip to content

A repository of useful PowerCLI scripts for your daily SysAdmin duties

License

Notifications You must be signed in to change notification settings

EarlyOwl/PowerCLI-SysAdmin-Repo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

PowerCLI-SysAdmin-Repo

A repository of useful PowerCLI scripts for your daily SysAdmin duties

Note! This repo is currrently W.I.P. - code will be added time to time

Contents

What is this?

This is a repository containing useful scripts to perform various tasks on your VMware infrastructure.

Prerequisites

The scripts in this repo were tested on an environment running:

Client-Side

  • PowerShell version 5.1
  • PowerCLI 13.0

Server-Side

  • VMware vCenter Server 7.0.3

You can check your PowerShell version by running $PSVersionTable.

If you don't have the PowerCLI modules installed, you can do so by running Install-Module -Name VMware.PowerCLI on an elevated PowerShell (documentation).

After the installation, i suggest to:

  1. Suppress the CEIP message by running Set-PowerCLIConfiguration -Scope AllUsers -ParticipateInCeip $false

  2. If you are dealing with self-signed certificates, add an exception to ignore them by default with Set-PowerCLIConfiguration -Scope AllUsers -InvalidCertificateAction Ignore

Installation

There are several ways to retrieve the scripts. For example, you can either:

  • Download the whole branch as a .ZIP archive by clicking Code > Download ZIP (or here)

  • Download a single script directly from the PowerShell. For example, to download the script Powerstate-Report.ps1 you can use the following snippet:

Invoke-WebRequest -URI https://raw.githubusercontent.com/EarlyOwl/PowerCLI-SysAdmin-Repo/main/scripts/Powerstate-Report.ps1 -Outfile Powerstate-Report.ps1 

REMEMBER: you should adjust the connection parameters in the scripts to fit your environment!

# Connect to vCenter server
Connect-VIServer -Server vcenter.domain.com -User yourusernamehere -Password yourpasswordhere

Usage

Each script comes with its own embedded documentation. For example, to check the docs for the script Powerstate-Report.ps1 you can do so by running:

 Get-Help .\Powerstate-Report.ps1 -full

Anyways, a brief description of every script can be found in the next chapter.

Script list

Quick navigation

Powerstate-Report.ps1

This script retrieves the power state, uptime and last boot time of all the VMs. It then outputs everything on a nicely formatted HTML table.

Sample output

Powerstate-Report.ps1

Datastores-Report.ps1

This script retrieves informations about the datastores in the datacenter, like name, available space, free space percentage, etc. It then outputs everything on a nicely formatted HTML table.

Sample output

Datastores-Report.ps1

Get-Portgroups.ps1

This script retrieves the list of the portgroups for each vDS. It then outputs everything on a nicely formatted HTML table.

Sample output

Get-Portgroups.ps1

Massive-Shutdown.ps1

This script shuts down every VM it finds in the vCenter, except the vCenter itself (the hostname of the vCenter MUST be specified inside the script). As this script doesn't produce any output file, there isn't a sample output tab below.

Vmwaretools-Report.ps1

This script enumerates all the VMs and verifies whether or not they have Vmware Tools installed (and if so, it checks the current version). It then outputs everything on a nicely formatted HTML table.

Sample output

Vmwaretools-Report.ps1

Misc

Can I contribute? Can I reuse all/part of this script for other purposes?

Yes and yes.

This sucks / You could have done X instead of X!

I'm eager to learn, open an issue or a pull request to suggest an improvement / fix.

About

A repository of useful PowerCLI scripts for your daily SysAdmin duties

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published