Nutanix 4.0 PowerShell goes GA

· 4 min read

One of the big new things for workflows and automation in Nutanix NOS 4.0 are the PowerShell cmdlets to interact with the Nutanix API’s. The POSH library covers the entire extent and functionality of the Nutanix platform and graphical user interface. In other others, anything that can be done via GUI can also be done via REST API and can also be done via POSH; including Alerts, Authentication, Backup and Disaster Recovery, Clusters, Containers, Disks, VM and Host, Remote Sites, Multi-Cluster, Storage Pools, SNMP etc.

A little while ago I published an article introducing the Beta version of the Nutanix Powershell API. Few people from the community came back to us asking for POSH Standards and to avoid conflicts with other POSH modules such as VMware PowerCLI. We heard you!! The GA release addresses most of the concerns and recommendations, if not all.

The Powershell installer can be easily downloaded PRISM under Admin options and it will need Powershell 2.0+ and .NET 4.0 installed on the computer running the commands. The command may be manually executed or via Powershell scripts with pipelining support.

(Click to Enlarge)

 

This article is just an introduction to Nutanix Powershell. In future articles I will select and explain specific cmdlets. In the meantime, to get help descriptions just use: Get-Help

The example below demonstrates how to establish a connection to a Nutanix cluster.

 

Here is another example of retrieving a Nutanix container.

powershell_containers_example

 

Below you will find the full list with all cmdlets supported with Nutanix. To generate this list just use the following command: get-module | ForEach-Object {Get-Command -Module $_} | ForEach-Object {$_.Name}

 

