• ×
    Information
    Windows update impacting certain printer icons and names. Microsoft is working on a solution.
    Click here to learn more
    Information
    Need Windows 11 help?
    Check documents on compatibility, FAQs, upgrade information and available fixes.
    Windows 11 Support Center.
  • post a message
  • ×
    Information
    Windows update impacting certain printer icons and names. Microsoft is working on a solution.
    Click here to learn more
    Information
    Need Windows 11 help?
    Check documents on compatibility, FAQs, upgrade information and available fixes.
    Windows 11 Support Center.
  • post a message
Guidelines
The HP Community is where owners of HP products, like you, volunteer to help each other find solutions.
HP Recommended

Dear Community,

I'm trying to implement a support PowerShell script to reboot a Poly Studio device using the REST API. Based from some forum threads (e.g. https://community.polycom.com/t5/VoIP-SIP-Phones/FAQ-REST-API/td-p/98914) and the Poly REST API Reference Guide I forged following script to call a reboot of a certain device using a Basic Auth.

 

#Credentials

$username = "admin"
$password = "******************" | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($username,$password)


#Certificate and TLS settings
Add-Type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
    ServicePoint srvPoint, X509Certificate certificate,
    WebRequest request, int certificateProblem) {
        return true;
    }
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

# Set Tls versions
$allProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $allProtocols


#Body for REST API call
$body = @"
{
 `"action`": `"reboot`"
}
"@


#Invoke REST command

Invoke-RestMethod -Uri "https://IP_OF_THE_POLY_DEVICE/rest/system/reboot" -Credential $cred  -Method Post -ContentType "application/json" -Body $body  

 

 

But running the script brings a 403 Error:

 

"Invoke-RestMethod :
Status page
Forbidden
The server understood the request, but is refusing to fulfill it
You can get technical details here.
Please continue your visit at our home page.
In Zeile:31 Zeichen:2
+ Invoke-RestMethod -Uri "https://xxx.xxx.xxx.xxx/rest/system/reboot" -Cre ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"

 

I have no clue how to successfully authenticate to the device with the admin credentials of the Poly Studio and then perform the reboot command. Has anyone an idea what I am missing here? Any help is greatly appreciated.

 

Kind Regards,

Torsten

3 REPLIES 3
HP Recommended

Hello @CyPh3R ,

 

Welcome back to the Poly Community.

Both the communities Must Read First or Read 1st and if available the FAQ reference the basic minimum information a new or follow up post should contain.

This ensures the questions having to be asked are limited and any new or follow up post contains the right amount of details to ensure any voluntary participant within the community does not spend additional time chasing basic information.


Unfortunately, your post fell a bit short of the above-explained requirements and we kindly ask you, therefore, to ensure to read these sections and ensure a reply (not Edit!) provides as much detail as possible

 

Statting the above please ensure you check:

 

May 19, 2020 Question: Does a Poly G7500 or Studio X50/X30 support REST API?
Resolution: Details on this can be found in the Poly VideoOS REST API Reference Guide >here< (or search the Support Page for the latest) or for instructions check >here<

 

Another community member also posted this >here<


Please ensure to provide some feedback if this reply has helped you so other users can profit from your experience.

Best Regards

Steffen Baier

 

------------------------------------------------
Notice: I am an HP Poly employee but all replies within the community are done as a volunteer outside of my day role. This community forum is not an official HP Poly support resource, thus responses from HP Poly employees, partners, and customers alike are best-effort in attempts to share learned knowledge.
If you need immediate and/or official assistance for former Poly\Plantronics\Polycom please open a service ticket through your support channels
For HP products please check HP Support.

Please also ensure you always check the General VoIP , Video Endpoint , UC Platform (Microsoft) , PSTN
HP Recommended

Hello @SteffenBaierUK,

thank you for your reply. It looks like my searching and finding skills are not as good as yours, since I was not able to find the thread you mentioned. BUT, this thread was a full hit to guide me into the right direction! 🙂

 

Using curl with the "cookies.txt "to connect and reboot the device did the job. I even adapted this method into a little PowerShell script. So for other users who may have the same question in the future, maybe this will help:

 

 

#Set variables fur Curl
$CurlEXE            = 'C:\Windows\System32\curl.exe'

$CurlArgument_logon = '-b', 'c:\temp\cookies_my_poly_device.txt',
                      '-c', 'c:\temp\cookies_my_poly_device.txt',
                      '-d', '{\"user\": \"admin\",\"password\": \"123\"}',
                      '-H', 'Content-Type: application/json',
                      '-k', 'https://10.20.30.44/rest/session'


$CurlArgumentReboot = '-b', 'c:\temp\cookies_my_poly_device.txt',
                      '-c', 'c:\temp\cookies_my_poly_device.txt',
                      '-H', 'Content-Type: application/json',
                      '-k', 'https://10.20.30.40/rest/system/reboot',
                      '-d', '{\"action\": \"reboot\"}'
                

#Logon and reboot device
& $CurlEXE @CurlArgument_logon
& $CurlEXE @CurlArgumentReboot

 

Thank you very much for the hint!

 

Kind Regards,

Torsten

 

HP Recommended

Hello @CyPh3R ,

 

there is already a working Power Shell script >here<

 

Please ensure to provide some feedback if this reply has helped you so other users can profit from your experience.

Best Regards

Steffen Baier

------------------------------------------------
Notice: I am an HP Poly employee but all replies within the community are done as a volunteer outside of my day role. This community forum is not an official HP Poly support resource, thus responses from HP Poly employees, partners, and customers alike are best-effort in attempts to share learned knowledge.
If you need immediate and/or official assistance for former Poly\Plantronics\Polycom please open a service ticket through your support channels
For HP products please check HP Support.

Please also ensure you always check the General VoIP , Video Endpoint , UC Platform (Microsoft) , PSTN
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the <a href="https://www8.hp.com/us/en/terms-of-use.html" class="udrlinesmall">Terms of Use</a> and <a href="/t5/custom/page/page-id/hp.rulespage" class="udrlinesmall"> Rules of Participation</a>.