Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick Terlisten PatrickTerlisten

View GitHub Profile
View powershell_snippets.ps1
###
# VMware PowerCLI
###
# Create a new entry in the credential store
New-VICredentialStoreItem -Host vcenter.domain.tld -User Username -Password Passw0rd
# Connect to vCenter server (credential store item exist for this vCenter server)
@PatrickTerlisten
PatrickTerlisten / disable_dhcp_inform.vbs
Created Apr 17, 2016
Disable DHCPINFORM on Windows 2000, 2003, XP, Vista, 7
View disable_dhcp_inform.vbs
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT Name,DeviceID FROM Win32_NetworkAdapter WHERE NetConnectionStatus=2", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
strName = objItem.Name
Set colNicConfigs = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_NetworkAdapter.DeviceID='" & objItem.DeviceID & "'} WHERE AssocClass=Win32_NetworkAdapterSetting")
@PatrickTerlisten
PatrickTerlisten / Get-CpuRatio
Last active May 8, 2018
This script outputs the pCPU/ vCPU ratio for each ESXi host.
View Get-CpuRatio
#requires -Version 1
#requires -PSSnapin VMware.VimAutomation.Core
function Get-CpuRatio {
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
@PatrickTerlisten
PatrickTerlisten / Shutdown-vSphereCluster.ps1
Created Dec 1, 2015
A script to shutdown a vSphere Cluster.
View Shutdown-vSphereCluster.ps1
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
This script will shut down all VMs, the ESXi hosts that were running the VMs, the vCenter VM
and, at the end, the ESXi host that was running the vCener VM.
Please modify all necessary variables. Make sure that you read the comments!
@PatrickTerlisten
PatrickTerlisten / Create-DataCoreSSVBackup.ps1
Last active Dec 1, 2015
This script creates a backup of the DataCore SANsymphony-V configuration.
View Create-DataCoreSSVBackup.ps1
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
This script creates a backup of the DataCore SANsymphony-V configuration.
.EXAMPLE
Create-DataCoreSSVBackup
@PatrickTerlisten
PatrickTerlisten / Reclaim-ThinVMDK.ps1
Last active Feb 21, 2018
This script uses sdelete to zero-out all disks of a Windows VM. Afterwards, the VM is moved between datastores to reclaim zeroed space.
View Reclaim-ThinVMDK.ps1
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
This script uses sdelete to zero-out all disks of a Windows VM. Afterwards, the VM
is moved between datastores to reclaim zeroed space.
History
v1.3: Redesign.
@PatrickTerlisten
PatrickTerlisten / Get-VMWorkingDirMismatch.ps1
Last active Dec 5, 2015
This script outputs a list of all VMs where VM inventory name and working directory name doesn't match.
View Get-VMWorkingDirMismatch.ps1
#requires -Version 1
#requires -PSSnapin VMware.VimAutomation.
function Get-VMWorkingDirMismatch {
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
@PatrickTerlisten
PatrickTerlisten / Get-OutdatedVMTools.ps1
Last active Dec 5, 2015
This script outputs a list of all VMs without VMware Tools or with VMware Tools that needs to be updated.
View Get-OutdatedVMTools.ps1
#requires -Version 1
#requires -PSSnapin VMware.VimAutomation.Core
function Get-OutdatedVMTools {
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
@PatrickTerlisten
PatrickTerlisten / Get-MemoryBallooningStats.ps1
Last active Dec 5, 2015
This script outputs a list of all VMs that suffer from memory ballooning
View Get-MemoryBallooningStats.ps1
#requires -Version 1
#requires -PSSnapin VMware.VimAutomation.Core
function Get-MemoryBallooningStats {
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
@PatrickTerlisten
PatrickTerlisten / Get-LunPathState.ps1
Last active Jan 5, 2020
PowerCLI Script that outputs a list of all LUN paths for all ESXi hosts
View Get-LunPathState.ps1
#requires -Version 2
#requires -PSSnapin VMware.VimAutomation.Core
function Get-LUNPathState {
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
This script outputs the number of paths to each LUN.
You can’t perform that action at this time.