Reply

Update MSServer Options with REST API in Powershell

[ Edited ]
New Member
Posts: 4
2426     0

Hello,

 

I want to update the options for msserver:dhcp and msserver:dns via powershell, for example login_name, login_password, synchronization_interval but it doesn't work, looks like I missed something in the options.

 

$msserver_options = @{
synchronization_interval="10"}
$body = $msserver_options | ConvertTo-Json


$uri_msdhcp = "$($ib_uri_base)/msserver:dhcp/ZG5zLm1zX3NlcnZlcl9kaGNwX3Byb3BlcnRpZXMkMA:10.0.0.1?_return_as_object=1"


Invoke-RestMethod -Uri $uri_msdhcp -Method PUT -WebSession $ib_session -ContentType 'application/json' -Body $body

Error Message

 

Invoke-RestMethod : Der Remoteserver hat einen Fehler zurückgegeben: (400) Ungültige Anforderung.
In Zeile:7 Zeichen:1
+ Invoke-RestMethod -Uri $uri_msdhcp -Method PUT -WebSession $ib_session -ContentT ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

 

the GET command works fine and give me the correct result, I also tryed to another PUT command to update the name of a fixed address which also works fine.

 

GET ms-dhcp

 

$uri_msdhcp = "$($ib_uri_base)/msserver:dhcp/ZG5zLm1zX3NlcnZlcl9kaGNwX3Byb3BlcnRpZXMkMA:10.0.0.1?_return_fields=synchronization_interval&_return_type=json"
Invoke-WebRequest -Uri $uri_msdhcp -Method Get -WebSession $ib_session

StatusCode : 200
StatusDescription : OK
Content : {"_ref": "msserver:dhcp/ZG5zLm1zX3NlcnZlcl9kaGNwX3Byb3BlcnRpZXMkMA:10.0.0.1", "synchronization_interval": 2}

 

thanks in advance

Andreas

Re: Update MSServer Options with REST API in Powershell

Adviser
Posts: 181
2426     0

Hi,

 

An integer is expected for synchronization_interval. Could you please remove the quotes around 10 and try again?

 

Thanks and regards,

Krishna

Re: Update MSServer Options with REST API in Powershell

New Member
Posts: 4
2426     0

Hi Krishna,

 

I tryed this already but get the same error message

 

$msserver_options = @{
synchronization_interval=10}
$body = $msserver_options | ConvertTo-Json

kind regards,

Andreas

 

Re: Update MSServer Options with REST API in Powershell

[ Edited ]
New Member
Posts: 4
2426     0

I tried the new NIOS version 8.4.4 with the new WAPI version v2.10.3 because new features for MS Servers are implemented (RFE-9632) but still get the same error 400.

Re: Update MSServer Options with REST API in Powershell

New Member
Posts: 2
2426     0

A whole number is normal for synchronization_interval. Would you be able to please eliminate the statements around 10 and attempt once more?

Re: Update MSServer Options with REST API in Powershell

New Member
Posts: 2
2427     0

you can check this too from more help 

192.168.100.1 192.168.1.1  jpg to pdf

Showing results for 
Search instead for 
Did you mean: 

Recommended for You