# # PowerShell 2 # # Export service and equipment data from ServiceView # # # Setup ServiceView options # # # URL to connect to ServiceView # $serviceview_api = "http:///get_services.php" # # The value of the SECRET option set in the options setup section. # $serviceview_secret = "" # # Bring back all service fields # $serviceview_details = 1; # # Include equipment details 0 = no or 1 = yes # $serviceview_equipment = 1; # # Get a specific service only using its service code, blank for all services # $serviceview_service_code = "" # # Only retrieve results with this service property, blank for all services # $serviceview_property_code="" # # Load the JSON decoder # [System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions") $ser = New-Object System.Web.Script.Serialization.JavaScriptSerializer $url = "$($serviceview_api)?secret=$($serviceview_secret)&full=$($serviceview_details)&equipment=$($serviceview_equipment)&service_code=$($serviceview_service_code)&property_code=$($serviceview_property_code)" # # Create Web Client # $wc = New-Object Net.WebClient # # Connect to ServiceView and download the JSON # $json = $wc.DownloadString($url) # # Decode JSON # $obj = $ser.DeserializeObject($json) # # Loop thru the services # foreach ($serviceItem in $obj) { # # Service fields available in $serviceItem for $serviceview_details = 0 See top of file # # service_code # service_name # service_group_name # # Service fields available in $serviceItem for $serviceview_details = 1 See top of file # # service_id # service_name # service_group_name # service_group_id # description # catalogue_fg # budget_owner # business_owner # technical_owner # service_code # supported_hours # public_fg # # AND service properties that are set for this service Write-Host "$($serviceItem.service_name) - $($serviceItem.service_group_name)" foreach ($equipItem in $serviceItem.equipment) { # # Equipment fields available in $equipItem # # hardware_id # hardware_name # service_id # manufacturer # model # virtual_fg # leased_fg # purchase_date # end_of_lease_date # end_of_maintenance_date # server_use # operating_system # serial_number # asset_tag # contract_id # rack_units # datacentre_id # rack_id # rack_position # building_id # floor # room # created_by # create_dt # modified_by # modify_dt Write-Host $equipItem.hardware_name $equipItem.server_use } }