Add port group to all VMHosts with PowerCli

This is the script that I use when I need to add several new port groups to a single VMware cluster.  The script does check for the port group before it tries to add it to the VMhost encase it was already setup.

$NetworkInfo = Import-CSV C:\scripts\logs\NetworkInfo.csv
$ClusterName = "VM_Cluster"
$VMHosts = Get-Cluster $ClusterName | Get-VMHost
Foreach ($network in $NetworkInfo){
    $NewPortSwitch = $network.NewPortSwitch
    $VLANID = $Network.VLANID
    Foreach ($VMHost in $VMHosts){
        IF (($VMHost | Get-VirtualPortGroup -name $NewPortSwitch -ErrorAction SilentlyContinue) -eq $null){
            Write-host "Creating $NewPortSwitch on VMhost $VMHost" -ForegroundColor Yellow
            $NEWPortGroup = $VMhost | Get-VirtualSwitch | Select -last 1 | New-VirtualPortGroup -Name $NewPortSwitch -VLanId $VLANID 

Below is the format for the NetworkInfo.csv.… Continue reading

PowerCli to get list of unused RDMs on VM Cluster – Updated

After finishing the last post and starting to use it after limited testing I found that my script wasn’t filtering out the Datastores as expected.  This information was presented to me via our storage team.  So I have went back to the Integrated Scripting Environment (ISE) to resolved my issues.

$Cluster = "Cluster name here"
#This Line gets all of the LUNs that are connected to the first host in the cluster.
Continue reading

PowerCli to get list of unused RDMs on VM Cluster

This page has been updated. Please visit for the updated script.

Since my last post was about RDMs, lets continue the discusion.  In my work environment we have been consolidating our VMware platform.
So we have been moving VMs with RDMs attached from one cluster to another.  So its been a messy process, and we haven’t had the time to
clean up behind ourselves. … Continue reading