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 Get-VAMISummary
- 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
- The
Get-Help
with-Online
parameter navigates to appropriate article in the http://www.virtuallyghetto.com.
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 theGet-VAMIStorageUsed
andDescription
in theGet-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 , but if we haveGet-VAMIService
/Start-VAMIService
/Stop-VAMIService
– why could not we haveRestart-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.
Get-VAMIPerformance
Connect-CisServer VCSA Get-VAMIPerformance
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 .
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
LikeLike
Still valid, of course.
https://github.com/rgel/PowerCLi/tree/master/VAMI
LikeLike
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.
LikeLike
The VAMI API does not allow events fetching, you can use PowerCLi Get-VIEvent cmdlet instead.
1. Get all existing event types:
2. Get events of desired type:
3. Returned object is [VimApi.Event] data type. You may select only properties you are interested in (| select createdTime, fullFormattedMessage)
4. Consider using -MaxSamples, -Start and -Finish parameters:
LikeLike
Thank you very much , did not think get-ViEvent will work here .
Great information !
LikeLike
You’re welcome. You’ll only need to determine event type, related to HA failover.
LikeLike
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 1.0.0.0 VAMI
Function Get-VAMIBackupSize 1.0.0.0 VAMI
Function Get-VAMIDisks 1.0.0.0 VAMI
Function Get-VAMIHealth 1.0.0.0 VAMI
Function Get-VAMINetwork 1.0.0.0 VAMI
Function Get-VAMIPerformance 1.0.0.0 VAMI
Function Get-VAMIService 1.0.0.0 VAMI
Function Get-VAMIStatsList 1.0.0.0 VAMI
Function Get-VAMIStorageUsed 1.0.0.0 VAMI
Function Get-VAMISummary 1.0.0.0 VAMI
Function Get-VAMITime 1.0.0.0 VAMI
Function Get-VAMIUser 1.0.0.0 VAMI
Function New-VAMIUser 1.0.0.0 VAMI
Function Remove-VAMIUser 1.0.0.0 VAMI
Function Restart-VAMIService 1.0.0.0 VAMI
Function Start-VAMIDiskResize 1.0.0.0 VAMI
Function Start-VAMIService 1.0.0.0 VAMI
Function Stop-VAMIService 1.0.0.0 VAMI
PowerCLI C:\Users\subhatnagar\Desktop> Get-VAMISummary
PowerCLI C:\Users\subhatnagar\Desktop>
LikeLike
You are not connected to your VC.
Use
Connect-CisServer $VC
to connect first.LikeLike
now I am connected to them… here it is…
PowerCLI C:\Users\subhatnagar\Desktop> $global:DefaultCisServers
Name User Port
—- —- —-
server1 subhatnagar@xvz.COM 443
server2 subhatnagar@xyz.COM 443
LikeLike
And still have no output from any cmdlet ?
LikeLike
Yeah 😦
LikeLike
Try to restart one of your VC if it is possible, this might help.
LikeLike
I tried it on multiple vCenters and its the same. No output at all.
LikeLike
Disconnect from all your VC and check you are disconnected:
Try to execute this code against a VC that you just have restarted:
LikeLike
I tried breaking the module..
“””
Function Get-VAMISummary
{
$ErrorActionPreference = ‘Stop’
foreach ($Server in ($global:DefaultCisServers | ? { $_.IsConnected }))
{
Try
{
$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
}
$SummaryResult
}
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
LikeLike
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:\>
LikeLike
If you have embedded PSC, probably you have not enough permissions on this VC or there is some network related issue
LikeLike
Forgot to ask you, what is your PowerCLi version?
LikeLike
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. 😦
LikeLike
The
Connect-VIServer
is differ fromConnect-CisServer
cmdlet and there is no releations between them.Did you try to connect to the PSC with
Connect-CisServer
?LikeLike
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:
2. Your environment (Windows version of
PowerCLi 6.5 R1
,VCSA 6.5
andvSphere 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!
LikeLike
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.
LikeLike
The
switch
section of theGet-VAMISummary
function is intended to build two backup expiration related properties:BackupExpireDate
andDaysToExpire
and I try to keep them updated ASAP (please see the function versions 1.2 and 1.3).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.LikeLike