Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param([string]$computerName)
- $apikey = "supersecretapikey"
- $url = "http://url.snipeit.com"
- $computerName = (Get-WmiObject -class Win32_ComputerSystem -ComputerName $computerName).name
- $assetTag = (Get-WmiObject win32_bios -ComputerName $computerName).SerialNumber
- $assetExists = Get-Asset -search $assetTag -url $url -apikey $apikey
- $cs = (Get-WmiObject -class Win32_ComputerSystem -ComputerName $computerName).TotalPhysicalMemory
- $memoryAmount = [math]::Ceiling($cs / 1024 / 1024 / 1024)
- $modelno = (Get-WmiObject -class Win32_ComputerSystem -ComputerName $computerName).Model
- $manufacturer = (Get-WmiObject -class Win32_ComputerSystem -ComputerName $computerName).Manufacturer
- $SystemType = (Get-WmiObject -class Win32_ComputerSystem -ComputerName $computerName).PCSystemType
- $OS = (Get-WmiObject Win32_OperatingSystem -ComputerName $computerName).caption
- $OSArch = (Get-WmiObject Win32_OperatingSystem -ComputerName $computerName).osarchitecture
- $cpu = (Get-WmiObject Win32_Processor -ComputerName $computerName).Name
- if ($cpu -like "*i5*"){
- $cpuType = "i5"
- }
- elseif ($cpu -like "*i7*"){
- $cpuType = "i7"
- }
- elseif ($cpu -like "*i3*"){
- $cpuType = "i3"
- }
- $modelSelection = Get-Model -url $url -apikey $apikey | Where-Object {$_.name -like "*$modelno*" -and $_.name -like "*$memoryAmount*" -and $_.name -like "*$cpuType*"}
- if(([string]::IsNullOrEmpty($modelSelection)))
- $NewModel = "$($modelno) $($cpuType)/$($memoryAmount)GB"
- $Assetmanufacturer = Get-Manufacturer -url $url -apikey $apikey | Where-Object {$_.name -like "*$manufacturer*"}
- $ComputerType = (Get-WmiObject -Class:Win32_ComputerSystem -ComputerName $computerName).PCSystemTypeEx
- If($ComputerType = 2){$Categoryid = 2}
- If($ComputerType = 1){$Categoryid = 3}
- New-Model $NewModel -category_id $Categoryid -manufacturer_id $Assetmanufacturer.id -fieldset_id 5 -url $url -apikey $apikey
- $modelSelection = Get-Model -url $url -apikey $apikey | Where-Object {$_.name -like "*$modelno*" -and $_.name -like "*$memoryAmount*" -and $_.name -like "*$cpuType*"}
- }
- Write-Host $modelno
- if(([string]::IsNullOrEmpty($assetExists)))
- {
- New-Asset -Name $computerName -tag $assetTag -Model_id $modelSelection.id -Status "2" -url $url -apikey $apikey
- }
- else {
- Write-Host "Asset Exist $($assetExists.id) : $($computerName) $($assetTag) $($SystemType) $($manufacturer)"
- Set-Asset -id $($assetExists.id) -Name $computerName -Model_id $modelSelection.id -Status "2" -url $url -apikey $apikey -CustomValues = @{ OS = "$($OS)" }
- exit
- }
Advertisement
Add Comment
Please, Sign In to add comment