From e0959054cde6143e928a41a3cae13c502468f5b5 Mon Sep 17 00:00:00 2001 From: "Yinghua Zeng [MVP]" <28437644+sandytsang@users.noreply.github.com> Date: Tue, 23 Jul 2019 19:46:36 +0300 Subject: [PATCH] Changed using InvokeRestMethod Got Invoke-Restmethod working, try it. :) --- .../AdminService/ListAdminServiceFunctions.ps1 | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/ConfigMgr/AdminService/ListAdminServiceFunctions.ps1 b/ConfigMgr/AdminService/ListAdminServiceFunctions.ps1 index ef7d1cf..5f90146 100644 --- a/ConfigMgr/AdminService/ListAdminServiceFunctions.ps1 +++ b/ConfigMgr/AdminService/ListAdminServiceFunctions.ps1 @@ -29,19 +29,11 @@ $Result.value.Name #Returns Function Names $SiteServer = "YourServerName" -[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true } -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - -$ControllerUri = "https://$($SiteServer)/AdminService/v1.0/`$metadata" +$ControllerUri = "https://$($SiteServer)/AdminService/v2.0/`$metadata" $WMIUri = "https://$($SiteServer)/AdminService/wmi/`$metadata" -$agentsquery = New-Object System.Net.WebClient -$agentsquery.Headers.Add('accept','application/xml') -$agentsquery.UseDefaultCredentials =$true - -[XML]$ControllerResults = $agentsquery.DownloadString($ControllerUri) -[XML]$WMIResults = $agentsquery.DownloadString($WMIUri) - +$ControllerResults = Invoke-RestMethod -Method Get -Uri $ControllerUri -UseDefaultCredentials +$WMIResults = Invoke-RestMethod -Method Get -Uri $WMIUri -UseDefaultCredentials #$ControllerClasses = ($ControllerResults | ConvertFrom-Json).value #$WMIClasses = ($WMIResults | ConvertFrom-Json).value