Hi,
I'm admittedly pretty poor at JSON and Powershell. I'm hoping someone here
can give me a hand. I have a script for installing and configuring VNC on a
given domain PC. I'm currently attempting to write web requests to add a
new connection. I have authentication working, it's just the actual
creation of a new VNC connection that's broken. Keeps giving me error 500.
Any suggestions?

### Add connection to guacamole WIP
$pc = $args[0]
[Net.ServicePointManager]::SecurityProtocol =
[Net.SecurityProtocolType]::Tls12


# Obtain Token
$postParams = "username=api&password=aaaaaaa"
$t = Invoke-WebRequest -Uri https://remoteaccess.domain.ca/api/tokens
-Method POST -Body $postParams|ConvertFrom-Json | select AuthToken
$token = $t.Authtoken


# test thing
$param = @{
  parentIdentifier = "ROOT";
  name = "aaaaaaaaaaaaaaa";
  protocol = "vnc";
  parameters = {
    port = "5900";
    password = "aaa";
    hostname = "$pc"
  }
}
$diet = $param | convertto-json
Invoke-WebRequest -Uri "
https://remoteaccess.domain.ca/api/session/data/mysql/connections?token=$token";
-ContentType  "application/json" -Method POST -Body $diet



# Deauthenticate token
Invoke-WebRequest -Uri https://remoteaccess.domain.ca/api/tokens/$token
-Method DELETE -Body "token=$token"





-- 

*Justin Engwer*

Reply via email to