Hi All,
sometimes we have to get details from our V-CENTER, whether for a self-inventory or any task we are planning to proceed. I am assuming that most of you already know these commands, However, it was important for me to demonstrate this for you. Introduce PowerCLI.
I as IT guy like to learn and check new technologies in my leisure time in the home, especially that we are talking about IT technologies.
So let get started,
First of all, you have to connect to your V-CENTER with the following command:
Connect-VIServer -Server “PelegITvcenter01”
What about our VM’s:?
Get-vm |select name
Your HA Cluster didn’t work properly ? do you have 1000 VM’s but don’t know what are their power state? run the following command:
Get-VM | select Name,PowerState
All right, get your cluster:
Get-Cluster
get cluster and host information
Get-Cluster | Get-VMHost | sort name
Get power state, Num CPU, Memory GB in regarding your VM:
Get-Cluster | Get-VM | sort name
Would like to know what network adapter type do you use on all VMs’ before starting the task of changing the adapter to VMX?, NP:
get-vm | Get-NetworkAdapter
Would like to Power On VM by Powershell?
Start-VM -VM <VM NAME> -Confirm -RunAsync
Get Virtual Port Group:
Get-VirtualPortGroup
Get Virtual Switch:
Get-VirtualSwitch
Get Virtual machines with Thin or Thick Provision:
Get-VM | Get-HardDisk |select Parent,StorageFormat,Filename
Important!, get snapshot details:
Get-vm | Get-Snapshot
Get all snapshots less than 3 days:
Get-VM | Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(-3)}
Remove snapshot according to match snapshot name
get-vm | Get-Snapshot | where {$_.Name -match “name of snapshot”} | Remove-Snapshot -confirm:$false
You can use in Export, Filter, where-object, variables to improve your script/query.