I am trying to get the following information through Powershell on my AD: OS, OS Version, OS Architecture (32 or 64 bit), RAM, and space left on C Drive. I wrote the following script, but it isn’t pulling the computers in the list like I wanted. The 2023ComputerList has all of our domain computers on it, separated by line.<\/p>\n
$computers = Get-Content -Path ‘C:\\scripts\\2023ComputerList.txt’<\/p>\n
foreach ($computer in $computers) {
\n$Info = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property Name
\n$RAM = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property TotalPhysicalMemory
\n$Bios = Get-CimInstance -ClassName Win32_BIOS
\n$OperatingSystem = Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property Caption, OSArchitecture
\n$HardDrive = Get-CimInstance -ClassName Win32_LogicalDisk -Filter “DriveType=3”<\/p>\n
$OutputObj = New-Object -Type PSObject
\n$OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Info
\n$OutputObj | Add-Member -MemberType NoteProperty -Name RAM -Value $RAM
\n$OutputObj | Add-Member -MemberType NoteProperty -Name BIOS -Value $Bios
\n$OutputObj | Add-Member -MemberType NoteProperty -Name OperatingSystem -Value $OperatingSystem
\n$OutputObj | Add-Member -MemberType NoteProperty -Name HardDrive -Value $HardDrive
\n$OutputObj | Export-Csv ‘C:\\scripts\\2023PCInventoryList.csv’ -Append -NoTypeInformation
\n}<\/p>\n
Any help would be appreciated!<\/p>","upvoteCount":5,"answerCount":14,"datePublished":"2023-04-25T18:38:23.000Z","author":{"@type":"Person","name":"redngold","url":"https://community.spiceworks.com/u/redngold"},"suggestedAnswer":[{"@type":"Answer","text":"
I am trying to get the following information through Powershell on my AD: OS, OS Version, OS Architecture (32 or 64 bit), RAM, and space left on C Drive. I wrote the following script, but it isn’t pulling the computers in the list like I wanted. The 2023ComputerList has all of our domain computers on it, separated by line.<\/p>\n
$computers = Get-Content -Path ‘C:\\scripts\\2023ComputerList.txt’<\/p>\n
foreach ($computer in $computers) {
\n$Info = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property Name
\n$RAM = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property TotalPhysicalMemory
\n$Bios = Get-CimInstance -ClassName Win32_BIOS
\n$OperatingSystem = Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property Caption, OSArchitecture
\n$HardDrive = Get-CimInstance -ClassName Win32_LogicalDisk -Filter “DriveType=3”<\/p>\n
$OutputObj = New-Object -Type PSObject
\n$OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Info
\n$OutputObj | Add-Member -MemberType NoteProperty -Name RAM -Value $RAM
\n$OutputObj | Add-Member -MemberType NoteProperty -Name BIOS -Value $Bios
\n$OutputObj | Add-Member -MemberType NoteProperty -Name OperatingSystem -Value $OperatingSystem
\n$OutputObj | Add-Member -MemberType NoteProperty -Name HardDrive -Value $HardDrive
\n$OutputObj | Export-Csv ‘C:\\scripts\\2023PCInventoryList.csv’ -Append -NoTypeInformation
\n}<\/p>\n
Any help would be appreciated!<\/p>","upvoteCount":5,"datePublished":"2023-04-25T18:38:24.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-collect-ad-computer-information/950765/1","author":{"@type":"Person","name":"redngold","url":"https://community.spiceworks.com/u/redngold"}},{"@type":"Answer","text":"
Do you only want it in powershell or do you need the details of the servers (even if not using PS) ?<\/p>\n
I would recommend you to use a inventory software like PDQ inventory if it is important for you to have the servers data.<\/p>\n
Else you may need to confirm the following<\/p>\n
Nowhere in your script are you telling Get-CimInstance the remote computer name. You also don’t need to call Get-CimInstance so many times when querying the same class. Finally, creating your object like that is the “old” way. It’s better/easier to create a PSCustomObject.<\/p>","upvoteCount":1,"datePublished":"2023-04-26T09:42:59.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-collect-ad-computer-information/950765/3","author":{"@type":"Person","name":"saidbrandon","url":"https://community.spiceworks.com/u/saidbrandon"}},{"@type":"Answer","text":"
You’d be better served with using an Invoke-Command so they can be run in parallel since you’re querying so may different classes. If you we only doing 1, Get-CimInstance does support parallelization.<\/p>\n
$Computers = Get-Content -Path 'C:\\scripts\\2023ComputerList.txt'\n\nInvoke-Command -ComputerName $Computers -ScriptBlock {\n [PSCustomObject]@{\n ComputerName = $env:COMPUTERNAME\n RAM = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property TotalPhysicalMemory\n BIOS = Get-CimInstance -ClassName Win32_BIOS\n OperatingSystem = Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property Caption, OSArchitecture\n HardDrive = Get-CimInstance -ClassName Win32_LogicalDisk -Filter \"DriveType=3\"\n }\n} | Export-Csv -Path 'C:\\scripts\\2023PCInventoryList.csv' -NoTypeInformation\n<\/code><\/pre>\nAdditionally, if you go with Invoking, All of those will be available via Get-ComputerInfo except the disk. It gathers a lot more information so speed may be an issue.<\/p>","upvoteCount":0,"datePublished":"2023-04-26T09:51:30.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-collect-ad-computer-information/950765/4","author":{"@type":"Person","name":"saidbrandon","url":"https://community.spiceworks.com/u/saidbrandon"}},{"@type":"Answer","text":"
I condensed the code a bit to run a few parameters from Get-ComputerInfo (thank you for that suggestion!), and it looks like this:<\/p>\n
$Computers = Get-Content -Path ‘C:\\scripts\\2023ComputerList.txt’<\/p>\n
\n\nInvoke-Command -ComputerName $Computers -ScriptBlock {
\n[PSCustomObject]@{
\nComputerName = $env:COMPUTERNAME
\nComputerInfo = Get-ComputerInfo | select CsDNSHostName, WindowsProductName, OSArchitecture, CsTotalPhysicalMemory, CsProcessors
\nHardDrive = Get-CimInstance -ClassName Win32_LogicalDisk -Filter “DriveType=3”
\n}
\n} | Export-Csv -Path ‘C:\\scripts\\2023PCInventoryList.csv’ -NoTypeInformation<\/p>\n<\/blockquote>\n<\/blockquote>\n
This is what I get when I attempt to run it on our DC.<\/em><\/strong>
\nInvoke-Command : Cannot validate argument on parameter ‘ComputerName’. The argument is null or empty. Provide an
\nargument that is not null or empty, and then try the command again.
\nAt line:3 char:30<\/p>\n\n- Invoke-Command -ComputerName $Computers -ScriptBlock {<\/li>\n
- \n
<\/code><\/pre>\n<\/li>\n- CategoryInfo : InvalidData: (
[Invoke-Command], ParameterBindingValidationException<\/li>\n - FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand<\/li>\n<\/ul>\n
Any ideas?<\/p>","upvoteCount":0,"datePublished":"2023-04-26T11:19:50.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-collect-ad-computer-information/950765/5","author":{"@type":"Person","name":"redngold","url":"https://community.spiceworks.com/u/redngold"}},{"@type":"Answer","text":"
Sounds like your 2023ComputerList.txt file isn’t formatted correctly or contains a blank line or lines. It should look like:<\/p>\n
SERVER1\nSERVER2\nSERVER3\n<\/code><\/pre>\nand not<\/p>\n
SERVER1\n\nSERVER2\n<\/code><\/pre>\nor not<\/p>\n
SERVER1\nSERVER2\n\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2023-04-26T11:28:36.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-collect-ad-computer-information/950765/6","author":{"@type":"Person","name":"saidbrandon","url":"https://community.spiceworks.com/u/saidbrandon"}},{"@type":"Answer","text":"Try adding these lines just above your ForEach:<\/p>\n
Write-Host \"Here is the Computers variable:`n$($computers)`n`n`tHere is Computer:`n$($computer)\"\nRead-Host \"Got that?\"\n<\/code><\/pre>\nThe Read-Host will make it stop each time, so this won’t be for Production, of course! Break out with …<\/p>\n
If you’re looking at all live PCs in your Domain, why bother managing this list?<\/p>\n
An easier way to get a live list of all active PCs in your Domain would be thus:<\/p>\n
ForEach ($Computer in (Get-ADComputer -Filter {Enabled -eq $True} | Sort).Name){\n# [...]\n}\n<\/code><\/pre>\n…or use whatever selection criteria you used to build the .txt file.<\/p>","upvoteCount":0,"datePublished":"2023-04-26T12:18:25.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-collect-ad-computer-information/950765/7","author":{"@type":"Person","name":"jimlong3","url":"https://community.spiceworks.com/u/jimlong3"}},{"@type":"Answer","text":"
For your freespace, see if this might be useful:<\/p>\n
$Result = ForEach ($PC in (Get-ADComputer -Filter {OperatingSystem -notlike \"*Server*\" -And Enabled -ne $False}).Name | Sort) {\n\tWrite-Progress -Activity \"Getting Disk Free Space on $PC.\" -Status \"Checking $PC\" \n# Make sure it's online\n\tIf (Test-Connection $PC -Count 1 -Quiet){\n\t\tWrite-Host $PC\n# Load the $Result variable, format the free space as a number, but rounded and decimal-aligned, for Sorting\n\t\t[PSCustomObject] @{\n\t\t\tPC\t = $PC\n\t\t\tFreeSpace = [Math]::Round((Get-Volume C -CIMSession $PC).SizeRemaining / 1GB,2, [System.MidpointRounding]::AwayFromZero)\n\t\t\t' '\t = \"GB\"\n\t\t} # End PSCustomObject\n\t} # End If PC is online\n} # End For Each PC\n$Result | Sort-Object FreeSpace\n<\/code><\/pre>\nHTH…<\/p>","upvoteCount":0,"datePublished":"2023-04-26T12:30:00.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-collect-ad-computer-information/950765/8","author":{"@type":"Person","name":"jimlong3","url":"https://community.spiceworks.com/u/jimlong3"}},{"@type":"Answer","text":"
For RAM, set $PC to a valid name & see if any of this might be useful:<\/p>\n
# RAM Installed\n\t\t\"`t`t`t`tRAM\"\n\t\t$RAMArray = Get-WmiObject -Class \"Win32_PhysicalMemoryArray\" -namespace \"Root\\CIMV2\" -ComputerName $PC\n\t\t$AllSlots = Get-WmiObject -Class \"Win32_PhysicalMemory\" -namespace \"Root\\CIMV2\" -ComputerName $PC\n\t\t\"`tTotal Installed RAM: \" + ((Get-WmiObject -Class \"CIM_PhysicalMemory\" -ComputerName $PC | \n\t\t Measure-Object -Property Capacity -Sum).Sum / 1GB) + \" GB\"\n\t\t\"`tTotal Number of DIMM Slots: $($RAMArray.MemoryDevices)\"\n\t\t\"`n\" \n\t\tForeach ($DIMM In $AllSlots) # Disclose info for each DIMM\n\t\t\t{\n\t\t\t\"Memory Installed: `t$($DIMM.DeviceLocator)`t$($DIMM.Description)\"\n\t\t\t\"BankLabel: `t$($DIMM.BankLabel)\"\n\t\t\t\"Memory Size: `t$(($DIMM.Capacity / 1GB)) GB\"\n\t\t\t\"Speed: `t$($DIMM.Speed)\"\n\t\t\t\"TotalWidth: `t$($DIMM.TotalWidth)\"\n\t\t\t\"FormFactor: `t$($DIMM.FormFactor)\"\n\t\t\t\"Manufacturer: `t$($DIMM.Manufacturer)\"\n\t\t\tif ($DIMM.Model) {\"Model: `t$($DIMM.Model)\"} ## This seems blank a lot, so why print it?\n\t\t\tif ($DIMM.Caption -ne $DIMM.Description) { ## Redundant? Thanks fer nuttin.\n\t\t\t\t\"Caption: `t$($DIMM.Caption)\"}\n\t\t\tif ($DIMM.Name -ne $DIMM.Description) { ## Oh, even more redundant? Lovely.\n\t\t\t\t\"Name: `t$($DIMM.Name)\"}\n\t\t\t\"Part Number: `t$($DIMM.PartNumber)\"\n\t\t\t\"Serial Number: `t$($DIMM.SerialNumber)\"\n\t\t\tif ($DIMM.Attributes) {\"Attributes: `t$($DIMM.Attributes)\"} ## Usually blank but useful if not.\n\t\t\t\"`n\"\n\t\t} # End ForEach DIMM\n\n# RAM Usage\n\t\t\"`t`t`t`tRAM Usage\"\n\t\t$props=@(\n\t\t @{Label=\"Memory Percentage in Use (%)\"; Expression = {\"{0:N2}\" -f ((($_.TotalVisibleMemorySize - $_.FreePhysicalMemory)*100)/ $_.TotalVisibleMemorySize)}}; \n\t\t @{Label=\"Available Physical Memory (MB)\"; Expression = {[math]::round(($_.FreePhysicalMemory / 1kb), 2)}}; \n\t\t @{Label=\"Total Physical Memory (MB)\"; Expression = {[math]::round(($_.TotalVisibleMemorySize / 1kb), 2)}}; \n\t\t @{Label=\"Available Virtual Memory (MB)\"; Expression = {[math]::round(($_.FreeVirtualMemory / 1kb), 2)}}; \n\t\t @{Label=\"Total Virtual Memory (MB)\"; Expression = {[math]::round(($_.TotalVirtualMemorySize /1kb), 2)}}; \n\t\t)\n\t\t$OS | Format-List $props\n\n# Top 10 RAM Consumers\n\t\t\"`t`t`t`tTop 10 RAM Consumers\"\n\t\t$props=@(\n\t\t @{Label=\"Process Name\"; Expression = {$_.Name}},\n\t\t @{Label=\"PID\"; Expression={$_.Handle}},\n\t\t @{Label=\"CommandLine\"; Expression = {$_.CommandLine}}, \n\t\t @{Label=\"Private Memory(mb)\";Expression={[math]::round(($_.WorkingSetSize / 1mb), 2)}}\n\t\t)\n\t\t# Need a variable here to further investigate SvcHost processes\n\t\t$Consumers = Get-WmiObject Win32_Process -ComputerName $PC |\n\t\t Sort WorkingSetSize -Descending |\n\t\t Select -First 10\n\t\t$Consumers | Format-List $props\n\t\t$Consumers | ForEach {If ($_.Name -like \"*svchost*\"){tasklist /svc /FI \"imagename eq svchost.exe\" /FI \"PID eq $($_.Handle)\" /S $PC}}\n<\/code><\/pre>\nHTH…<\/p>\n
ETA: Set the $OS variable thus:<\/p>\n
$OS = Get-WMIObject Win32_OperatingSystem -ComputerName $PC\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2023-04-26T12:45:38.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-collect-ad-computer-information/950765/9","author":{"@type":"Person","name":"jimlong3","url":"https://community.spiceworks.com/u/jimlong3"}},{"@type":"Answer","text":"If you ever want more than just the Name for Info, see if some of these are useful:<\/p>\n
Get-WMIObject Win32_ComputerSystem -ComputerName $PC | Format-Table Manufacturer, Model,`\n @{Label='Asset Tag';Expression={(Get-WmiObject win32_SystemEnclosure -ComputerName $PC).SerialNumber}},`\n SystemType, @{Label='Cores';Expression={$_.NumberOfLogicalProcessors}},`\n Domain, @{Label='Joined?';Expression={$_.PartOfDomain}}`\n -Wrap -A\n<\/code><\/pre>\n(You don’t need a cmdlet for just Name. $computer (or $PC, for me) is it.)<\/p>","upvoteCount":0,"datePublished":"2023-04-26T12:56:03.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-collect-ad-computer-information/950765/10","author":{"@type":"Person","name":"jimlong3","url":"https://community.spiceworks.com/u/jimlong3"}},{"@type":"Answer","text":"
You might find some useful information in the BIOS by this:<\/p>\n
$BIOS = Get-WmiObject Win32_BIOS -ComputerName $PC\n\t\t[PSCustomObject]@{\n\t\t 'Name' = $($BIOS.Name)\n\t\t 'Manuf.' = $BIOS.Manufacturer\n\t\t 'Description' = $BIOS.Description\n\t\t 'Version' = $BIOS.Version\n\t\t 'SMBVersion' = $BIOS.SMBIOSBIOSVersion\n\t\t 'Caption' = $BIOS.Caption\n\t\t 'SN' = $BIOS.SerialNumber\n\t\t 'Release Date' = $($BIOS.ConvertToDateTime($BIOS.releasedate).ToShortDateString())\n\t\t 'Status' = $($BIOS.Status)\n\t\t}\n<\/code><\/pre>\nHTH…<\/p>","upvoteCount":0,"datePublished":"2023-04-26T13:18:52.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-collect-ad-computer-information/950765/11","author":{"@type":"Person","name":"jimlong3","url":"https://community.spiceworks.com/u/jimlong3"}},{"@type":"Answer","text":"
Operating System:<\/p>\n
$OS = Get-WMIObject Win32_OperatingSystem -ComputerName $PC\n# Windows\n\t\t\"`r`n`t`t`t`tOperating System\"\n\t\t$RealBuild = Switch -WildCard ($OS.Version){\n\t\t\t'*19045*'{\"22H2\"}\n\t\t\t'*19044*'{\"21H2\"}\n\t\t\t'*19043*'{\"21H1\"}\n\t\t\t'*19042*'{\"20H2\"}\n\t\t\t'*19041*'{\"2004\"}\n\t\t\t'*18363*'{\"1909\"}\n\t\t\t'*18362*'{\"1903\"}\n\t\t\t'*17763*'{\"1809\"}\n\t\t\t'*17134*'{\"1803\"}\n\t\t\t'*16299*'{\"1709\"}\n\t\t\t'*15063*'{\"1703\"}\n\t\t\t'*14393*'{\"1607\"}\n\t\t\t'*10586*'{\"1511\"}\n\t\t\t'*10240*'{\"1507\"}\n\t\t\tDefault {\" Old\"}\n\t\t\t} # End of Switch\n\n\t\t\"OS: $($OS.Caption) $($OS.CSDVersion) Build: $($OS.BuildNumber) ($($RealBuild)) $($OS.BuildType) $($OS.OSArchitecture)\"\n\t\t\"Free Physical Memory: $([Math]::Round($OS.FreePhysicalMemory / 1MB,3)) MB - $($OS.FreePhysicalMemory) Bytes\"\n\t\t\"Free Space In Paging Files: $([Math]::Round($OS.FreeSpaceInPagingFiles / 1MB,3)) MB - $($OS.FreeSpaceInPagingFiles) Bytes\"\n\t\t$UpTime = (Get-Date) - [Management.ManagementDateTimeConverter]::ToDateTime($OS.LastBootUpTime)\n\t\t\"UpTime \" + \"{0:00} Days {1:00} Hrs {2:00} Min\" -f $UpTime.Days,$UpTime.Hours,$UpTime.Minutes\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2023-04-26T13:28:51.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-collect-ad-computer-information/950765/12","author":{"@type":"Person","name":"jimlong3","url":"https://community.spiceworks.com/u/jimlong3"}},{"@type":"Answer","text":"Getting useful info on Local Disks is hard, but this may help:<\/p>\n
# Local Disks\n\t\t\"`t`t`t`tLocal Disks`n\"\n\t\t$PhysicalDisks = Get-WmiObject -Class Win32_DiskDrive -ComputerName $PC | Sort-Object DeviceID # -Descending\n\t\tForEach ($PhysicalDisk in $PhysicalDisks) {\n\t\t\t$DiskPartitions = Get-WmiObject -ComputerName $PC `\n\t\t\t -Query \"ASSOCIATORS OF {Win32_DiskDrive.DeviceID='$($PhysicalDisk.DeviceID)'} WHERE ASSOCCLASS = Win32_DiskDriveToDiskPartition\"\n\t\t\tForEach ($DiskPartition in $DiskPartitions) {\n\t\t\t\t$LogicalDisks = (Get-WmiObject -ComputerName $PC `\n\t\t\t\t -Query \"ASSOCIATORS OF {Win32_DiskPartition.DeviceID='$($DiskPartition.DeviceID)'} WHERE ASSOCCLASS = Win32_LogicalDiskToPartition\")\n\t\t\t\tForEach ($LogicalDisk in $LogicalDisks) {\n\t\t\t\t\t\"Drive $($LogicalDisk.Name)(\" + $LogicalDisk.VolumeName + \")`t$($DiskPartition.DeviceID)`tModel: $($PhysicalDisk.Model)\"\n\t\t\t\t\t \"`tSize: \" + [Math]::Round($LogicalDisk.Size / 1GB,2) + \" GB \" + \n\t\t\t\t\t \"`tFree Space: \" + [Math]::Round($LogicalDisk.FreeSpace / 1GB,2) + \" GB \" + \n\t\t\t\t\t \"`t($([Math]::round((($LogicalDisk.FreeSpace/$LogicalDisk.Size) * 100),2))\" + \"% Free)\" + \n\t\t\t\t\t \"`tS.M.A.R.T. Status: $($PhysicalDisk.Status)\"\n\t\t\t\t} # End For Each Logical Disk\n\t\t\t} # End For Each Partition\n\t\t\tForEach ($x in Get-WmiObject -ComputerName $PC -namespace root\\wmi –class MSStorageDriver_FailurePredictStatus){\n\t\t\t\tIf (!(Compare-Object $x.InstanceName.SubString(0,25) $PhysicalDisk.PNPDeviceID.SubString(0,25))){\n\t\t\t\t\tIf($x.PredictFailure){\n\t\t\t\t\t\"************************* S.M.A.R.T. Failure Predicted!`tReason: $($x.Reason) *************************\"}}\n\t\t\t} # End ForEach Prediction\n\t\t} # End For Each Physical Disk\n\n# Mapped Network Drives\n\t\t\"`n`t`t`t`tMapped Network Drives`n\"\n\t\tGet-WMIObject Win32_MappedLogicalDisk -Property \"DeviceID, ProviderName\" -ComputerName $PC |\n\t\t FT @{Label=\"Drive`nLetter\"; Expression={$_.DeviceID}}, @{Label=\"Path\"; Expression = {$_.ProviderName}}\n<\/code><\/pre>\nHTH…<\/p>\n
(I only ask that you learn things and answer other questions.)<\/p>","upvoteCount":0,"datePublished":"2023-04-26T13:35:02.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-collect-ad-computer-information/950765/13","author":{"@type":"Person","name":"jimlong3","url":"https://community.spiceworks.com/u/jimlong3"}},{"@type":"Answer","text":"
#runs this script on all machines in domain:\n$computers = Get-ADComputer -Filter * | Select-Object -ExpandProperty Name\n\n$results = foreach ($computer in $computers) {\n $Info = Get-CimInstance -ComputerName $computer -ClassName Win32_ComputerSystem | Select-Object -ExpandProperty Name\n $RAM = Get-CimInstance -ComputerName $computer -ClassName Win32_ComputerSystem | Select-Object -ExpandProperty TotalPhysicalMemory\n $Bios = Get-CimInstance -ComputerName $computer -ClassName Win32_BIOS\n $OperatingSystem = Get-CimInstance -ComputerName $computer -ClassName Win32_OperatingSystem | Select-Object -Property Caption, OSArchitecture\n $HardDrive = Get-CimInstance -ComputerName $computer -ClassName Win32_LogicalDisk -Filter \"DriveType=3\"\n\n $OutputObj = New-Object -Type PSObject\n $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Info\n $OutputObj | Add-Member -MemberType NoteProperty -Name RAM -Value $RAM\n $OutputObj | Add-Member -MemberType NoteProperty -Name BIOS -Value $Bios\n $OutputObj | Add-Member -MemberType NoteProperty -Name OperatingSystem -Value $OperatingSystem\n $OutputObj | Add-Member -MemberType NoteProperty -Name HardDrive -Value $HardDrive\n\n $OutputObj\n}\n\n$results | Export-Csv -Path 'C:\\scripts\\systeminfo.csv' -NoTypeInformation\n\n \n\n<\/code><\/pre>\n(Just tested it in a lab):
\n