NameModuleName
Connect-NutanixClusterCommon
Disconnect-NutanixClusterCommon
Get-NutanixClusterCommon
Get-NutanixCmdletsInfoCommon
Acknowledge-NTNXAlertAlertsAdministration
Get-NTNXAlertAlertsAdministration
Get-NTNXAlertMetadataAlertsAdministration
Get-NTNXHardwareAlertAlertsAdministration
Get-NTNXStorageAlertAlertsAdministration
Resolve-NTNXAlertAlertsAdministration
Set-NTNXAlertMetadataAlertsAdministration
Add-NTNXAuthConfigDirectoryAuthConfigAdministration
Add-NTNXAuthTypeAuthConfigAdministration
Get-NTNXAuthConfigAuthConfigAdministration
Get-NTNXAuthConfigDirectoryAuthConfigAdministration
Get-NTNXAuthTypeAuthConfigAdministration
Get-NTNXClientAuthStateAuthConfigAdministration
Remove-NTNXAuthConfigAuthConfigAdministration
Remove-NTNXAuthConfigDirectoryAuthConfigAdministration
Remove-NTNXAuthTypeAuthConfigAdministration
Set-NTNXAuthConfigAuthConfigAdministration
Set-NTNXAuthConfigDirectoryAuthConfigAdministration
Set-NTNXAuthTypeAuthConfigAdministration
Set-NTNXClientAuthStateAuthConfigAdministration
Abort-NTNXProtectionDomainReplicationBackupAndDrAdministration
Add-NTNXOutOfBandScheduleBackupAndDrAdministration
Add-NTNXProtectionDomainCronScheduleBackupAndDrAdministration
Add-NTNXProtectionDomainVMBackupAndDrAdministration
Clear-NTNXCronScheduleBackupAndDrAdministration
Clear-NTNXProtectionDomainRetentionPolicyBackupAndDrAdministration
Get-NTNXOutOfBandScheduleBackupAndDrAdministration
Get-NTNXProtectionDomainBackupAndDrAdministration
Get-NTNXProtectionDomainAlertBackupAndDrAdministration
Get-NTNXProtectionDomainConsistencyGroupBackupAndDrAdministration
Get-NTNXProtectionDomainCronScheduleBackupAndDrAdministration
Get-NTNXProtectionDomainEventBackupAndDrAdministration
Get-NTNXProtectionDomainHealthCheckSummaryBackupAndDrAdministration
Get-NTNXProtectionDomainPendingActionBackupAndDrAdministration
Get-NTNXProtectionDomainPendingReplicationBackupAndDrAdministration
Get-NTNXProtectionDomainReplicationBackupAndDrAdministration
Get-NTNXProtectionDomainSnapshotBackupAndDrAdministration
Get-NTNXProtectionDomainStatBackupAndDrAdministration
Get-NTNXUnprotectedVmBackupAndDrAdministration
Mark-NTNXProtectionDomainActiveBackupAndDrAdministration
Mark-NTNXProtectionDomainForRemovalBackupAndDrAdministration
Mark-NTNXProtectionDomainInactiveBackupAndDrAdministration
Migrate-NTNXProtectionDomainBackupAndDrAdministration
New-NTNXProtectionDomainBackupAndDrAdministration
Remove-NTNXOutOfBandScheduleBackupAndDrAdministration
Remove-NTNXProtectionDomainCronScheduleBackupAndDrAdministration
Remove-NTNXProtectionDomainSnapshotBackupAndDrAdministration
Remove-NTNXProtectionDomainVMBackupAndDrAdministration
Replace-NTNXProtectionDomainCronScheduleBackupAndDrAdministration
Restore-NTNXEntityBackupAndDrAdministration
Rollback-NTNXProtectionDomainBackupAndDrAdministration
Set-NTNXProtectionDomainReplicationBackupAndDrAdministration
Set-NTNXProtectionDomainRetentionPolicyBackupAndDrAdministration
Set-NTNXProtectionDomainSnapshotBackupAndDrAdministration
Add-NTNXEmailAlertContactClusterAdministration
Add-NTNXNameServerClusterAdministration
Add-NTNXNfsSubnetWhitelistClusterAdministration
Add-NTNXNtpServerClusterAdministration
Add-NTNXPublicKeyClusterAdministration
Get-NTNXClusterInfoClusterAdministration
Get-NTNXClusterStatClusterAdministration
Get-NTNXEmailAlertContactClusterAdministration
Get-NTNXEmailAlertSettingClusterAdministration
Get-NTNXNameServerClusterAdministration
Get-NTNXNfsSubnetWhitelistClusterAdministration
Get-NTNXNtpServerClusterAdministration
Get-NTNXPublicKeyClusterAdministration
Get-NTNXRackableUnitClusterAdministration
Get-NTNXRemoteSupportSettingClusterAdministration
Get-NTNXSmtpServerClusterAdministration
Get-NTNXSmtpServerSecurityModeTypeClusterAdministration
Get-NTNXSpotlightSearchResultClusterAdministration
Remove-NTNXEmailAlertContactClusterAdministration
Remove-NTNXNameServerClusterAdministration
Remove-NTNXNfsSubnetWhitelistClusterAdministration
Remove-NTNXNtpServerClusterAdministration
Remove-NTNXPublicKeyClusterAdministration
Remove-NTNXRackableUnitClusterAdministration
Remove-NTNXSmtpServerClusterAdministration
Send-NTNXEmailUsingSmtpServerClusterAdministration
Set-NTNXClusterClusterAdministration
Set-NTNXClusterDomainClusterAdministration
Set-NTNXEmailAlertSettingClusterAdministration
Set-NTNXRemoteSupportSettingClusterAdministration
Set-NTNXSmtpServerClusterAdministration
Get-NTNXClusterClustersDataQuery
Get-NTNXMultiClusterAlertClustersDataQuery
Get-NTNXMultiClusterEventClustersDataQuery
Get-NTNXMultiClusterStatClustersDataQuery
Add-NTNXNfsDatastoreContainerAdministration
Get-NTNXContainerContainerAdministration
Get-NTNXContainerAlertContainerAdministration
Get-NTNXContainerEventContainerAdministration
Get-NTNXContainerStatContainerAdministration
Get-NTNXContainerVDiskContainerAdministration
Get-NTNXNfsDatastoreContainerAdministration
New-NTNXContainerContainerAdministration
Remove-NTNXContainerContainerAdministration
Remove-NTNXNfsDatastoreContainerAdministration
Set-NTNXContainerContainerAdministration
Get-NTNXDiskDiskAdministration
Get-NTNXDiskAlertDiskAdministration
Get-NTNXDiskEventDiskAdministration
Get-NTNXDiskHealthCheckSummaryDiskAdministration
Get-NTNXDiskStatDiskAdministration
Remove-NTNXDiskDiskAdministration
Acknowledge-NTNXEventEventsAdministration
Get-NTNXEventEventsAdministration
Get-NTNXHardwareEventEventsAdministration
Get-NTNXStorageEventEventsAdministration
Get-NTNXHealthCheckHealthCheckAdministration
Set-NTNXHealthCheckHealthCheckAdministration
Get-NTNXHostHostAdministration
Get-NTNXHostAlertHostAdministration
Get-NTNXHostEventHostAdministration
Get-NTNXHostHealthCheckSummaryHostAdministration
Get-NTNXHostStatHostAdministration
Get-NTNXHttpProxyHttpProxyAdministration
New-NTNXHttpProxyHttpProxyAdministration
Remove-NTNXHttpProxyHttpProxyAdministration
Set-NTNXHttpProxyHttpProxyAdministration
Get-NTNXClusterLicenseInfoLicenseAdministration
Get-NTNXLicenseLicenseAdministration
Get-NTNXLicenseAllowanceLicenseAdministration
Get-NTNXRemoteSiteRemoteSiteAdministration
Get-NTNXRemoteSiteAlertRemoteSiteAdministration
Get-NTNXRemoteSiteEventRemoteSiteAdministration
Get-NTNXRemoteSiteHealthCheckSummaryRemoteSiteAdministration
Get-NTNXRemoteSitePendingReplicationRemoteSiteAdministration
Get-NTNXRemoteSiteSnapshotRemoteSiteAdministration
Get-NTNXRemoteSiteStatRemoteSiteAdministration
Mark-NTNXRemoteSiteForRemovalRemoteSiteAdministration
New-NTNXRemoteSiteRemoteSiteAdministration
Set-NTNXRemoteSiteRemoteSiteAdministration
Get-NTNXServiceCenterServiceCenterAdministration
New-NTNXServiceCenterServiceCenterAdministration
Remove-NTNXServiceCenterServiceCenterAdministration
Set-NTNXServiceCenterServiceCenterAdministration
Add-NTNXSnmpTransportSnmpAdministration
Add-NTNXSnmpTrapSnmpAdministration
Add-NTNXSnmpUserSnmpAdministration
Get-NTNXSnmpInfoSnmpAdministration
Get-NTNXSnmpStatusSnmpAdministration
Get-NTNXSnmpTransportSnmpAdministration
Get-NTNXSnmpTrapSnmpAdministration
Get-NTNXSnmpUserSnmpAdministration
Remove-NTNXSnmpTransportSnmpAdministration
Remove-NTNXSnmpTrapSnmpAdministration
Remove-NTNXSnmpUserSnmpAdministration
Set-NTNXSnmpStatusSnmpAdministration
Set-NTNXSnmpTrapSnmpAdministration
Set-NTNXSnmpUserSnmpAdministration
Get-NTNXStoragePoolStoragePoolAdministration
Get-NTNXStoragePoolAlertStoragePoolAdministration
Get-NTNXStoragePoolEventStoragePoolAdministration
Get-NTNXStoragePoolStatStoragePoolAdministration
New-NTNXStoragePoolStoragePoolAdministration
Remove-NTNXStoragePoolStoragePoolAdministration
Set-NTNXStoragePoolStoragePoolAdministration
Get-NTNXSnapshotForVDiskVDiskAdministration
Get-NTNXVDiskVDiskAdministration
Get-NTNXVDiskAlertVDiskAdministration
Get-NTNXVDiskEventVDiskAdministration
Get-NTNXVDiskSnapshotVDiskAdministration
Get-NTNXVDiskStatVDiskAdministration
New-NTNXVDiskVDiskAdministration
New-NTNXVDiskSnapshotVDiskAdministration
Remove-NTNXVDiskVDiskAdministration
Set-NTNXVDiskVDiskAdministration
Get-NTNXVirtualDiskVirtualDiskAdministration
Get-NTNXVirtualDiskStatVirtualDiskAdministration
Get-NTNXVMVMAdministration
Get-NTNXVMAlertVMAdministration
Get-NTNXVMEventVMAdministration
Get-NTNXVMHealthCheckSummaryVMAdministration
Get-NTNXVMStatVMAdministration
Get-NTNXVMVDiskVMAdministration
Get-NTNXVMVirtualDiskVMAdministration
Get-NTNXVStoreVStoreAdministration
Protect-NTNXVStoreVStoreAdministration
UnProtect-NTNXVStoreVStoreAdministration

 

