This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Quick & Dirty snapshot list | |
get-vm | % { $s = $_ | Get-Snapshot; if ($s) { write-output "VM: $($_.name), Snap: $($s.name)" } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Compare specific privileges assigned to roles with matching names in two different vCenters | |
#Populate two arrays with roles from old vCenter 5.5 and new vCenter 6.0 | |
Connect-VIServer oldvcenter | |
$p_old = Get-VIRole | |
Disconnect-VIServer | |
Connect-VIServer | |
$p_new = Get-VIRole | |
Disconnect-VIServer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "Current Memory Configuration" | |
free -m | |
read -p "Continue or ctrl-c? " | |
echo "Disk Free Space" | |
df -h | |
read -p "Make 4GB swap file at /swapfile? Continue or ctrl-c..." | |
echo "Allocating space..." | |
fallocate -l 4G /swapfile | |
echo "Formatting as swap..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
#List all listening ports and their bound IP | |
ss -lntu | awk '{print $5}' | awk -F ':' '{print $2, "(", $1, ")" }' | sort -n | |
#Lists just the ports | |
#ss -lntu | awk '{print $5}' | sed 's/^.*://' | sort -n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get-vmhost | % { start-vmhostservice -hostservice ($_ | Get-VMHostService | ? key -eq "TSM-SSH") } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get VM Host Max EVC Mode | |
get-view -viewtype hostsystem | select name, {$_.parent}, {$_.Summary.MaxEVCModeKey} | sort "`$_.parent" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#vmotion-validation-test.ps1 | |
#vMotion a VM over all hosts in a cluster, twice. | |
$cluster = Read-Host "Cluster Name" | |
$vm = Read-Host "Test VM Name" | |
function validate-vmotion($cluster, $vm) { | |
$totalms = 0 | |
$count = 0 | |
get-cluster $cluster | get-vmhost | foreach { | |
$duration = Measure-Command { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ajz posted this example at https://www.reddit.com/r/vmware/comments/4akx3o/when_did_somebody_change_the_memory/d126zrc | |
#Saving here for future reference | |
# Get VM's "Reconfiguration" events | |
$changeevents = $vm | Get-VIEvent | Where { $_.FullFormattedMessage -like "Reconfigured*"} | |
# Who initiated the event | |
$changeevents[0].UserName | |
# What specs were changed | |
$changeevents[0].ConfigSpec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#given source.csv | |
#mac,ip | |
#aabbccddeef0,172.16.1.20 | |
#aabbccddeef1,172.16.1.21 | |
Import-CSV source.csv | % { Add-DhcpServerv4Reservation -Scope 172.16.1.0 -ClientID $_.mac -IPAddress $_.ip } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Datastore | % { $sum = ($_ | get-vm | Measure-Object).count; echo "$($_.name), $sum" } |