Scripts

vmware powercli commands

Add Network Port Group

To add to all hosts in the cluster, use this script:

get-cluster "My-Servers" | Get-VMHost | Get-VirtualSwitch -Name "vSwitch0" | New-VirtualPortGroup -Name "VM Mgmt Network VLAN 101" -VLanId 101

To add to one host, use this script:

get-vmhost "IP of Host" | Get-VirtualSwitch -Name "vSwitch0" | New-VirtualPortGroup -Name "VM Mgmt...Read More »


VMware Scripts

PowerCLI get list of vMotion IP’s in use



$Array = @()
$Clusters = Get-Cluster | Sort Name
ForEach ($Cluster in $Clusters){
$VmHosts = $Cluster | Get-VmHost | Where {$_.ConnectionState -eq “Connected”} | Sort Name
ForEach ($VmHost in $VmHosts){
$Array += Get-VMHostNetworkAdapter -VMHost $VmHost.Name -VMKernel | Where {$_.VMotionEnabled -eq “True”} | select VmHost,IP
}
}
$Array | Out-GridView

 

Source: http://blog.jgriffiths.org/powercli-get-list-of-vmotion-ips-in-use/

Read More »

Date and Time in DOS

for /f “tokens=1,2,3,4,5,6 usebackq delims=.: ” %a in (‘%date% %time%’) do echo %c%b%a_%d%e%f

...Read More »