Searching for Hosts ​
GET /api/hosts
Searching for Hosts can be achieved via multiple criteria, as outlined by the fields below. You can search using just one field, or multiple to further narrow down the search results. In order to search for Hosts, you must specify the Hosts API Key which can be found on the screen Administration -> Passwordstate Administration -> System Settings -> API tab.
- HostName
- HostType
- OperatingSystem
- DatabaseServerType
- SiteID
- SiteLocation
Powershell
# Search by Host Name
$PasswordstateUrl = 'https://passwordstate/api/hosts/?HostName=<value>'
# Search by Host Name and Operating System
$PasswordstateUrl = 'https://passwordstate/api/hosts/?HostName=<value>&OperatingSystem=<value>'
# Search by Host Name, Operating System and SQL Server
$PasswordstateUrl = 'https://passwordstate/api/hosts/?HostName=<value>&OperatingSystem=<value>&DatabaseServerType=SQL Server'
# Searching for all SQL Servers
$PasswordstateUrl = 'https://passwordstate/api/hosts/?DatabaseServerType=SQL Server'
# Searching for all SQL Servers and Oracle
$PasswordstateUrl = 'https://passwordstate/api/hosts/?DatabaseServerType=SQL Server,Oracle'
# Searching for all Window 2012 Servers
$PasswordstateUrl = 'https://passwordstate/api/hosts/?OperatingSystem=Windows Server 2012'
# Search by SiteID
$PasswordstateUrl = 'https://passwordstate/api/hosts/?SiteID=<value>'
# Search by Site Location
$PasswordstateUrl = 'https://passwordstate/api/hosts/?SiteLocation=<value>'
# Search by Host Name and Site Location
$PasswordstateUrl = 'https://passwordstate/api/hosts/?HostName=<value>&SiteLocation=<value>'
Invoke-Restmethod -Method GET -Uri $PasswordstateUrl -Header @{ "APIKey" = "<apikey>" }Json
# Response
HTTP/1.1 200
[
{
"HostID":"12345",
"HostName":"abcserver.halox.net",
"HostType":"Windows",
"OperatingSystem":"Windows Server 2012",
"DatabaseServerType":"",
"SQLInstanceName":"",
"DatabasePortNumber":"",
"RemoteConnectionType":"RDP",
"RemoteConnectionPortNumber":"3389",
"RemoteConnectionParameters":"",
"Tag":"MyServer",
"Title":"",
"SiteID":"0",
"SiteLocation":"Internal",
"InternalIP":"192.168.1.57",
"ExternalIP":"",
"MACAddress":"28-C2-DD-E2-52-0E",
"SessionRecording":"False",
"VirtualMachine":"True",
"VirtualMachineType":"VMware",
"Notes":"",
"JobID":"",
"FolderID":"2130"
}
]