There are times that you will need to check if esxi credentials are correct & consistent across the multiple hosts, and this PowerCLI script will save your time a lot. It uses TCP port 443 so it takes a bit longer than using ssh, but the good thing is you do not need to open port 22 from your client. The process is quite simple Continue reading “Check or Verify Esxi Credentials on Multiple Esxi Hosts”
Category: PowerCLI
PowerCLI to set Evacuated Esxi Hosts into Maintenance Mode
It’s the little script that will set all esxi hosts into maintenance mode when no VMs are left running, particularly useful when you’re doing the bulk VMs migration or shutdown for Esxi maintenance. Continue reading “PowerCLI to set Evacuated Esxi Hosts into Maintenance Mode”
Powershell to Check VMware Network Portgroup Connectivity with VM Migration
Now, it’s a blogging time. Here is the little script that you can use to check the network connectivity of each portgroup in your vmware environment, which can also be used to determine if the portgroups or physical uplink (backing the vswitch) has the desired vlan access for the multiple exsi hosts.
This script will output the the VM’s ICMP Ping status after making vMotion to each host within the current vmware cluster (where the VM resides) or any clusters. Continue reading “Powershell to Check VMware Network Portgroup Connectivity with VM Migration”
PowerCLI Script to List VM Snapshots with Last VM Reboot Time
Again, It’s time to script, making life easier with the system admin’s boring tasks. Most of us have testing environment in which we have to play with snapshots (so called checkpoints in Hyper-V).
This script will list the VMs snapshots with the last VM power-on time. This is particularly useful in cases where you want to keep the snapshot until the VM is rebooted and proved to be fully functional after any configuration changes. Continue reading “PowerCLI Script to List VM Snapshots with Last VM Reboot Time”
How to use PowerCLI to list Device ID, Mounted URL of Datastores in VMware
Here is the PowerCLI one-liner command to find the Datastore Name, Mounted URL and Device ID in your vSphere Environment.
Assume you’ve installed VMware PowerCLI. Continue reading “How to use PowerCLI to list Device ID, Mounted URL of Datastores in VMware”
PowerCLI Connection Error: The underlying connection was closed: An unexpected error occurred on a send
“The underlying connection was closed: An unexpected error occurred on a send”
List ALL VMware SRM Protected VMs with their Protection Group Names
In your VMware Site-Recovery-Manager Environment, you may need to fetch the list of protected VMs and their associated protection group for documentation purpose. For this purpose, I created this one-liner command to fetch the necessary information with Name, Protection Group Name, Description, Replication Type & Datastore. Continue reading “List ALL VMware SRM Protected VMs with their Protection Group Names”
PowerCLI: Automatically Power on VMs from the Saved CSV file
It’s the Powershell script using PowerCLI to power on a bunch of VMs when multiple servers go offline or during disaster recovery. Not using any third-party tools, I got the idea to do it in PowerCLI to backup the current Powerstate of the VMs to csv file and compare it when powering on VMs, so that you do not mistakenly turn on VMs that are initially powered off. I added the progress bar to get the progress state of powering on VMs.
What this script will do:
1) It will backup the current Power State of VMs to csv file. It will create the new csv file if not already created.
2) If the file is already created, it will check the current power state of VMs by comparing with the csv file.
3) If the Powered On server in the list is found as powered off in vCenter or esxi, it will power on all VMs.
Please note that you will need to connect the vCenter/Esxi before running the script. Also, you will need to disconnect the vCenter/Esxi connection once the job is finished.
Use the the following command to connect to the host.
Connect-VIServer -Server yourserver -Credential (get-credential)
Use the following command to disconnect from host.
Disconnect-VIServer -Server yourserver -confirm:$false
You can download my script from the github.
PowerCLI: Get the Vmnic CDP Information of Esxi Hosts
In these days, I do have to backup the CDP info of our current esxi hosts and fortunately I found script this blog and official VMware site to discover information. Only I made little changes to the script to suite my environment. You need Powercli (PowerCLI 5.5 is here) already installed, and must be connected to vCenter of specific Esxi host before running the script.
If you’re not connected to vCenter, you can use the command:
Connect-VIServer -Server yourServerNameOrIP -Credential (Get-Credential)
After you have finished running the script, you can disconnect the vCenter Server by using the following command.
Disconnect-VIServer -Server yourServerNameOrIP
Note: You can also add the esxi hostnames in the hostlist.txt to get the CDP info for specific hosts only. If the hostlist.txt file doesn’t exit, then it will gather information for all Esxi hosts.
You can download my script from the github.