Powershell Script
Following script is used to read computer details and write it to text file.
Computer Details include computer name, serial number, MacAddress & IPAddress.
- $OutputFilePath = "C:\ComputerDetails.txt"
- $strComputer = (Get - WmiObject Win32_Computersystem).name
- $SerialNumber = gwmi win32_bios | Select– ExpandProperty SerialNumber
- [System.IO.File]::WriteAllText($OutputFilePath, $file.FullName)
- $file.lastwritetime | Add - Content $OutputFilePath
- $colItems = Get - WmiObject - Class "Win32_NetworkAdapterConfiguration" - ComputerName $strComputer - Filter "IpEnabled = TRUE"
- ForEach($objItem in $colItems)
- {#
- write - host "IP Address: "
- $objItem.IpAddress[0]
- "Mac: "
- $objItem.MacAddress
- $MacAddress = $objItem.MacAddress
- $IPAddress = $objItem.IpAddress[0]
- }
- "Computer Name : " + $ComputerName | Add - Content $OutputFilePath
- "Serial Number : " + $SerialNumber | Add - Content $OutputFilePath
- "Mac Address : " + $MacAddress | Add - Content $OutputFilePath
- "IP Address : " + $IPAddress | Add - Content $OutputFilePath