Can I search for all used device types in a selected location by using Python?
Category:
Scripts
Answer
- Define the get_parameter() function to select the location of interest.
def get_parameters():
var1=Parameters.Create("location","Location" )
var1.Description='Please select a location'
var1.Type=ParameterType.Location
var1.Optional=True
var1.Value=0
Parameters.Add(var1)
return
- Access the selected location in the execute() function and get the details of it.
selLocationId=Parameters.Get('location').Value
locDetails=Service.LocationGetDetails(selLocationId)
isDeviceContainer=locDetails.Info.IsDeviceContainer
- If the location is a device container look for all devices inside of the location.
if isDeviceContainer:
allDevices=Service.LocationGetDevices(selLocationId)
for eachDevice in allDevices:
devName=eachDevice.Info.Name
devManu=eachDevice.DeviceType.Manufacturer
devType=eachDevice.DeviceType.Name
- Report the details of the device type in the output window.
Output.AppendLine(devName+ "| "+devManu+ "| " +devType)
- Now perform any type of statistic investigations on the device types and information collected by the code before.
Tags