Public/Set-Computers.ps1
<#PSScriptInfo .VERSION 1.0 .GUID 972a6d04-f905-4347-98b1-6bf00d8ce204 .AUTHOR dmcanady .COMPANYNAME .COPYRIGHT .TAGS .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES .PRIVATEDATA #> function Set-Computers { param ( [string]$AuditSelection ) if ($AuditSelection -eq "Storage") { #Start Storage If #Storage audit parameters $RecordData = @{ "Filter" = @(@("install_status", "-eq", "16"), "and", @("location", "-eq", $script:Office.Code), "and", @("u_type", "-in", "Laptop, Mac_Laptop, Tablet")); "Sort" = @("model", "asc"); "Table" = "alm_hardware"; "First" = 300; "Properties" = @("u_last_physical_inventory_date", "serial_number", "display_name", "sys_id"); } # Gets a list of all computers, info with ID that are in storage $script:Computers = Get-ServiceNowRecord @RecordData | % { $counter = 0 } { $counter++; $_ | Add-Member -Name ID -Value $counter -MemberType NoteProperty -PassThru } | % { $_ | Add-Member -Name AuditStatus -Value "NotScanned" -MemberType NoteProperty -PassThru } }#end Storage If elseif ($AuditSelection -eq "Repair") {#start Repair If $RecordData = @{ "Filter" = @(@("cat_item", "-eq", "cd13f3032b7892001235717bf8da1580"), "and", @("u_depot_location", "-eq", $script:Office.Code) , "and", @("state", "-in", "2, 1, 11"), "or", @("u_substate", "-eq", "c4b3f3702b3c9200258f89efe8da1504")); "Sort" = @("state", "asc"); "Table" = "u_computer_support"; "First" = 150; "Properties" = @("number", "u_asset", "cat_item", "state", "u_substate", "u_depot_location", "u_serial_number", "u_wi_primary_tech"); } # Gets a list of all computers, info with ID for acitve or ready for pickup repairs $script:Computers = Get-ServiceNowRecord @RecordData | % { $counter = 0 } { $counter++; $_ | Add-Member -Name ID -Value $counter -MemberType NoteProperty -PassThru } | % { $_ | Add-Member -Name AuditStatus -Value "NotScanned" -MemberType NoteProperty -PassThru } | % { $_ | Add-Member -Name Serial -Value "" -MemberType NoteProperty -PassThru } DataFormat }#end Repair If elseif ($AuditSelection -eq "Assignment") {#start Assignment If $RecordData = @{ "Filter" = @(@("cat_item", "-in", "e604f7032b7892001235717bf8da153c, a6b3bfcf2b3892001235717bf8da1530"), "and", @("u_depot_location", "-eq", $script:Office.Code) , "and", @("state", "-in", "2, 1, 11"), "or", @("u_substate", "-eq", "c4b3f3702b3c9200258f89efe8da1504")); "Sort" = @("state", "asc"); "Table" = "u_computer_support"; "First" = 150; "Properties" = @("number", "u_asset", "cat_item", "state", "u_substate", "u_depot_location", "u_serial_number", "u_wi_primary_tech"); } # Gets a list of all computers, info with ID for Assignments and LCMs $script:Computers = Get-ServiceNowRecord @RecordData | % { $counter = 0 } { $counter++; $_ | Add-Member -Name ID -Value $counter -MemberType NoteProperty -PassThru } | % { $_ | Add-Member -Name AuditStatus -Value "NotScanned" -MemberType NoteProperty -PassThru } | % { $_ | Add-Member -Name Serial -Value "" -MemberType NoteProperty -PassThru } DataFormat }#end Assignment If } |