Public/Connect-PrismServer.ps1
<#
.DESCRIPTION Wrapper for Nutanix API version 0.3. .NOTES Author: Timothy Rasiah #> function Connect-PrismServer { [CmdletBinding()] param ( [Parameter(Mandatory=$true)] [String]$Server, [Int]$Port = 9440, [Parameter(Mandatory=$true)] [PSCredential]$Credential ) $Domain = $Credential.GetNetworkCredential().Domain $Username = $Credential.GetNetworkCredential().UserName $Password = $Credential.GetNetworkCredential().Password # https://www.nutanix.dev/reference/prism_central/v3/authentication # create the HTTP Basic Authorization header $pair = $Username + ":" + $Password $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $base64 = [System.Convert]::ToBase64String($bytes) $basicAuthValue = "Basic $base64" $Global:DefaultNutanixV3Connection = @() $Global:DefaultNutanixV3Connection += [PrismSession]@{ "BaseUrl" = "https://$($Server):$($Port)/api/nutanix/v3" "BasicAuth" = "$($basicAuthValue)" } } |