VMware VAMI PowerCLi module


At the beginning of this year famous VMware guru William Lam wrote excellent series of articles “Exploring new VCSA VAMI API w/PowerCLI”. Together with that he released his VAMI PowerCLi module.

Excellent technology (thanks to VMware), good job (thanks to William) and great start point for community members like me.

I have released my version of VAMI (Virtual Appliance Management Interface) PowerCLi module.


There were two reasons for the module writing: overall module improvements and new functions.

Overall module improvements

  • All functions support simultaneous connections to multiple vSphere Automation SDK servers within the same PowerCLi session. All returned objects contain Server property.
Connect-CisServer VCSA, PSC1, PSC2
  • Some functions have been converted to advanced functions to support -Verbose and -Confirm parameters.
Start-VAMIService -Name vsphere-client –Verbose
Remove-VAMIUser lamw -Verbose -Confirm:$false
  • All functions return objects only (no more Write-Host). This allows to format or export an output from any function.
Get-VAMIStorageUsed | Format-Table –AutoSize
Get-VAMIHealth | Export-Csv -NoTypeInformation .\Health.csv
  • Pipeline supported for paired functions.
Get-VAMIService vsphere-client | Stop-VAMIService
Get-Help Get-VAMITime -Online
  • Some minor changes in Param () sections. For example, Get-VAMIService now can accept multiple services in the -Name parameter.
Get-VAMIService rbd,vsphere-client
  • Added some properties to returned objects in some functions. For example, Usage% property in the Get-VAMIStorageUsed and Description in the Get-VAMIService (like you see in the Web Client).
Get-VAMIStorageUsed | Get-Member
Get-VAMIService | Get-Member -MemberType NoteProperty

New functions

  • The Restart-VAMIService function. Well, it was simple Emoj, but if we have Get-VAMIService/Start-VAMIService/Stop-VAMIService – why could not we have Restart-VAMIService? Now we have.
Get-VAMIService rbd,vsphere-client | Restart-VAMIService
  • The Get-VAMIPerformance (CPU and Memory in VAMI UI). I will consider this function in more detail.



Connect-CisServer VCSA

By default, the function returns CPU and Memory metrics for the last day and takes the samples every two hours.


This can be controlled by -Period and -Interval parameters. The parameters are positional and Intellisense is supported as well.

Get-VAMIPerformance –Period Week –Interval DAY1
Get-VAMIPerformance Day HOURS6


Sometimes you will get zero metrics. There two reasons for this: either appliance was powered off awhile or a period, specified by -Period parameter overlaps with a period before the appliance was deployed. The -ExcludeZero switch will filter these metrics out from the report.

Get-VAMIPerformance –Period Quarter -ExcludeZero


And finally you can export a long period (three month) frequent report (get samples every five minutes) and analyze it in Excel later.

Get-VAMIPerformance Quarter MINUTES5 –ExcludeZero | Export-Csv –notype .\Perf.csv

If you are familiar with the Excel, there is no problem to build some graphs.


Your manager will like it Emoj.

You may also like:

VMware VSAN PowerCLi module

