I have a code which can find all nodeagents and deployment manager servers.
if scopetype == "nodeagent" or scopetype =="DeploymentManager":