Public/Get-AvdHostPool.ps1
function Get-AvdHostPool { <# .SYNOPSIS Get AVD Hostpool information. .DESCRIPTION With this function you can get information about an AVD hostpool. .PARAMETER HostPoolName Enter the name of the hostpool you want information from. .PARAMETER ResourceGroupName Enter the name of the resourcegroup where the hostpool resides in. .EXAMPLE Get-AvdHostPool -HostPoolName avd-hostpool-001 -ResourceGroupName rg-avd-001 .EXAMPLE Get-AvdHostPool -ResourceId "/subscription/../HostPoolName" #> [CmdletBinding(DefaultParameterSetName = "Name")] param ( [Parameter(Mandatory, ParameterSetName = "Name")] [ValidateNotNullOrEmpty()] [string]$HostPoolName, [Parameter(Mandatory, ParameterSetName = "Name")] [ValidateNotNullOrEmpty()] [string]$ResourceGroupName, [Parameter(Mandatory, ParameterSetName = "ResourceId")] [ValidateNotNullOrEmpty()] [string]$resourceId ) Begin { Write-Verbose "Start searching for hostpool $hostpoolName" AuthenticationCheck $token = GetAuthToken -resource $script:AzureApiUrl $apiVersion = "?api-version=2019-12-10-preview" switch ($PsCmdlet.ParameterSetName) { Name { Write-Verbose "Name and ResourceGroup provided" $url = $script:AzureApiUrl + "/subscriptions/" + $script:subscriptionId + "/resourceGroups/" + $ResourceGroupName + "/providers/Microsoft.DesktopVirtualization/hostpools/" + $HostpoolName + $apiVersion } ResourceId { Write-Verbose "ResourceId provided" $url = $script:AzureApiUrl + $resourceId + $apiVersion } } $parameters = @{ uri = $url Headers = $token } } Process { $parameters = @{ uri = $url Method = "GET" Headers = $token } $results = Invoke-RestMethod @parameters return $results } End {} } |