I have ran PowerPath VE in my production ESXi environment and I am a huge fan of the product. What I have seen in the past is that
sometimes the hosts will lose their way to the licensing server, and not
technically have a license checked out.
I don’t know if there is a risk to losing the benefits that PowerPath VE
provides when a host is in this unlicensed state, so I wrote a simple batch
script that would reregister the hosts.
This worked in the past, but often times I would be negligent and not
run it as frequently as I should.
Coupled with the fact that we began to use VMware’s lockdown
mode to fully secure our ESXi hosts, the batch file was no longer working. Lockdown mode prevents anyone from directly
authenticating directly to the ESXi host, therefore the built in lockbox sitting
on the PowerPath VE server was no longer able to directly register the hosts as
licensed.
I could manually disable each hosts lockdown mode and run
the batch file again, but that’s pretty tedious and I am sure I would forget to
do it. In times like these I turn to
PowerCLI and write a dependable script and set it to run in task scheduler and
not worry about it again.
Since I do not have PowerPath VE installed on all of my
hosts, I will just maintain a csv file with the host information as an input for
the script.
The rest of the script is pretty basic. The script is a PowerCLI\Powershell wrapper
script. I am importing the PPhosts.csv
file so I can run a set of actions against each individual server
sequentially. For each host listed, I
will first disable lockdown mode. I dug
the .ExitLockdownMode() and .EnterLockdownMode() out of the following KB
article: KB article
001
002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 |
Connect-VIServer 'Your vCenter' $var = Import-Csv C:\temp\PPhosts.csv FOrEach ($guy in $var ) { (get-vmhost $guy.Name -ErrorAction SilentlyContinue | get-view).ExitLockdownMode() $1 = "rpowermt host=" $2 = " register" $3 = $1 + $guy.Name + $2 cmd /c $3 (get-vmhost $guy.Name -ErrorAction SilentlyContinue | get-view).EnterLockdownMode() } |
I used the –ErrorAction SilentlyContinue so the script
will not halt. There is a known bug with
vCenter when the status of the lockdown mode is listed incorrectly. The “SilentlyContinue” switch will allow the
script to continue to loop through the remaining hosts.
Next I am doing a little concatenation to build the
correct command per host in the csv file.
The end result should have $3= “rpowermt host=MYHOST1.host.com register”. Using the cmd /c will execute the same command
I previously ran in my batch file. But
instead with PowerShell as the wrapper, it will insert each host name or ($guy.Name) every time the
loop is executed.
In the end, I am just putting the host back in
lockdown mode as it was before. The last step is to set the script to run as a
scheduled task. I do periodically test
the scripts functionality and launch the script as a scheduled task to verify
they are working correctly.