Hi all, hope all is well. Hoping someone can assist with a simple powershell report. I am trying to gather a report of server info such as Processor,Memory,Disks, & OS. Issue i am having is the Disks information. Every report i run is able to give me all the other info in a nice csv but once disk info is asked using Get-WmiObject -Class Win32_LogicalDisk it does not follow the formatting of the CSV. Wanted to see if anyone else has ran into this and has any suggestions<\/p>","upvoteCount":2,"answerCount":6,"datePublished":"2019-03-08T16:39:20.000Z","author":{"@type":"Person","name":"mcb","url":"https://community.spiceworks.com/u/mcb"},"suggestedAnswer":[{"@type":"Answer","text":"
Hi all, hope all is well. Hoping someone can assist with a simple powershell report. I am trying to gather a report of server info such as Processor,Memory,Disks, & OS. Issue i am having is the Disks information. Every report i run is able to give me all the other info in a nice csv but once disk info is asked using Get-WmiObject -Class Win32_LogicalDisk it does not follow the formatting of the CSV. Wanted to see if anyone else has ran into this and has any suggestions<\/p>","upvoteCount":2,"datePublished":"2019-03-08T16:39:20.000Z","url":"https://community.spiceworks.com/t/powershell-remote-server-info/701324/1","author":{"@type":"Person","name":"mcb","url":"https://community.spiceworks.com/u/mcb"}},{"@type":"Answer","text":"
You should just modify the output of the command to fit how you want it to be in the csv.<\/p>\n
How do you want it? By default it looks like<\/p>\n
DeviceID : E:\nDriveType : 3\nProviderName :\nFreeSpace : 1722846179328\nSize : 4000750497792\nVolumeName : Elements\n\nDeviceID : G:\nDriveType : 4\nProviderName : \\\\app01\\shares\\userdata\nFreeSpace : 329769316352\nSize : 1073605505024\nVolumeName : DataShares\n<\/code><\/pre>\nYou can easily change this by doing a Select<\/p>\n
PS C:\\Users\\me> Get-WmiObject -Class Win32_LogicalDisk | select DeviceID,ProviderName,Size,Freespace\n\nDeviceID ProviderName Size Freespace\n-------- ------------ ---- ---------\nC: 159446462464 57483800576\nD:\nE: 4000750497792 1722846179328\nG: \\\\app01\\shares\\userdata 1073605505024 329769472000\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2019-03-08T16:45:13.000Z","url":"https://community.spiceworks.com/t/powershell-remote-server-info/701324/2","author":{"@type":"Person","name":"matt234","url":"https://community.spiceworks.com/u/matt234"}},{"@type":"Answer","text":"Thank you. This part I have. Issue now is having one CSV that also includes memory,processor, & OS for multiple servers.<\/p>","upvoteCount":0,"datePublished":"2019-03-08T16:47:45.000Z","url":"https://community.spiceworks.com/t/powershell-remote-server-info/701324/3","author":{"@type":"Person","name":"mcb","url":"https://community.spiceworks.com/u/mcb"}},{"@type":"Answer","text":"
Why not post the script you’re working with so we can see how to make suggestions? Chances are, you’ll just need to add a few things to a PSObject to store them, but the data could be presented in a number of different ways before the Export-CSV call.<\/p>","upvoteCount":0,"datePublished":"2019-03-08T17:50:00.000Z","url":"https://community.spiceworks.com/t/powershell-remote-server-info/701324/4","author":{"@type":"Person","name":"dancrane","url":"https://community.spiceworks.com/u/dancrane"}},{"@type":"Answer","text":"
I have been using the below.<\/p>\n
<#\n.SYNOPSIS\n Name: Get-PCInfo.ps1\n The purpose of this script is to retrieve basic information of a PC.\n\n.DESCRIPTION\n This is a simple script to retrieve basic information of domain joined computers.\n It will gather hardware specifications and Operating System and present them on the screen.\n\n.RELATED LINKS\n Home\n\n.PARAMETER Computer\n This is the only parameter that is needed to provide the name of the computer either\n in as computer name or DNS name.\n\n.NOTES\n Updated: 08-02-2018 Testing the connection before the information gathering.\n \n Release Date: 05-02-2018\n \n Author: Stephanos Constantinou\n\n.EXAMPLE\n Run the Get-PCInfo script to retrieve the information.\n \n Get-PCInfo.ps1 -Computer test-pc\n#>\n\nParam( [string]$Computer )\n\n$Connection = Test-Connection $Computer -Count 1 -Quiet\n\nif ($Connection -eq \"True\") {\n\n $ComputerHW = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $Computer |\n select Manufacturer,Model | FT -AutoSize\n\n $ComputerCPU = Get-WmiObject win32_processor -ComputerName $Computer |\n select DeviceID,Name | FT -AutoSize\n\n $ComputerRam_Total = Get-WmiObject Win32_PhysicalMemoryArray -ComputerName $Computer |\n select MemoryDevices,MaxCapacity | FT -AutoSize\n\n $ComputerRAM = Get-WmiObject Win32_PhysicalMemory -ComputerName $Computer |\n select DeviceLocator,Manufacturer,PartNumber,Capacity,Speed | FT -AutoSize\n\n $ComputerDisks = Get-WmiObject -Class Win32_LogicalDisk -Filter \"DriveType=3\" -ComputerName $Computer |\n select DeviceID,VolumeName,Size,FreeSpace | FT -AutoSize\n\n $ComputerOS = (Get-WmiObject Win32_OperatingSystem -ComputerName $Computer).Version\n\n switch -Wildcard ($ComputerOS) {\n \"6.1.7600\" {$OS = \"Windows 7\"; break}\n \"6.1.7601\" {$OS = \"Windows 7 SP1\"; break}\n \"6.2.9200\" {$OS = \"Windows 8\"; break}\n \"6.3.9600\" {$OS = \"Windows 8.1\"; break}\n \"10.0.*\" {$OS = \"Windows 10\"; break}\n default {$OS = \"Unknown Operating System\"; break}\n }\n \n Write-Host \"Computer Name: $Computer\"\n Write-Host \"Operating System: $OS\"\n Write-Output $ComputerHW\n Write-Output $ComputerCPU\n Write-Output $ComputerRam_Total\n Write-Output $ComputerRAM\n Write-Output $ComputerDisks\n}\nelse {\n\n Write-Host -ForegroundColor Red @\"\nComputer is not reachable or does not exists.\n\"@\n}\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2019-03-08T17:52:57.000Z","url":"https://community.spiceworks.com/t/powershell-remote-server-info/701324/5","author":{"@type":"Person","name":"mcb","url":"https://community.spiceworks.com/u/mcb"}},{"@type":"Answer","text":"What output are you seeing vs wanting to see? Because, that script just outputs text to the console and doesn’t create a CSV at all.<\/p>\n
Are you trying to copy and paste that into Excel or another spreadsheet program?<\/p>\n
Keep in mind a CSV file has only one type of item and fields at the top to match, but you are outputting multiple types of data?<\/p>\n
You might be better off generating an html file for each computer using convertto-html -fragment if you are trying to create a formatted report rather than a csv abused for that purpose to be viewable in excel.<\/p>","upvoteCount":0,"datePublished":"2019-03-08T22:37:25.000Z","url":"https://community.spiceworks.com/t/powershell-remote-server-info/701324/6","author":{"@type":"Person","name":"craigduff","url":"https://community.spiceworks.com/u/craigduff"}}]}}