Here's an example PowerShell script that can extract serial number and model information from a list of computers, and export it to an Excel file:
# Define the list of computers
$computers = Get-Content -Path "C:\Users\UserName\Desktop\ComputerList.txt"
# Create an empty array to store the computer information
$computerInfo = @()
# Loop through each computer and extract the information
foreach ($computer in $computers) {
# Use the Get-WmiObject cmdlet to get the serial number and model
$serialNumber = Get-WmiObject -Class Win32_Bios -ComputerName $computer | Select-Object -ExpandProperty SerialNumber
$model = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer | Select-Object -ExpandProperty Model
# Add the computer information to the array
$computerInfo += [PSCustomObject]@{
"ComputerName" = $computer
"SerialNumber" = $serialNumber
"Model" = $model
}
}
# Export the computer information to an Excel file
$computerInfo | Export-Excel -Path "C:\Users\UserName\Desktop\ComputerInfo.xlsx" -WorksheetName "ComputerInfo" -AutoSize
To run this script remotely, you will need to have the appropriate permissions and access to the remote computers. You can use the -Credential
parameter with the Get-WmiObject
cmdlet to specify the credentials to use for the remote connection. For example:
$credential = Get-Credential
$serialNumber = Get-WmiObject -Class Win32_Bios -ComputerName $computer -Credential $credential | Select-Object -ExpandProperty SerialNumber
This will prompt you for the username and password to use for the remote connection. Alternatively, you can store the credentials in a secure string and use the ConvertTo-SecureString
and Get-Credential
cmdlets to create the credential object.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-01-07 11:00:00 +0000
Seen: 9 times
Last updated: Aug 10 '21
How can you obtain the sha1 of the most recent commit in a git repository using C#?
How can I deal with Expression.Error related to a column in Power Query?
How can you implement pagination in Oracle for the LISTAGG() function?
What is the process for implementing a FutureBuilder on an OnTap function in Flutter?
How can we require users to be logged in before they can access the root folders in WordPress?
In SCSS, what is the method for grouping and reusing a set of classes and styles?
How can popen() be used to direct streaming data to TAR?
How does iOS retrieve information from a BLE device?
How can Django Admin accommodate a variety of formats and locales for its input fields?