Public/Get-TVDeviceInfoFromAlias.ps1
function Get-TVDeviceInfoFromAlias { [CmdletBinding(ConfirmImpact = 'Medium', PositionalBinding = $false, SupportsPaging = $true, SupportsShouldProcess = $true)] param ( [Parameter(Mandatory = $true)] $alias ) $Method = "GET" $Uri = "https://webapi.teamviewer.com/api/v1/devices?full_list=true" Write-Host "[$Method] RestMethod: [$Uri]" -ForegroundColor Yellow Try { $Device = Invoke-RestMethod -Uri $Uri -Method $Method -Headers $header -ContentType $ContentType -Verbose -ErrorVariable TVError -ErrorAction SilentlyContinue $DeviceInformation = $Device.devices | Where-Object { $_.alias -like "*$alias*" } $DeviceInformation } Catch { $JsonError = $TVError.Message | ConvertFrom-Json $HttpResponse = $TVError.ErrorRecord.Exception.Response Write-Host "Error: $($JsonError.error) `nDescription: $($JsonError.error_description) `nErrorCode: $($JsonError.error_code) `nHttp Status Code: $($HttpResponse.StatusCode.value__) `nHttp Description: $($HttpResponse.StatusDescription)" -ForegroundColor Red } } |