Good Morning!<\/p>\n
Thank you for taking the time to read this question. Currently, this script was found online and works like a charm. I just need it to report everything as it currently does but I want another item to show. I want it to display actual disk usage. Any help would be much appreciated!<\/p>\n
#Define how you want\n\n$serverList = \"C:\\Temp\\Reports\\ServerList.txt\"\n\n#only for ad servers\n\n#$serverlist=Get-ADComputer -Filter {OperatingSystem -Like '*windows server*' } | Select-Object -ExpandProperty Name\n\n#Only for ad computers\n#or $serverlist=Get-ADComputer -Filter {OperatingSystem -notLike '*server*' } | Select-Object -ExpandProperty Name\n\n$outputCSV = \"C:\\Temp\\Reports\\RFV.csv\"\n \n \n$scriptpath = $MyInvocation.MyCommand.Path\n#$dir = Split-Path $scriptpath\npushd $dir\n \n[System.Collections.ArrayList]$sysCollection = New-Object System.Collections.ArrayList($null)\n \nforeach ($server in (Get-Content $serverList))\n{\n \"Collecting information from $server\"\n $totCores=0\n \n try\n {\n [wmi]$user = Get-WmiObject Win32_Computersystem -ComputerName $server \n [wmi]$sysInfo = get-wmiobject Win32_ComputerSystem -Namespace \"root\\CIMV2\" -ComputerName $server -ErrorAction Stop\n [wmi]$bios = Get-WmiObject Win32_BIOS -Namespace \"root\\CIMV2\" -computername $server\n [wmi]$os = Get-WmiObject Win32_OperatingSystem -Namespace \"root\\CIMV2\" -Computername $server\n [array]$disks = Get-WmiObject Win32_LogicalDisk -Namespace \"root\\CIMV2\" -Filter DriveType=3 -Computername $server\n [array]$disks = Get-WmiObject Win32_LogicalDisk -Namespace \"root\\CIMV2\" -Computername $server\n [array]$procs = Get-WmiObject Win32_Processor -Namespace \"root\\CIMV2\" -Computername $server\n [array]$mem = Get-WmiObject Win32_PhysicalMemory -Namespace \"root\\CIMV2\" -ComputerName $server\n [array]$nic = Get-WmiObject Win32_NetworkAdapterConfiguration -Namespace \"root\\CIMV2\" -ComputerName $server | where{$_.IPEnabled -eq \"True\"}\n \n $si = @{\n user =[string]$sysinfo.username\n Server = [string]$server\n Manufacturer = [string]$sysInfo.Manufacturer\n Model = [string]$sysInfo.Model\n TotMem = \"$([string]([System.Math]::Round($sysInfo.TotalPhysicalMemory/1gb,2))) GB\"\n BiosDesc = [string]$bios.Description\n BiosVer = [string]$bios.SMBIOSBIOSVersion+\".\"+$bios.SMBIOSMajorVersion+\".\"+$bios.SMBIOSMinorVersion\n BiosSerial = [string]$bios.SerialNumber\n OSName = [string]$os.Name.Substring(0,$os.Name.IndexOf(\"|\") -1)\n ServicePack = (“SP {0}” -f [string]$os.ServicePackMajorVersion)\n Arch = [string]$os.OSArchitecture\n Processors = [string]@($procs).count\n Cores = [string]$procs[0].NumberOfCores\n\n }\n \n $disks | foreach-object {$si.\"Drive$($_.Name -replace ':', '')\"=\"$([string]([System.Math]::Round($_.Size/1gb,2))) GB\" }\n\n \n \n }\n catch [Exception]\n {\n \"Error communicating with $server, skipping to next\"\n $si = @{\n Server = [string]$server\n ErrorMessage = [string]$_.Exception.Message\n ErrorItem = [string]$_.Exception.ItemName\n }\n Continue\n }\n finally\n {\n [void]$sysCollection.Add((New-Object PSObject -Property $si)) \n }\n}\n \n$sysCollection `\n | select-object Server,TotMem,OSName,Processors,Cores,Manufacturer,Model,BiosSerial,DriveA,DriveB,DriveC,DriveD,DriveE,DriveF,DriveG,DriveH,DriveI,DriveJ,DriveK,DriveL,DriveM,DriveN,DriveO,DriveP,DriveQ,DriveR,DriveS,DriveT,DriveU,DriveV,DriveW,DriveX,DriveY,DriveZ,ErrorMessage,ErrorItem `\n | sort -Property Server `\n | Export-CSV -path $outputCSV -NoTypeInformation \n Write-Host \"inventory completed check $outputCSV\" -backgroundcolor \"green\"\n<\/code><\/pre>","upvoteCount":2,"answerCount":5,"datePublished":"2021-03-02T12:17:00.000Z","author":{"@type":"Person","name":"spiceuser-fjucg","url":"https://community.spiceworks.com/u/spiceuser-fjucg"},"suggestedAnswer":[{"@type":"Answer","text":"
Advertisement
Good Morning!<\/p>\n
Thank you for taking the time to read this question. Currently, this script was found online and works like a charm. I just need it to report everything as it currently does but I want another item to show. I want it to display actual disk usage. Any help would be much appreciated!<\/p>\n
#Define how you want\n\n$serverList = \"C:\\Temp\\Reports\\ServerList.txt\"\n\n#only for ad servers\n\n#$serverlist=Get-ADComputer -Filter {OperatingSystem -Like '*windows server*' } | Select-Object -ExpandProperty Name\n\n#Only for ad computers\n#or $serverlist=Get-ADComputer -Filter {OperatingSystem -notLike '*server*' } | Select-Object -ExpandProperty Name\n\n$outputCSV = \"C:\\Temp\\Reports\\RFV.csv\"\n \n \n$scriptpath = $MyInvocation.MyCommand.Path\n#$dir = Split-Path $scriptpath\npushd $dir\n \n[System.Collections.ArrayList]$sysCollection = New-Object System.Collections.ArrayList($null)\n \nforeach ($server in (Get-Content $serverList))\n{\n \"Collecting information from $server\"\n $totCores=0\n \n try\n {\n [wmi]$user = Get-WmiObject Win32_Computersystem -ComputerName $server \n [wmi]$sysInfo = get-wmiobject Win32_ComputerSystem -Namespace \"root\\CIMV2\" -ComputerName $server -ErrorAction Stop\n [wmi]$bios = Get-WmiObject Win32_BIOS -Namespace \"root\\CIMV2\" -computername $server\n [wmi]$os = Get-WmiObject Win32_OperatingSystem -Namespace \"root\\CIMV2\" -Computername $server\n [array]$disks = Get-WmiObject Win32_LogicalDisk -Namespace \"root\\CIMV2\" -Filter DriveType=3 -Computername $server\n [array]$disks = Get-WmiObject Win32_LogicalDisk -Namespace \"root\\CIMV2\" -Computername $server\n [array]$procs = Get-WmiObject Win32_Processor -Namespace \"root\\CIMV2\" -Computername $server\n [array]$mem = Get-WmiObject Win32_PhysicalMemory -Namespace \"root\\CIMV2\" -ComputerName $server\n [array]$nic = Get-WmiObject Win32_NetworkAdapterConfiguration -Namespace \"root\\CIMV2\" -ComputerName $server | where{$_.IPEnabled -eq \"True\"}\n \n $si = @{\n user =[string]$sysinfo.username\n Server = [string]$server\n Manufacturer = [string]$sysInfo.Manufacturer\n Model = [string]$sysInfo.Model\n TotMem = \"$([string]([System.Math]::Round($sysInfo.TotalPhysicalMemory/1gb,2))) GB\"\n BiosDesc = [string]$bios.Description\n BiosVer = [string]$bios.SMBIOSBIOSVersion+\".\"+$bios.SMBIOSMajorVersion+\".\"+$bios.SMBIOSMinorVersion\n BiosSerial = [string]$bios.SerialNumber\n OSName = [string]$os.Name.Substring(0,$os.Name.IndexOf(\"|\") -1)\n ServicePack = (“SP {0}” -f [string]$os.ServicePackMajorVersion)\n Arch = [string]$os.OSArchitecture\n Processors = [string]@($procs).count\n Cores = [string]$procs[0].NumberOfCores\n\n }\n \n $disks | foreach-object {$si.\"Drive$($_.Name -replace ':', '')\"=\"$([string]([System.Math]::Round($_.Size/1gb,2))) GB\" }\n\n \n \n }\n catch [Exception]\n {\n \"Error communicating with $server, skipping to next\"\n $si = @{\n Server = [string]$server\n ErrorMessage = [string]$_.Exception.Message\n ErrorItem = [string]$_.Exception.ItemName\n }\n Continue\n }\n finally\n {\n [void]$sysCollection.Add((New-Object PSObject -Property $si)) \n }\n}\n \n$sysCollection `\n | select-object Server,TotMem,OSName,Processors,Cores,Manufacturer,Model,BiosSerial,DriveA,DriveB,DriveC,DriveD,DriveE,DriveF,DriveG,DriveH,DriveI,DriveJ,DriveK,DriveL,DriveM,DriveN,DriveO,DriveP,DriveQ,DriveR,DriveS,DriveT,DriveU,DriveV,DriveW,DriveX,DriveY,DriveZ,ErrorMessage,ErrorItem `\n | sort -Property Server `\n | Export-CSV -path $outputCSV -NoTypeInformation \n Write-Host \"inventory completed check $outputCSV\" -backgroundcolor \"green\"\n<\/code><\/pre>","upvoteCount":2,"datePublished":"2021-03-02T12:17:00.000Z","url":"https://community.spiceworks.com/t/adding-space-used-to-current-script/792343/1","author":{"@type":"Person","name":"spiceuser-fjucg","url":"https://community.spiceworks.com/u/spiceuser-fjucg"}},{"@type":"Answer","text":"Well you do have the correct WMI-OBJECT. Check out this link<\/a> and use the Select-Object and that should get you started.<\/p>","upvoteCount":0,"datePublished":"2021-03-02T14:08:28.000Z","url":"https://community.spiceworks.com/t/adding-space-used-to-current-script/792343/2","author":{"@type":"Person","name":"kenannan","url":"https://community.spiceworks.com/u/kenannan"}},{"@type":"Answer","text":"