This article was first published by Andre Leibovici (@andreleibovici) at myvirtualcloud.net

storagevirtualization

NutanixPowerCLIpowershellstorage

11 comments

Aleksandar

I'm pretty sure that provided command cannot produce that output. :(

Bjorn Houben

Why are the first commands using nutanix instead of ntnx? Otherwise you could just use: Get-Command *ntnx*

Andre Leibovici

Yes, 'Get-Command *ntnx*' will work.

I pasted a command-line I used for the Beta version that did not have NTNX in the name.
If you still want to use the original command-lie, add $_.ModuleName

'get-module | ForEach-Object {Get-Command -Module $_} | ForEach-Object {$_.Name,$_.ModuleName}'

Aleksandar

That command doesn't work either.
First, Get-Module returns all imported modules. That's not what you want, right?

If all commands had the same prefix (which they don't right now):

Get-Command -Noun NTNX* | Format-Table Name,ModuleName

Andre Leibovici

I just tested in my machine and it works for me. What error or output do you get?
get-module | ForEach-Object {Get-Command -Module $_} | ForEach-Object {$_.Name,$_.ModuleName}

Aleksandar

Here is partial output in freshly started PowerShell session:

PS C:\> get-module | ForEach-Object {Get-Command -Module $_} | ForEach-Object {$_.Name,$_.ModuleName}
Get-IseSnippet
ISE
Import-IseSnippet
ISE
New-IseSnippet
ISE
Add-Computer
Microsoft.PowerShell.Management
Add-Content
Microsoft.PowerShell.Management
Checkpoint-Computer
Microsoft.PowerShell.Management

I really don't understand how can you get info only about Nutinix cmdlets when you don't filter based on their names or module.

Andre Leibovici

Did you load the Nutanix Powershell cmdlets?
Have you got NOS 4.0 running in your environment?

Aleksandar

No, I don't have them installed on my computer. However, that doesn't change anything. I'm just looking at your command and don't understand how can you get output about Nutanix cmdlets only.

Andre Leibovici

Aleksandar, it doesn't only return Nutanix cmdlets. I have cleaned up what is not Nutanix to posts here on the blog.

James Birley (@jbirley)

Guys I think I can clear up some confusion, hopefully. :-)

