How to suppress annoying shell warnings on your ESXi hosts in vCenter!

So there you are logging into one of your vCenter’s and then WHOA WHAT IS GOING ON, WHY IS THERE A YELLOW TRIANGLE ON MY SERVER

Annoying Shell Warning on ESXi for ESXi Shell and SSH enabled

Then you click on your server, go to the “Summary” tab and notice it has some ERRORS! Oh my! But you might say to yourself… “Yea, I enabled remote ssh and local shell, so why is it warning me about this?!”

Well, now you don’t need to be annoyed by non-essential ‘warning’ messages which detract from REAL and ACTUAL error messages!

image

This is easily enough fixed by simply going to EACH of your servers, clicking “Configuration” then going to the “Advanced Settings” under Software, drilling down to “UserVars” finding “UserVars.SuppressShellWarning” and changing the value from “0” to “1”

But I don’t wanna do it manually!

Yea. Me neither. I’d rather execute this VERY simply using a single PowerCLI script.  I’ve found some really useful scripts out there which do this in 5-7 lines! That’s awesome…. I hate mult-line scripts unless I SPECIFICALLY need to do multi-line.  So here it is all in one-line!

Disclaimer: The assumption is that you’re using Connect-VIServer in order to connect to your one or multiple vCenters.

Set-VMHostAdvancedConfiguration –VMHost * –Name UserVars.SuppressShellWarning –Value 1

Poof! That is it, and it’ll go through one by one talking to each of your vCenters and enumerating out each of the underlying hosts and change this value!  It literally cannot get any easier than that! <3

PowerCLI One-Liners to make your VMware environment rock out!

So I hadn’t touched PowerCLI in a long while (Hey, I hadn’t touched the CONSOLE OF ANYTHING near production after having been in management for so long!   So, the first thing I decided to do was, “Well, what data is important to me… and what will make my life easier!”   Below you’ll see examples of some of those very scenarios, One-Liners and collections of data points! If you haven’t worked with PowerCLI this is a good way to get started.  I’ll also explain WTF I did and why, so you have some good logic and reasoning behind why to use some of these measures!  Also if you happen to have any really cool one-liners and scripts you’ve used, feel free to toss them into the comments!

Let’s start with … Well, getting started!

Launch PowerCLI CMDLine as an elevated user (This is especially important if you have a different administrative acct than your login)

Connect-VIServer

// You can paste in all of the vCenter Names in order to execute a ‘command’ against all of them.

Example, You can simply launch Connect-VIServer, hit enter and then paste a list of vCenters to connect to.  This is especially important if you happen to be managing more than one vCenter.

Get-VMHost | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Where {$_.ManagementTrafficEnabled} | Select Hostname, PortGroupName, IP, SubnetMask

// This will then dump the ESXi Hostnames, IPs and Subnets – For the Management Network

Get-VMHost | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Where {$_.vMotionEnabled} | Select Hostname, PortGroupName, IP, SubnetMask

// This will then dump the ESXi Hostnames, IPs and Subnets – For the vMotion Network

Get-VMHost | Get-Cluster | Select Name, DrsEnabled, DrsMode, DrsAutomationLevel

// Dump DRS Status

Get-VMHost | Get-Cluster | Select Name, VMSwapfilePolicy

// Dump VMSwapfilePolilcy

Get-VMHost | Get-Cluster | Select Name, HAAdmissionControlEnabled

// Check status of HA Admission Control

Get-VMHost | Get-Cluster | Select Name, HAFailoverLevel, HARestartPriority, HAIsolationResponse

// Check HA Status Levels

Get-VMHost | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Select Hostname, PortGroupName, IP, MTU

// Check for MTU Mismatches

Get-VirtualSwitch | Select VMHost, Name, MTU

// Shows what the MTU settings on the Virtual Switches are

Get-VMGuestNetworkInterface –VM VMNAME | Select VM, IP, SubnetMask, DefaultGateway, Dns

// Dumps a hosts Name, IP, Subnet, Gateway and DNS configuration

Append ‘| Export-Csv “c:\location\filename”’

// This will allow you to export the results to a CSV file  – This is called out so you’re aware of the syntax to do CSV type exports!

Get-VMHost | Get-ScsiLun | Select VMHost, ConsoleDeviceName, Vendor, MultipathPolicy

// This will dump the Multipath Policy of the storage on the systems to determine what the MP configuration is.

Get-VMHost | Get-ScsiLun | Select VMHost, ConsoleDeviceName, Vendor, MultipathPolicy | Where {$_.Vendor –eq “NETAPP”} | Select VMHost, ConsoleDeviceName, Vendor, MultipathPolicy

// This will dump the Multipath Policy of ONLY NetApp systems

Get-VMHost | Get-ScsiLun | Select VMHost, ConsoleDeviceName, Vendor, Model, LunType, MultipathPolicy | Export-CSV “C:\temp\MultipathPolicyFull.csv”

// This will dump the Multipath Policy into a CSV as it’ll be a tad bit longer with multiple attributes specified!

Get-ScsiLun –Hba [software iSCSI HBA] | Set-ScsiLun –MultipathPolicy “RoundRobin”

// You can use these parameters to change the LUNs from Fixed to RoundRobin

e.g.) Get-ScsiLun –Hba vmhba39 | Set-ScsiLun –MultipathPolicy “RoundRobin”

