No edit summary |
|||
| Line 33: | Line 33: | ||
Add new Hard disk:<syntaxhighlight lang="powershell"> | Add new Hard disk:<syntaxhighlight lang="powershell"> | ||
New-HardDisk -VM <name of vm> -CapacityGB 100 | New-HardDisk -VM <name of vm> -CapacityGB 100 | ||
</syntaxhighlight>See: https://developer.vmware.com/docs/powercli/latest/vmware.vimautomation.core/commands/new-harddisk/#CreateNew | |||
== Get Snapshots == | |||
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 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 12:43, 17 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