Add a New Host ​
POST /winapi/hosts
Adding a new Host object can be achieved by making a POST request on the URL, with appropriate fields forming the HTTP message body. To create Hosts, you must have been given access to the feature 'Host Record Permissions' which can be found on the screen Administration -> Passwordstate Administration -> System Settings -> Hosts tab.
The PowerShell example below creates a Host record with various fields specified.
Powershell
#JSON data for the object
$Body = @{
HostName = "abcserver.halox.net"
HostType = "Windows"
OperatingSystem = "Windows Server 2012"
DatabaseServerType = ""
SQLInstanceName = ""
DatabasePortNumber = ""
RemoteConnectionType = "RDP"
RemoteConnectionPortNumber = "3389"
RemoteConnectionParameters = ""
Tag = "MyServer"
Title = ""
SiteID = "0"
InternalIP = "192.168.1.57"
ExternalIP = ""
MACAddress = "28-C2-DD-E2-52-0E"
SessionRecording = "False"
VirtualMachine = "True"
VirtualMachineType = "VMware"
Notes = ""
}
$jsonData = $Body | ConvertTo-Json
$PasswordstateURL = 'https://passwordstate/winapi'
$result = Invoke-Restmethod -Method Post -Uri $PasswordstateURL'/hosts' -ContentType "application/json" -Body $jsonData -UseDefaultCredentials
Write-Output $result