Get-VMhost | Get-SCSILun | Where {$_.Vendor –EQ “NETAPP”} | Select VMHost, Vendor, MultipathPolicy

// Identify the Netapp LUNs

Get-VMhost | Get-SCSILun | Where {$_.Vendor –EQ “NETAPP”} | Where {$_.MultipathPolicy -EQ "Fixed"} | Select VMHost, Vendor, MultipathPolicy

// Identify the Netapp LUNs which are “Fixed”

Get-VMhost | Get-SCSILun | Where {$_.Vendor –EQ “NETAPP”} | Set-SCSILun –MultipathPolicy “RoundRobin”

// Set the NetApp LUNs to RoundRobin

Get-VMhost | Get-SCSILun | Where {$_.Vendor –EQ “NETAPP”} | Where {$_.MultipathPolicy -EQ "Fixed"} | Set-SCSILun –MultipathPolicy “RoundRobin”

Get-VMHost | Sort Name | Select Name, @{N=”NTP”;E={Get-VMHostNtpServer $_}}

// This will dump NTP Configuration settings

Get-VMHost | Get-View | foreach {$_.Summary.Hardware.OtherIdentifyingInfo[3].IdentifierValue}

// This will dump the Dell Service Tags

Get-VMHost | Get-View | Select Name, @{N=”Service Tag”;E={$_.Summary.Hardware.OtherIdentifyingInfo[3].IdentifierValue}}

// This will dump the Host name and the Dell Service Tag

Get-VMHost | Sort Name | Get-View | Select Name, @{N=”Tag 3”;E={$_.Summary.Hardware.OtherIdentifyingInfo[3].IdentifierValue}}, @{N=”Tag 2”;E={$_.Summary.Hardware.OtherIdentifyingInfo[3].IdentifierValue}}, @{N=”Tag 1”;E={$_.Summary.Hardware.OtherIdentifyingInfo[3].IdentifierValue}}

// This will dump the Host name and the Dell Service Tag values across all 3 identifiers

Get-View -ViewType HostSystem | Sort Name | Select Name,@{N="BIOS version";E={$_.Hardware.BiosInfo.BiosVersion}}, @{N="BIOS date";E={$_.Hardware.BiosInfo.releaseDate}}

// This will dump the hosts BIOS version and date(s)

get-vmhost | Get-VMHostAdvancedConfiguration -Name Syslog.global.logHost

// Dump the current SYSLOG Configuration

You may notice that a lot of the Scripts identified in here are very selfishly scripts I’ve personally used… and I’ll tell you… that’s not all that bad ;)   I figure as time goes on, I’ll find other various switches and flags which are important and others ought to check out!  I’m constantly building and adding to this list as there are various scripts I’ll be running on a daily, weekly and monthly basis.   As I start to identify which items fall into the lists I’ll share my experiences with ya’ll here! Enjoy!