Public/Get-MoveProviderInventory.ps1
|
Function Get-MoveProviderInventory { <# .SYNOPSIS List details of the Provider configuration inventory .DESCRIPTION .NOTES Implements details in https://www.nutanix.dev/api_reference/apis/provider.html .LINK Specify a URI to a help page, this will show when Get-Help -Online is used. .EXAMPLE Get-MoveExampleSomething -Verbose Explanation of the function or its result. You can include multiple examples with additional .EXAMPLE lines #> [CmdletBinding(DefaultParameterSetName = 'ByID')] param( [Parameter(Mandatory = $false, HelpMessage = 'Move Session Name')][String]$MoveSession = 'Default', [Parameter(Mandatory = $true, HelpMessage = 'Provider ID')][String]$Id ) ## Get Session Configuration $MoveSessionConfig = $global:MoveSessions[$MoveSession] if (-not $MoveSessionConfig) { Write-Host 'MoveSession: [' -NoNewline Write-Host $MoveSession -ForegroundColor Cyan Write-Host '] was not Found. Please use the New-MoveSession command.' Throw 'Move Session Not Found. Use New-MoveSession command before using features.' } #Honor SSL Settings if ($MoveSessionConfig.AllowInsecureSSL) { $MoveCertSettings = @{SkipCertificateCheck = $true } } else { $MoveCertSettings = @{SkipCertificateCheck = $false } } $uri = "https://$($MoveSessionConfig.MoveServer):$($MoveSessionConfig.MovePort)/move/v2/providers/$Id/workloads/list" $Body = @{ # AfterOffset = 0 # BeforeOffset = 0 # Fields = @( # 'string' # ) Filter = @{ # Categories = @{ # property1 = @( # 'string' # ) # property2 = @( # 'string' # ) # } # 'Get-Cluster' = @( # 'string' # ) # 'Get-Datacenter' = @( # 'string' # ) # Host = @( # 'string' # ) # ShareUuids = @( # # 'b4d15375-1097-4c96-a4c4-4cb5809b05bb' # ) # TargetType = 'string' # VMUuids = @( # # 'b4d15375-1097-4c96-a4c4-4cb5809b05bb' # ) } Limit = 0 # Query = 'string' RefreshInventory = $false ShowVMS = 'all' SortBy = 'VMName' SortOrderDesc = $true # UpdateInventoryToPlans = $true } try { $RestMethodSplat = @{ Uri = $uri TimeoutSec = 100 Method = 'POST' WebSession = $MoveSessionConfig.MoveWebSession ProgressAction = 'SilentlyContinue' Body = $Body | ConvertTo-Json -Depth 10 -Compress } $Result = Invoke-RestMethod @RestMethodSplat @MoveCertSettings } catch { throw $_.Exception.Message } return $Result } |