Some VMWare PowerCLI scripts that may come in handy to someone.


I was working with making some custom Scripts in PowerGUI and found some of the community ones missing some of the common things I have to do as part of Hardening or system setup. Most of the ones on other sites work but did not work well in PowerGUI due to it bombing out on an error so I just wanted it to set the ones which where not in the state I wanted them in.


Status of Lockdown Mode

Get-VMHost | Select Name, @{N="Lockdown";E={$_.Extensiondata.Config.adminDisabled}}

Disable Lockdown Mode

$Scope = Get-VMHost | Where {$_.Extensiondata.Config.adminDisabled -match 'True'}
foreach ($ESXhost in $Scope)
{
(Get-VMHost $ESXhost | get-view).ExitLockdownMode()
}

Enable Lockdown Mode

$Scope = Get-VMHost | Where {$_.Extensiondata.Config.adminDisabled -match 'False'}
foreach ($ESXhost in $Scope)
{
 Get-VMHost $ESXhost | get-view).EnterLockdownMode()
}


I also wrote a few scripts to help set up hosts for our Flash storage as recommended by Pure for their flash arrays. Use at your own Risk if you storage can't support these.


Get Settings


Get-VMhost | Get-VMHostAdvancedConfiguration Disk.SchedNumReqOutstanding


Get-VMhost | Get-VMHostAdvancedConfiguration Disk.SchedQuantum


Get-VMhost | Get-VMHostAdvancedConfiguration VMFS3.EnableBlockDelete


Get-VMhost | Get-VMHostAdvancedConfiguration DataMover.MaxHWTransferSize


Get-VMhost | Get-VMHostAdvancedConfiguration VMFS3.HardwareAcceleratedLocking


Get-VMHost | Get-ScsiLun -LunType disk | Where {$_.MultipathPolicy -notlike "RoundRobin"}


To Set Settings


Get-VMhost | Set-VMHostAdvancedConfiguration Disk.SchedNumReqOutstanding -Value 256


Get-VMhost | Set-VMHostAdvancedConfiguration Disk.SchedQuantum -Value 64


Get-VMhost | Set-VMHostAdvancedConfiguration VMFS3.EnableBlockDelete -value 1


Get-VMHost | Get-AdvancedSetting -Name DataMover.MaxHWTransferSize | Set-AdvancedSetting -Value 16384 (Not sure but this is the only way to set it I could find)


Get-VMhost | Set-VMHostAdvancedConfiguration VMFS3.HardwareAcceleratedLocking -value 1 (should be the default already)

Get-VMHost | Get-ScsiLun -LunType disk | Where {$_.MultipathPolicy -notlike "RoundRobin"} | Where {$_.CapacityGB -ge 100} | Set-Scsilun -MultiPathPolicy RoundRobin ( I found this one on JasonPierce.com it works in my environment because all local disks are under 100GB and we do not use them for datastores of any kind. It sets multpathing policy to RoundRobin and all our arrays support this)

Get-VMhost |Get-VMhostModule "qla2xxx" | Set-VMHostModule -Options "ql2xmaxqdepth=256"

Get-VMhost |Get-VMhostModule "lpfc820" | Set-VMHostModule -Options "lpfc_lun_queue_depth=256"

Comments

Popular posts from this blog

All things Organized

Finished SVS upgrades

Little Healthcare/Cash for Clunkers Humor