User Tools

Site Tools


vmware:esx_powercli

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
vmware:esx_powercli [2021/11/19 22:46]
manu
vmware:esx_powercli [2022/09/20 22:40] (current)
manu
Line 267: Line 267:
 </​cli>​ </​cli>​
  
 +==== List VM with RAW disks ====
 +
 +<cli prompt='>'>​
 +PS1> Get-VM | Get-HardDisk -DiskType "​RawPhysical","​RawVirtual"​ | Select Parent,​Name,​DiskType,​ScsiCanonicalName,​DeviceName | fl | Out-File –FilePath RDM-list.txt
 +</​cli>​
  
 ===== Commands ===== ===== Commands =====
  
-<​code>​ 
 Collecting information about virtual machine hardware Collecting information about virtual machine hardware
    
 To get a list of all the virtual machines in the inventory and their name, power state, number of CPUs, and configured memory, run the cmdlet: To get a list of all the virtual machines in the inventory and their name, power state, number of CPUs, and configured memory, run the cmdlet:
- +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VM+PS1> Get-VM
 Name PowerState Num CPUs Memory (MB) Name PowerState Num CPUs Memory (MB)
 ---- ---------- -------- ----------- ---- ---------- -------- -----------
 NW PoweredOff 1 512 NW PoweredOff 1 512
 PowerCLI PoweredOn 1 1024 PowerCLI PoweredOn 1 1024
- +</​cli>​ 
 Note: This command provides information about the version, virtual hardware attached (virtual disk, network, CD-ROM), datastore, host, High Availability restart, and isolation properties: Note: This command provides information about the version, virtual hardware attached (virtual disk, network, CD-ROM), datastore, host, High Availability restart, and isolation properties:
-  +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VM windows-dc | Format-List *+PS1> Get-VM windows-dc | Format-List * 
 +</​cli>​
    
 Collecting information about the virtual machine guest operating system Collecting information about the virtual machine guest operating system
    
 vSphere PowerCLI provides cmdlets to retrieve the details about the virtual machine guest operating system. These cmdlets are independent of the guest operating system installed in the virtual machine. vSphere PowerCLI provides cmdlets to retrieve the details about the virtual machine guest operating system. These cmdlets are independent of the guest operating system installed in the virtual machine.
-  +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VMGuest -VM windows-dc | Format-List *+PS1> Get-VMGuest -VM windows-dc | Format-List *
  
 OSFullName : Microsoft Windows Server 2003, Enterprise Edition (64-bit) OSFullName : Microsoft Windows Server 2003, Enterprise Edition (64-bit)
Line 297: Line 303:
 Nics : {} Nics : {}
 ScreenDimensions : {Width=1024,​ Height=768} ScreenDimensions : {Width=1024,​ Height=768}
- +</​cli>​ 
 Note: When retrieving the details about the guest operating system, you are prompted for the user name and password for the ESX/ESXi host and guest operating system. You can provide the authentication details in the command by using the -HostUser root -HostPassword pass1 -GuestUser administrator -GuestPassword vmware123 parameters. Note: When retrieving the details about the guest operating system, you are prompted for the user name and password for the ESX/ESXi host and guest operating system. You can provide the authentication details in the command by using the -HostUser root -HostPassword pass1 -GuestUser administrator -GuestPassword vmware123 parameters.
    
Line 303: Line 310:
    
 Note: To use this command ensure that the latest version of VMware Tools are installed on the virtual machine and this cmdlet is applicable only for Windows guest. Note: To use this command ensure that the latest version of VMware Tools are installed on the virtual machine and this cmdlet is applicable only for Windows guest.
-  +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VM windows-dc | Invoke-VMScript "​Get-Service app*"+PS1> Get-VM windows-dc | Invoke-VMScript "​Get-Service app*"
    
 Status Name DisplayName Status Name DisplayName
 ------ --- ----------- ------ --- -----------
 Stopped AppMgmt Application Management Stopped AppMgmt Application Management
