Powershell

Powershell

You can use powershell for setting up your devices, you can find on this page some example calls.

The device is session based, therefor you need to be sure that there is no active session on the device. In the first step we delete any existing session (this will stop a active document/signing process!) and generate a new session for the following communication.

 

Creating a new Session

Try{ $continue = $true while ($continue) { $device = Read-Host -Prompt "Enter the IP address or hostname of the ng device or 'Q' to finish" if ($device -eq "q") { # If the user enters 'exit', set the flag to false to exit the loop Write-Output "The tablet does not have the name configured and cannot be accessed by IP, the user has cancelled the operation." Read-Host -Prompt "Press any key to continue" Exit -1 } else { Try{ $restresponse = Invoke-WebRequest -Uri "http://$device/v1/session" -Method Delete -UseBasicParsing $restresponse = Invoke-WebRequest -Uri "http://$device/v1/session" -Method Post -UseBasicParsing if ($restresponse.StatusCode -eq 200) { $sessionId = $restresponse.Headers["Session-Id"] $continue = $false } }Catch { Write-Output " Tablet cannot be accessed through ""http://$device" Read-Host -Prompt "Press any key to end" Exit 1 } } } } Catch { Write-Output "Error: $($response.statuscode) $($error[0].Exception)" }

 

Uploading Promoscreens

Write-Output "Start updating the promoscreen" # Uploading Promoscreen images $headers = @{"Session-Id" = $sessionId} # prepare header with the session id $boundary = [System.Guid]::NewGuid().ToString(); $Lf = "`r`n" $imgIDX = 0 # This is the image number. $image = "C:\temp\1.jpg" # path to your image $param = "{`n `"index`": " + $imgIDX + ", `n `"time`": 5000`n}" # This is the param with the image number and the time, 5 seconds $fileimg = [System.IO.File]::ReadAllBytes($image); $fileimgenc = [System.Text.Encoding]::GetEncoding('ISO-8859-1').GetString($fileimg); # We read and encode the jpg $bodyimg = ("--$boundary", "Content-Disposition: form-data; name=`"file`"; filename=`"$image`"", "Content-Type: image/jpeg$LF", $fileimgenc, "--$boundary", "Content-Disposition: form-data; name=`"parameters`"", $LF, $param, "--$boundary--$LF") -join $LF try { $rest_updimg = Invoke-WebRequest -Uri "http://$device/v1/modes/Standby/PromoScreens/0" -Method Post -UseBasicParsing -Headers $headers -ContentType "multipart/form-data; boundary=$boundary" -Body $bodyimg } catch { Write-Output "Issue image upload( " + $imgIDX + ")" Write-Output "Status Code-fail : $($response.statuscode) $($error[0].Exception)" }

 

Setting Core Settings

Write-Output " Start updating the configuration" $headers = @{"Session-Id" = $sessionId} $body_serialized = ' {"type": "SerializeConfig"}' # Update of Cors origins list $body = ' {"type": "UpdateConfig", "settings": { "origins": ["https://stepover.de", "https://stepover.com", "https://stepoverinfo.net", "http://*.test.com", "https://test.com", "http://localhost:8080"]}}' try { $rest_updatecors = Invoke-WebRequest -Uri "http://$device/v1/config" -Method Put -UseBasicParsing -Headers $headers -Body $body $rest_serialized = Invoke-WebRequest -Uri "http://$device/v1/config" -Method Put -UseBasicParsing -Headers $headers -Body $body_serialized } catch { Write-Output "Error while updating the config $($response.statuscode) $($error[0].Exception)" Exit 1 }