Add a New Host ​
POST /api/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 use the Hosts API Key.
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/api'
$result = Invoke-Restmethod -Method Post -Uri $PasswordstateURL'/hosts' -ContentType "application/json" -Body $jsonData -Header @{ "APIKey" = "<apikey>" }
Write-Output $result