Execute PowerShell cmdlets in interactive and batch modes
PowerShell Interactive Mode (add-pssnapin)
The PowerShell Interactive Mode allows you to run individual PowerShell commands inside the PowerShell mode. View some of the PowerShell cmdlets here.
- The Add-PSSnapin command allows you to load Nutanix PowerShell cmdlets into the PowerShell environment.
- Convert the raw password to a secure string.
- This step is required because the Nutanix cmdlet Connect-NTNXCluster does not accept raw password input.
Connect to Cluster: Options
Before you can run any Nutanix related cmdlet, you need to connect to a Nutanix cluster.
To connect to a Nutanix cluster, you need to use the Connect-NutanixCluster cmdlet.
Load the Nutanix PowerShell cmdlets add-pssnapin nutanixcmdletsPSsnapin Define variables $Username = “admin” $password = “trA1ninG@” Convert plaintext password to a secure string $pwd = ConverTo-SecurString $password – AsPlainText - Force
Get-PSSnapin
PowerShell in Batch Mode (script)
- Instead of running a number of individual PowerShell commands, especially when dealing with repetitive actions, write a script instead.
- In PowerShell Batch Mode, you can execute that script directly in the PowerShell environment.