31 thoughts on “VMware VAMI PowerCLi module

  1. Hi there , It that link to Github still valid ? get 404 from here and from William’s site .
    This looks VERY Promising , cant wait to dive in


      1. Thank you Sir . Do you perhaps know if there is any way to get-VAMIEvents ? I am specifically trying to put something in place for VCHA6.5 . We need to know / trap / monitor the availability and possible failover events . All I could find in this stack is I could use system uptime from your awesome Get-VAMIsummary CMDlet.


      2. The VAMI API does not allow events fetching, you can use PowerCLi Get-VIEvent cmdlet instead.
        1. Get all existing event types:

        Get-VIEvent |select @{N='EventType'; E={$_.GetType().Name}} -Unique |sort EventType

        2. Get events of desired type:

        Get-VIEvent |? {$_.GetType().Name -eq 'TaskEvent'}
        Get-VIEvent |? {'VmPoweredOnEvent', 'VmPoweredOffEvent' -contains $_.GetType().Name}
        Get-VIEvent |? {$_.GetType().Name -like 'vm*'}

        3. Returned object is [VimApi.Event] data type. You may select only properties you are interested in (| select createdTime, fullFormattedMessage)

        Get-VIEvent |? {$_.GetType().Name -eq 'TaskEvent'} | select createdTime, fullFormattedMessage

        4. Consider using -MaxSamples, -Start and -Finish parameters:

        Get-VIEvent -MaxSamples 10000 -Start "20/08/2017" -Finish "27/08/2017" |? {$_.GetType().Name -eq 'TaskEvent'} | select createdTime, fullFormattedMessage


  2. I am having difficulties running it… please help… The output is empty.

    PowerCLI C:\Users\subhatnagar\Desktop> Get-Command -Module VAMI

    CommandType Name Version Source
    ———– —- ——- ——
    Function Get-VAMIAccess VAMI
    Function Get-VAMIBackupSize VAMI
    Function Get-VAMIDisks VAMI
    Function Get-VAMIHealth VAMI
    Function Get-VAMINetwork VAMI
    Function Get-VAMIPerformance VAMI
    Function Get-VAMIService VAMI
    Function Get-VAMIStatsList VAMI
    Function Get-VAMIStorageUsed VAMI
    Function Get-VAMISummary VAMI
    Function Get-VAMITime VAMI
    Function Get-VAMIUser VAMI
    Function New-VAMIUser VAMI
    Function Remove-VAMIUser VAMI
    Function Restart-VAMIService VAMI
    Function Start-VAMIDiskResize VAMI
    Function Start-VAMIService VAMI
    Function Stop-VAMIService VAMI

    PowerCLI C:\Users\subhatnagar\Desktop> Get-VAMISummary
    PowerCLI C:\Users\subhatnagar\Desktop>


      1. Disconnect from all your VC and check you are disconnected:

        Disconnect-CisServer -Server * -Force -Confirm:$false

        Try to execute this code against a VC that you just have restarted:

        Connect-CisServer $VC
        (Get-CisService -Name 'com.vmware.appliance.system.version' -Server $VC).get()


  3. I tried breaking the module..


    Function Get-VAMISummary
    $ErrorActionPreference = ‘Stop’
    foreach ($Server in ($global:DefaultCisServers | ? { $_.IsConnected }))
    $SystemVersionAPI = Get-CisService -Name ‘com.vmware.appliance.system.version’ -Server $Server
    $results = $SystemVersionAPI.get() | select product, ‘type’, version, build, install_time

    $SystemUptimeAPI = Get-CisService -Name ‘com.vmware.appliance.system.uptime’ -Server $Server
    $ts = [timespan]::FromSeconds($SystemUptimeAPI.get().ToString())
    $uptime = $ts.ToString(“dd\ \D\a\y\s\,\ hh\:mm\:ss”)

    $SummaryResult = [pscustomobject] @{
    Server = $Server.Name
    Product = $results.product
    Type = $results.type
    Version = $results.version
    Build = $results.build
    InstallDate = ([datetime]($results.install_time -replace ‘[a-zA-Z]’, ‘ ‘)).ToLocalTime().ToString()
    Uptime = $uptime
    Catch { }

    } #EndFunction Get-VAMISummary

    Saved the above function to Get-VAMISummary.ps1 and saved it as ps1.

    PowerCLI C:\Users\subhatnagar\Desktop> import-module .\Get-VAMISummary.ps1
    PowerCLI C:\Users\subhatnagar\Desktop> Get-VAMISummary

    And still nothing… And if I break it then I see this error..

    PowerCLI C:\Users\subhatnagar\Desktop> $SystemVersionAPI = Get-CisService -Name ‘com.vmware.appliance.system.version’ -Server $Server
    PowerCLI C:\Users\subhatnagar\Desktop> $results = $SystemVersionAPI.get() | select product, ‘type’, version, build, install_time
    A server error occurred: ‘com.vmware.vapi.std.errors.unauthorized’: Unable to authorize user (Server error id: ‘vapi.security.authorization.invalid’). Check $Error[0].Exception.ServerError for
    more details.
    At line:1 char:1
    + $results = $SystemVersionAPI.get() | select product, ‘type’, version, …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (:) [], CisServerException
    + FullyQualifiedErrorId : VMware.VimAutomation.Cis.Core.Types.V1.CisServerException


  4. Here is output….

    PowerCLI C:\> (Get-CisService -Name ‘com.vmware.appliance.system.version’ -Server $VC).get()
    A server error occurred: ‘com.vmware.vapi.std.errors.unauthorized’: Unable to authorize user (Server error id: ‘vapi.security.authorization.invalid’). Check $Error[0].Exception.ServerError for more details.
    At line:1 char:1
    + (Get-CisService -Name ‘com.vmware.appliance.system.version’ -Server $ …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (:) [], CisServerException
    + FullyQualifiedErrorId : VMware.VimAutomation.Cis.Core.Types.V1.CisServerException

    PowerCLI C:\>


      1. PowerCLI version is 6.5 Release 1 build 4624819.
        We have an external PSC on all our 6.5 appliances.
        I am able to run all PowerCLI commands after using Connect-viserver but these functions are not working. 😦


      2. The Connect-VIServer is differ from Connect-CisServer cmdlet and there is no releations between them.
        Did you try to connect to the PSC with Connect-CisServer?


      3. 1. Sorry, but you have VAMI API’s related issue and it is not related to my module at all.

        The following command’s failure proves this statement:

        Connect-CisServer $VC
        (Get-CisService -Name 'com.vmware.appliance.system.version' -Server $VC).get()

        2. Your environment (Windows version of PowerCLi 6.5 R1, VCSA 6.5 and vSphere 6.5) fit to all requirements and MUST be fully supported by VMware.

        3. I think you may open SR on this issue in the GSS.

        I will be grateful if you keep me updated.
        Good luck!


  5. Couple Questions:
    1. Are you planning on updating the vamiversion to account for the new version of VCSA – I run the command get-vamisummary and nothing is displayed. I believe that is because I have a version not accounted for in switch section of code.
    2. Not sure if this is related to the version that I have but when I run Get-VAMIStorageUsed the results are zero.


    1. The switch section of the Get-VAMISummary function is intended to build two backup expiration related properties: BackupExpireDate and DaysToExpire and I try to keep them updated ASAP (please see the function versions 1.2 and 1.3).

      Get-Help Get-VAMISummary -Full

      No output from any function of the VAMI module can point to the API related issue, already discussed with one of my readers Sunny Bhatnagar in above comments.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s