- +</​cli>​ 
 vSphere PowerCLI also provides cmdlets to provide the network configuration information from within the guest operating system: vSphere PowerCLI also provides cmdlets to provide the network configuration information from within the guest operating system:
-  +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VMGuestNetworkInterface -VM windows-dc -HostUser root -HostPassword vmware123 -GuestUser administrator -GuestPassword vmware123+PS1> Get-VMGuestNetworkInterface -VM windows-dc -HostUser root -HostPassword vmware123 -GuestUser administrator -GuestPassword vmware123
  
 VMId : VirtualMachine-vm-33 VMId : VirtualMachine-vm-33
Line 332: Line 340:
 WinsPolicy : Static WinsPolicy : Static
 Wins : Wins :
- +</​cli>​ 
 To retrieve the routing configuration of the specified virtual machine, run the cmdlet: To retrieve the routing configuration of the specified virtual machine, run the cmdlet:
-  +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VMGuestroute -VM windows-dc -HostUser root -HostPassword vmware123 -GuestUser administrator -GuestPassword vmware123+PS1> Get-VMGuestroute -VM windows-dc -HostUser root -HostPassword vmware123 -GuestUser administrator -GuestPassword vmware123
  
 Destination : 0.0.0.0 Destination : 0.0.0.0
Line 343: Line 352:
 VMId : VirtualMachine-vm-33 VMId : VirtualMachine-vm-33
 VM : windows-dc VM : windows-dc
- +</​cli>​ 
 Configuring a virtual machine using PowerCLI Configuring a virtual machine using PowerCLI
    
Line 349: Line 359:
    
 To create new virtual machines, run the cmdlet: To create new virtual machines, run the cmdlet:
-  +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> New-VM -VMHost xx.xx.xx.xx -Name TestCli -MemoryMB 1024 -DiskMB 8024+PS1> New-VM -VMHost xx.xx.xx.xx -Name TestCli -MemoryMB 1024 -DiskMB 8024
    
 Name PowerState Num CPUs Memory (MB) Name PowerState Num CPUs Memory (MB)
 ---- ---------- -------- - ---------- ---- ---------- -------- - ----------
 TestCli PoweredOff 1 1024 TestCli PoweredOff 1 1024
- +</​cli>​ 
 To migrate a virtual machine using vMotion, run the cmdlet: To migrate a virtual machine using vMotion, run the cmdlet:
-  +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VMHost xx.xx.xx.xx | Get-VM "​windows-cli"​ | Move-VM -Destination xx.xx.xx.xx+PS1> Get-VMHost xx.xx.xx.xx | Get-VM "​windows-cli"​ | Move-VM -Destination xx.xx.xx.xx
    
 Name PowerState Num CPUs Memory (MB) Name PowerState Num CPUs Memory (MB)
 ---- ---------- -------- ----------- ---- ---------- -------- -----------
 windows-cli PoweredOn 1 1024 windows-cli PoweredOn 1 1024
 +</​cli>​
    
 To migrate a virtual machine using Storage vMotion, run the cmdlet: To migrate a virtual machine using Storage vMotion, run the cmdlet:
-  +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VM windows-rhel5 | Move-VM -Datastore vCloud-1+PS1> Get-VM windows-rhel5 | Move-VM -Datastore vCloud-1
    
 Name PowerState Num CPUs Memory (MB) Name PowerState Num CPUs Memory (MB)
 ---- ---------- -------- ----------- ---- ---------- -------- -----------
 windows-rhel5 PoweredOn 1 3072 windows-rhel5 PoweredOn 1 3072
- +</​cli>​ 
 All of the virtual machines in the in the inventory can be configured with or without the CD-ROM drive using this command: All of the virtual machines in the in the inventory can be configured with or without the CD-ROM drive using this command:
    
 Note: To disable CD-ROM, use the $false option. To enable CD-ROM, use the $true option. Note: To disable CD-ROM, use the $false option. To enable CD-ROM, use the $true option.
