#Vars $sysType = "DT" $Location = "SysLocation" $NetAdap = "real" #can be broad(Full: broadcom), real(full: realtek) or vbox(full: VirtualBox) $dataFolder = "foldername" $csvname = "datafile.csv" #Setup $SYSID = Read-Host -Prompt 'Input System ID' $SYSIDU = "$SYSID".ToUpper() $file = "$dataFolder/$SYSIDU.txt" #Checking if dataFolder exist $dirtest = Test-Path $dataFolder if ($dirtest -eq $False) { Write-Host mkdir $dataFolder } #Checking if file exist $filetest = Test-Path $file 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" >> $dataFolder/$csvname