PowerCLI: Bring on the next version
In the previous version of PowerCLI we had 165 great cmdlets to play with and didn’t we have fun, now in the new version (Download Here) we have a whopping…..
That’s right, an extra 68 cmdlets (4 of the old cmdlets were renamed from the previous version), bring on the fun !
So as well as the increased performance, what do we now have to play with ? here is a quick summary of the new cmdlets and what they do….
| Name | Synopsis |
| Add-PassthroughDevice | Attaches pass-through devices to the specified virtual machine. |
| Apply-DrsRecommendation | Applies the specified DRS recommendations. |
| Copy-DatastoreItem | Copies items between datastores and between a datastore and a local file system provider. |
| Copy-HardDisk | Copies a virtual hard disk to another destination. |
| Copy-VMGuestFile | Copies a file from and to the guest OS of the specified virtual machines using VMware Tools. |
| Export-VApp | Exports a virtual appliance to the provided destination. |
| Get-Annotation | Retrieves annotations. |
| Get-CustomAttribute | Retrieves custom attributes. |
| Get-DrsRecommendation | Retrieves the available DRS recommendations from the provided clusters. |
| Get-IScsiHbaTarget | Retrieves the available iSCSI HBA targets. |
| Get-NicTeamingPolicy | Retrieves the Nic teaming policies of the specified virtual switches and virtual port groups. |
| Get-OSCustomizationNicMapping | Retrieves the configured Nic setting mappings for the specified OS customization specification. |
| Get-PassthroughDevice | Retrieves the pass-through devices available on the specified hosts, virtual machines, and templates. |
| Get-PowerCLIConfiguration | Retrieves the vSphere PowerCLI proxy configuration and default servers policy. |
| Get-PowerCLIVersion | Retrieves the vSphere PowerCLI version. |
| Get-UsbDevice | Retrieves the USB devices available on a vSphere server. |
| Get-VApp | Retrieves virtual appliances. |
| Get-VIPermission | Retrieves the permissions defined on the specified inventory objects. |
| Get-VIPrivilege | Retrieve the privilege groups and items for the provided servers. |
| Get-VIRole | Retrieves all roles defined on the provided servers. |
| Get-VMGuestNetworkInterface | Retrieves information about the network configuration of the specified virtual machines or guests. |
| Get-VMGuestRoute | Retrieves the routing configuration of the specified virtual machines or guests. |
| Get-VMHostAvailableTimeZone | Retrieves the time zones available on the specified host. |
| Get-VMHostHba | Retrieves information about the available HBAs (Host Bus Adapter). |
| Get-VMHostNetworkAdapter | Retrieves the host network adapters on a vSphere server. |
| Get-VMQuestion | Retrieves the pending questions for the specified virtual machines. |
| Import-VApp | Imports a virtual appliance. |
| Install-VMHostPatch | Updates the specified hosts. |
| Move-Template | Moves virtual machine templates to another location. |
| New-CustomAttribute | Creates a new custom attribute. |
| New-IScsiHbaTarget | Creates a new iSCSI HBA target. |
| New-OSCustomizationNicMapping | Adds Nic settings mappings to the specified OS customization specifications. |
| New-VApp | Creates a new virtual appliance. |
| New-VIPermission | Creates new permissions on the specified inventory objects for the provided users and groups in the role. |
| New-VIRole | Creates a new role on the specified servers and applies the provided privileges. |
| New-VMGuestRoute | Adds a new route to the routing table of the provided virtual machines and guests. |
| Remove-CustomAttribute | Removes custom attributes. |
| Remove-HardDisk | Removes the specified virtual hard disks. |
| Remove-IScsiHbaTarget | Removes targets from their iSCSI HBAs. |
| Remove-OSCustomizationNicMapping | Removes the specified OS customization NIC mappings. |
| Remove-PassthroughDevice | Removes the specified pass-through devices. |
| Remove-UsbDevice | Removes the specified USB devices from a virtual machine. |
| Remove-VApp | Removes virtual appliances from the server. |
| Remove-VIPermission | Removes the specified permissions. |
| Remove-VIRole | Removes the specified roles. |
| Remove-VMGuestRoute | Removes the specified routes from the routing table of their corresponding virtual machines. |
| Restart-VM | Restarts the specified virtual machines. |
| Restart-VMHost | Restarts the specified hosts. |
| Set-Annotation | Changes the name of the specified annotation. |
| Set-CustomAttribute | Specifies a name for a custom attribute. |
| Set-IScsiHbaTarget | Configures an iSCSI HBA target. |
| Set-NicTeamingPolicy | Configures the specified NIC teaming policy. |
| Set-OSCustomizationNicMapping | Modifies the provided OS customization NIC mappings. |
| Set-PowerCLIConfiguration | Modifies the vSphere PowerCLI configuration. |
| Set-VApp | Configures a virtual appliance. |
| Set-VIPermission | Modifies the properties of the specified permissions. |
| Set-VIRole | Modifies the privileges of the provided roles. |
| Set-VIToolkitConfiguration | Modifies the vSphere PowerCLI configuration. |
| Set-VMGuestNetworkInterface | Configures the network settings of a virtual machine using VMware Tools. |
| Set-VMGuestRoute | Configures the specified route. |
| Set-VMHostHba | Configures the CHAP properties of the given iSCSI HBAs. |
| Set-VMHostStorage | Configures a host storage. |
| Set-VMQuestion | Answers the specified virtual machine question. |
| Start-VApp | Starts virtual appliances. |
| Start-VMHost | Starts the specified hosts. |
| Stop-VApp | Stops virtual appliances. |
| Stop-VMHost | Powers off the specified hosts. |
| Suspend-VMHost | Suspends hosts. |
PowerShell Gotcha – Export-CSV, Out-GridView and others PowerCLI to SQL Databases











