Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $apikey = "supersecretapikey"
- $url = "snipeurl"
- $assetTag = (Get-WmiObject win32_bios).SerialNumber
- $assetExists = Get-Asset -search $assetTag -url $url -apikey $apikey
- if(([string]::IsNullOrEmpty($assetExists)))
- {
- $computerName = $env:COMPUTERNAME
- $cs = (Get-WmiObject -class Win32_ComputerSystem).TotalPhysicalMemory
- $memoryAmount = [math]::Ceiling($cs / 1024 / 1024 / 1024)
- $modelno = (Get-WmiObject -class Win32_ComputerSystem).Model
- $cpu = (Get-WmiObject Win32_Processor).Name
- if ($cpu -like "*i5*"){
- $cpuType = "i5"
- }
- elseif ($cpu -like "*i7*"){
- $cpuType = "i7"
- }
- $modelSelection = Get-Model -url $url -apikey $apikey | Where-Object {$_.name -like "*$modelno*" -and $_.name -like "*$memoryAmount*" -and $_.name -like "*$cpuType*"}
- New-Asset -Name $computerName -tag $assetTag -Model_id $modelSelection.id -Status "2" -url $url -apikey $apikey
- }
- else {
- exit
- }
Advertisement
Add Comment
Please, Sign In to add comment