No edit summary |
No edit summary |
||
| Line 38: | Line 38: | ||
Get all snapshots in vSphere environment with the following command:<syntaxhighlight lang="powershell"> | Get all snapshots in vSphere environment with the following command:<syntaxhighlight lang="powershell"> | ||
Get-Snapshot * | Select-Object -Property VM, Name, SizeGB, Children | Sort-Object -Property sizeGB -Descending | ft -AutoSize | Get-Snapshot * | Select-Object -Property VM, Name, SizeGB, Children | Sort-Object -Property sizeGB -Descending | ft -AutoSize | ||
</syntaxhighlight> | |||
== Get VM information == | |||
Get vm creation date:<syntaxhighlight lang="powershell"> | |||
(get-vm -name "<vm name>").ExtensionData.config.createdate | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 11:16, 24 May 2024
VMware Powercli
Connect to environment
- Connect-VIServer -Server vcenter01 -User admin -Password pass
or
- Connect-VIServer -Server vcenter01
Disconnect from all servers:
- Disconnect-Viserver -Server *
Create VMs
Get Guest ID from all VMs currently in the vSphere:
(get-vm | get-vmguest).GuestID | sort | unique
Get guest ID from template to set when using New-VM:
Get-Template -Name "name_of_your_template"
$template.ExtensionData.Config.GuestId
VM Management
Disk Management
Add new Hard disk:
New-HardDisk -VM <name of vm> -CapacityGB 100
Get Snapshots
Get all snapshots in vSphere environment with the following command:
Get-Snapshot * | Select-Object -Property VM, Name, SizeGB, Children | Sort-Object -Property sizeGB -Descending | ft -AutoSize
Get VM information
Get vm creation date:
(get-vm -name "<vm name>").ExtensionData.config.createdate