-  +[<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VM | Get-CDDrive | Set-CDDrive -Connected:​$false+PS1> Get-VM | Get-CDDrive | Set-CDDrive -Connected:​$false
    
 Confirm Confirm
Line 382: Line 395:
 Performing operation "​Setting Connected: False, NoMedia: False."​ on Target "​CD/​DVD Drive 1". Performing operation "​Setting Connected: False, NoMedia: False."​ on Target "​CD/​DVD Drive 1".
 [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "​Y"​):​Y [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "​Y"​):​Y
- +</​cli>​ 
 If you would like to remove confirmation option, then add this at the end of commandlet "​-Confirm:​$false",​ this is an example: If you would like to remove confirmation option, then add this at the end of commandlet "​-Confirm:​$false",​ this is an example:
-  +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VM | Get-CDDrive | Set-CDDrive -Connected:​$false -confirm:​$false +PS1> Get-VM | Get-CDDrive | Set-CDDrive -Connected:​$false -confirm:​$false 
- +</​cli>​ 
 Working with virtual machine snapshots Working with virtual machine snapshots
    
Line 392: Line 407:
    
 To take a new snapshot for all virtual machines in a cluster, run the cmdlet: To take a new snapshot for all virtual machines in a cluster, run the cmdlet:
-  +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-Cluster "​vCloud"​ | Get-VM | New-Snapshot -Name Automate+PS1> Get-Cluster "​vCloud"​ | Get-VM | New-Snapshot -Name Automate
    
 Name Description PowerState Name Description PowerState
Line 399: Line 414:
 Automate PoweredOff Automate PoweredOff
 Automate PoweredOff Automate PoweredOff
 +</​cli>​
    
 To remove a snapshot from all of the virtual machine in the inventory, run the cmdlet: To remove a snapshot from all of the virtual machine in the inventory, run the cmdlet:
-  +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VM | Get-Snapshot | Remove-Snapshot+PS1> Get-VM | Get-Snapshot | Remove-Snapshot
    
 Confirm Confirm
Line 410: Line 426:
 [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
 (default is "​Y"​):​A (default is "​Y"​):​A
 +</​cli>​
    
 To remove a confirmation option, add this at the end of commandlet: To remove a confirmation option, add this at the end of commandlet:
- +<​code>​ 
--Confirm:​$false+  -Confirm:​$false 
 +</​code>​
  
 For example: For example:
- +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VM | Get-Snapshot | Remove-Snapshot -Confirm:​$false+PS1> Get-VM | Get-Snapshot | Remove-Snapshot -Confirm:​$false 
 +</​cli>​
    
 Note: Use these commands with caution as the changes made are applicable for all virtual machines. Note: Use these commands with caution as the changes made are applicable for all virtual machines.
Line 426: Line 445:
    
 In this example, the VMware Tools for all of the virtual machines in Resource Pool vCloud are updated without rebooting the virtual machine: In this example, the VMware Tools for all of the virtual machines in Resource Pool vCloud are updated without rebooting the virtual machine:
-  +<cli prompt='>'>​ 
-[vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-ResourcePool vcloud | Get-VM | Update-Tools -NoReboot+PS1> Get-ResourcePool vcloud | Get-VM | Update-Tools -NoReboot
 WARNING: Automatic update of VMware tools is not fully supported for WARNING: Automatic update of VMware tools is not fully supported for
 non-Windows OSs. Manual intervention might be required. non-Windows OSs. Manual intervention might be required.
- +</​cli>​ 
 Note: Before running the cmdlet, ensure that the VMware Tools service is running. This command is used only to upgrade VMware Tools. To do an unattended install, use msiexec.exe. For more information,​ see the Microsoft article Command ​ Note: Before running the cmdlet, ensure that the VMware Tools service is running. This command is used only to upgrade VMware Tools. To do an unattended install, use msiexec.exe. For more information,​ see the Microsoft article Command ​
-</​code>​+
  
  
vmware/esx_powercli.1637358410.txt.gz · Last modified: 2021/11/19 22:46 by manu