Another important feature is that PowerCLI now supports running cmdlets on multiple servers. To switch between working on a single server and working on multiple servers, use the Set-PowerCLIConfiguration cmdlet.
@Mariana
You guys have just made far too many exciting changes, I knew I missed something, thanks for pointing it out.
Alan
[...] Virtual-Al (Alan) – Better coverage on the new cmdlets in PowerCLI 4.0 U1 [...]
[...] the PowerCLI has been updated, and can be found here. There are 68 new CMDLETS, which Alan Renouf does a great job of explaining. I’m especially looking forward to trying out GetSet-CustomAttribute (no more manipulation [...]
[...] Alan Renouf also gives his initial impressions on the release here. [...]
I’ve tried this script, a modified version of yours:
Get-VMHost | Select name,
@{N=”Mem.Usage.Average”;E={(get-stat -entity $_ -Start ((Get-Date).AddDays(-30)) -Finish (Get-Date) -stat mem.usage.average -intervalmins 5 -MaxSamples 1).Value}},
@{N=”Mem.Usage.Maximum”;E={(get-stat -entity $_ -Start ((Get-Date).AddDays(-30)) -Finish (Get-Date) -stat mem.usage.maximum -intervalmins 5 -MaxSamples 1).Value}},
@{N=”Cpu.Usage.Average”;E={(get-stat -entity $_ -Start ((Get-Date).AddDays(-30)) -Finish (Get-Date) -stat cpu.usage.average -intervalmins 5 -MaxSamples 1).Value}},
@{N=”Cpu.Usage.Maximum”;E={(get-stat -entity $_ -Start ((Get-Date).AddDays(-30)) -Finish (Get-Date) -stat cpu.usage.maximum -intervalmins 5 -MaxSamples 1).Value}} |Export-Csv c:\stats.csv
I want to get the maximum cpu usage of the last 30 days, but nothing happens, only the average numbers occur in the stats.csv.
What am I doing wrong?