They way Nutanix decided to implement POSH support involves providing a desktop shortcut that launches a batch file to start a new powershell host session. (Similar to PowerCLI). It then runs a set of nested POSH scripts that, among other things like checking some prerequisites, imports all of the Nutanix modules. (There are 21 based on my count).

By like most POSH scripters, I prefer to have all of my modules, both third party and my own, in my existing powershell host configuration. Usually, I add these import steps to my profile. However, it turns out that Nutanix modifies the cmdlet names on import using the –prefix parameter of the ‘Import-Module’ cmdlet. So the snippets of their code look like this:

[string] $nounPrefix = "NTNX"
Import-Module $currFile -WarningAction silentlyContinue -Prefix $nounPrefix

Just before they loop through importing all their modules, they import one set of cmdlets which they consider “common” first that they do NOT put the “NTNX” on.
So to get all of the Nutanix related cmdlets in their “custom” POSH session, you could run the following command:

gcm | ? implementingtype -like "Nutanix*" | ft Name,Modulename

Again, I prefer to import modules in my profile, so I added these two lines which do the trick.

Import-Module "C:\Program Files (x86)\Nutanix Inc\NutanixCmdlets\Modules\Common\Common.dll"
Get-ChildItem -Path 'C:\Program Files (x86)\Nutanix Inc\NutanixCmdlets\Modules' *.dll -recurse | ForEach-Object {Import-Module -Name $_.FullName -WarningAction silentlyContinue -Prefix "NTNX"}

It imports the common module twice, but the second time it modifies it with the “NTNX” prefix. Then as Bjorn and Alexandar mention, you can simply run Get-Command *ntnx* (I get 193 cmdlets).

My request is for Nutanix to fix the cmdlet naming convention natively and to consolidate the modules if possible.

Andre Leibovici

James, that a great feedback and thank you for providing your POSH profile configuration. I'm pointing the engineers to your request.

-Andre

Comments are preserved from the original site and are closed.