Files
SysDesk-Data_acquiring_tool/V2_SysDesk-SaveSystem.ps1
Bram Prieshof fc8c8a261b Added Release 1
2020-01-27 23:19:12 +01:00

56 lines
1.4 KiB
PowerShell

#Vars
$sysType = "DT"
$Location = "SysLocation"
$NetAdap = "real" #can be broad(Full: broadcom), real(full: realtek) or vbox(full: VirtualBox)
$csvname = "datafile.csv"
#Setup
$SYSID = Read-Host -Prompt 'Input System ID'
$SYSIDU = "$SYSID".ToUpper()
$file = "$SYSIDU.txt"
#Checking if file exist
$filetest = Test-Path $SYSIDU*
if ($filetest -eq $True) { Write-Host
"This SysID already exists"
pause
exit
}
#Getting WindowsKEY
$WinKey = cscript productkey-V2.vbs //Nologo
#Getting System Serial
$serial = wmic bios get serialnumber
$shortserial = $serial -replace "SerialNumber" -replace '(?m)^\s*?\n'
$noBlanksSer = $shortserial -notmatch '^\n*$'
$noBlanks2ser = $noBlanksSer -notmatch '^\s*$'
#Getting Macaddres
$macaddr = Get-CimInstance win32_networkadapterconfiguration |select description, macaddress | where {$_.MACAddress -ne $null } | where {$_.Description -match $NetAdap } | select macaddress
$shortmacaddr = $macaddr -replace "macaddress" -replace '@{=' -replace '}' -replace ":","-"
#Saveing SYSID to File
echo $SYSIDU >> $file
#Saving sysType to File
echo $sysType >> $file
#Saveing Serial to File
echo $noBlanks2ser >> $file
#Saving Location
echo $Location >> $file
#Saving Macaddres
echo $shortmacaddr >> $file
#Saving windows-key
echo $WinKey >> $file
#Saving to Main CSV
echo "$SYSIDU,$sysType,$noBlanks2ser,$Location,$shortmacaddr,$WinKey" >> $csvname