• ×
    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

Hello Steffen,

 

I am trying to use the REST API and PowerShell to execute a reboot command against a G7500.  Your CURL examples work, and I have tried to adapt the Trio examples but keep getting errors.  Can you help point me in the right direction?  This is important for us as we have over 100 of these systems deployed and are looking to script out management.  Thanks!

$body = "{`"action`": `"reboot`"}";

$password = "mypassword" | ConvertTo-SecureString -AsPlainText -Force

$cred = New-Object System.Management.Automation.PSCredential("admin",$password)

$url = "https://172.1.16.232/rest/system/reboot";

Invoke-WebRequest $url -Method Post -ContentType "application/json" -Credential $cred -body $body



Invoke-WebRequest : 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.
At line:1 char:1
+ Invoke-WebRequest $url -Method Post -ContentType "application/json" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
1 ACCEPTED SOLUTION

Accepted Solutions
HP Recommended

For those looking to use PowerShell in the future, here is an adapted example for the G7500.  I do not know why the Trio REST method with a single line does not work with the G7500, as that would be more efficient (passing the $credentials in one shot).  Converting the CURL commands exactly to Invoke-WebRequest seemed fine, however.

 

#BEGIN POWERSHELL SCRIPT FOR POLY G7500 REST command
$password = "myPassword" #your password
$IP = "172.16.200.200" #IP of unit

#URL to make new session
$sessionURL = ("https://" + $IP + "/rest/session");
#Command to make new session
$sessionBody = "{`"user`": `"admin`",`"password`": `"" + $password + "`"}"

#URL to issue reboot
$rebootURL = ("https://" + $IP + "/rest/system/reboot");
#Command to issue reboot
$rebootBody = "{`"action`": `"reboot`"}"


# disable self signed certificate check
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{
$certCallback = @"
    using System;
    using System.Net;
    using System.Net.Security;
    using System.Security.Cryptography.X509Certificates;
    public class ServerCertificateValidationCallback
    {
        public static void Ignore()
        {
            if(ServicePointManager.ServerCertificateValidationCallback ==null)
            {
                ServicePointManager.ServerCertificateValidationCallback += 
                    delegate
                    (
                        Object obj, 
                        X509Certificate certificate, 
                        X509Chain chain, 
                        SslPolicyErrors errors
                    )
                    {
                        return true;
                    };
            }
        }
    }
"@
    Add-Type $certCallback
 }
[ServerCertificateValidationCallback]::Ignore()
# End self signed certificate commands

Invoke-WebRequest $sessionURL -ContentType "application/json" -Method Post -body $sessionBody -SessionVariable sess;
Invoke-WebRequest $rebootURL -ContentType "application/json" -Method Post -WebSession $sess -Body $rebootBody

  

View solution in original post

6 REPLIES 6
HP Recommended

Hello @philliplyle 

 

other community users may get put off if a question is raised to a specific user instead of a larger audience.

 

In addition, I am unable to answer all posts and cannot provide free support via the community. If an issue is urgent please work with our support team instead.

 

Looking at the REST API >here< from the Video FAQ and a reboot simply is:

curl -b cookies.txt -c cookies.txt -X POST -d "{\"user\": \"admin\",\"password\": \"123\"}" -H "Content-Type: application/json" -k https://10.252.149.104/rest/session
curl -b cookies.txt -c cookies.txt -H "Content-Type: application/JSON" -k https://10.252.149.104/rest/system/reboot -d "{\"action\": \"reboot\"}"

This is for CURL from a MS-Dos command line and not power shell as outlined in the above FAQ article.

 

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

Yes, that's why I said "I have tried to adapt your Trio PowerShell examples".


Okay, I will try the long and arduous Support process.

 

HP Recommended

Hello @philliplyle 

 

I replied to your post within 6 minutes outside of my working hours in my personal time with a working solution to reboot 1x Studio X or G7500.

 

Adopting my working solution to 100x endpoints should not take more than 10 minutes of copying and pasting the relevant IP addresses.

 

Spending a bit longer may find an easier solution but the above using CURL in an MS-DOS window or on a Linux box should not require you to contact support.

 

I doubt our support team would provide you with a script as well as this is not part of our job.

 

I created and shared my own found solution as I am an enthusiast like others and have been in situations where a customer needed to automate this for thousands of devices.

 

Please simply look at my working example 1st.

 

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

Yes, as I already wrote Steffan - "I have tried adapting your examples".  This is why I mentioned you specifically - because they are your examples.  So saying I should refer to your examples is not helpful.

 

No, they do not work on the G7500.  Why did you tell me to contact support and then now tell me that they will likely not help?  I would suggest not responding at all in the future, as your responses often have an attitude that puts off customers.

 

 

HP Recommended

 Hello @philliplyle 

 

I will respect your wishes and will never reply to another of your posts after this. Please be aware that English is not my 1st language but that should not matter regarding your offputting reply comment.

 

We are here within the Video Section.

 

The Video FAQ contains a Rest API post by myself >here< and in addition the Poly VideoOS REST API Reference Guide >here< can be consulted. This is why I refer to this post with examples as this has been tested and works.

 

You already confirmed my CURL examples work in your 1st initial post.

 

The G7500 and Studio X use a different format aka you need to get a session cookie 1st prior to communicating further to issue the reset command.

 

You have not posted any logs of using the Video FAQ G7500/Studio X Curl solution so others could comment.

 

The Poly Trio, VVX, or CCX phones use a different approach than the above that is why posted both CURL and Power Shell examples.

 

I explained the official way of getting support and in my last reply explained that support most likely will not be able to help as writing scripts is not part of our day job.

 

Poly offers many managing solutions for our different endpoints and/or our professional service team can be consulted for anything outside of this. All of this may involve a financial cost.

 

A final goodbye

 

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

For those looking to use PowerShell in the future, here is an adapted example for the G7500.  I do not know why the Trio REST method with a single line does not work with the G7500, as that would be more efficient (passing the $credentials in one shot).  Converting the CURL commands exactly to Invoke-WebRequest seemed fine, however.

 

#BEGIN POWERSHELL SCRIPT FOR POLY G7500 REST command
$password = "myPassword" #your password
$IP = "172.16.200.200" #IP of unit

#URL to make new session
$sessionURL = ("https://" + $IP + "/rest/session");
#Command to make new session
$sessionBody = "{`"user`": `"admin`",`"password`": `"" + $password + "`"}"

#URL to issue reboot
$rebootURL = ("https://" + $IP + "/rest/system/reboot");
#Command to issue reboot
$rebootBody = "{`"action`": `"reboot`"}"


# disable self signed certificate check
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{
$certCallback = @"
    using System;
    using System.Net;
    using System.Net.Security;
    using System.Security.Cryptography.X509Certificates;
    public class ServerCertificateValidationCallback
    {
        public static void Ignore()
        {
            if(ServicePointManager.ServerCertificateValidationCallback ==null)
            {
                ServicePointManager.ServerCertificateValidationCallback += 
                    delegate
                    (
                        Object obj, 
                        X509Certificate certificate, 
                        X509Chain chain, 
                        SslPolicyErrors errors
                    )
                    {
                        return true;
                    };
            }
        }
    }
"@
    Add-Type $certCallback
 }
[ServerCertificateValidationCallback]::Ignore()
# End self signed certificate commands

Invoke-WebRequest $sessionURL -ContentType "application/json" -Method Post -body $sessionBody -SessionVariable sess;
Invoke-WebRequest $rebootURL -ContentType "application/json" -Method Post -WebSession $sess -Body $rebootBody

  

† 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>.