New Posts

A Mini-Blog around VMware, my experiences, and medium to develop my professional expertise.

I started working with VMware in 2008. Since then, I've done countless P2V/V2V migrations, new installs and upgrades from 4 through 6.5. Currently I manage enterprise VMware environments with thousands of VMs and millions of users. I hope this mini-blog provides you with ideas and knowledge, as other blogs of this type have helped me along the way.

-KnightUSN
VMware Certified Professional 4 – Data Center Virtualization
VMware Certified Professional 5 – Data Center Virtualization
VMware Certified Professional 6 – Data Center Virtualization

Configure RDM pathing to Fixed

posted Jun 14, 2016, 11:31 AM by Knight USN   [ updated Jun 14, 2016, 11:34 AM ]

<# 
.SYNOPSIS
    Configures a VM's RDM pathing to Fixed.
.DESCRIPTION
    Created to quickly configure MSSQL cluster VMs that need RDMs in physical compatibility mode and SCSI bus sharing. It is recommended that the path selection be configured for Fixed path.
.EXAMPLE
    .\SET-RDMvmtoFixed.ps1  <ESXi Name>
.NOTES
Author: KnightUSN
Version: 1.0 May 2016
#>

param(
    [parameter(Mandatory = $true,
ValueFromPipeline=$true)]
    [string[]]$vmname
    )

$hdds = get-vm $vmname | Get-HardDisk -DiskType RawPhysical

foreach($hdd in $hdds){

$lun = Get-ScsiLun -CanonicalName $hdd.ScsiCanonicalName -VmHost $hdd.Parent.VMhost

If($lun.MultipathPolicy -ne 'Fixed'){
$scsilunpath = get-scsilunpath -ScsiLun $lun | Sort-Object State | Select-Object -First 1
set-scsilun -ScsiLun $lun -MultipathPolicy Fixed -PreferredPath $scsilunpath -Confirm:$false
}
}

Inactive LUN Paths on ESXi host.

posted May 23, 2016, 10:39 AM by Knight USN   [ updated Jun 14, 2016, 11:48 AM ]

<# 
.SYNOPSIS
Checks ESXi Host lun paths for Dead Path scenerio.
.DESCRIPTION
Created to check and look for Paths that are not "active". If paths are found, they are listed for that host.
.EXAMPLE
.\GET-DeadPath.ps1  <ESXi Name>
or
.\GET-DeadPath.ps1 *
.NOTES
Author: KnightUSN
Version: 1.0 May 2016
#>

param(
    [parameter(Mandatory = $true)]
    [string[]]$Param
    )


$VHs = Get-VMHost $Param -State Connected

ForEach ($VH in $VHs){
$VHcli = $VH | Get-ESXcli
Write-Host "Checking "$VH.name" for Dead Path" 
$VHcli.storage.core.path.list() | ?{$_.state -ne "active"}
}

Reset Hard "Flapped" Host Nics

posted Apr 8, 2016, 5:40 PM by Knight USN   [ updated Apr 9, 2016, 7:39 AM ]

So I came across a scenario where host nic was down. Rebooting and reseating hardware did nothing. Removing the vSwitch and recreating seemed to resolve the issue. When it happened again days later I tried removing the network adapter and re-adding it back to the vSwitch. That resolved it. I decided to look into scripting this task while the vendors tried to figure this out. Looking at the EsxCLI I noticed that resetting the nic that was down also resolved the issue. So, I made a function. Enjoy!

<################################################################################
.SYNOPSIS
Checks and corrects downed link status on ESXi physical nics.
.DESCRIPTION
Function was created to check and look for "Flapped" NICs. Then reset the nic if link status is down.
.EXAMPLE
ResetHostNics ESXi1
or      
Get-VMhost | %{ResetHostNics $_.Name} 
.NOTES
By: KnightUSN
################################################################################>
Function ResetHostNics($vhost){
    $esxcli = get-vmhost $vhost | Get-EsxCli
    $downNics = $esxcli.network.nic.list() | ?{$_.Link -eq "Down"} | select name
    ForEach($downNic in $downNics){
        Write-Host $vhost " was Affected. Fixing... "$downNic.name
$esxcli.network.nic.down($downNic.Name)
$esxcli.network.nic.up($downNic.Name)
    }
}

1-3 of 3

Comments