Kamis, 21 Desember 2017

How To Buy The Farm Systems Inventory I.E. Ram, Disk, Cpu In Addition To Operating Systems Data Using Powershell Inward Domain.

Every System Administrator needs to hold Server Inventory together with operate yesteryear on it update, So hither is an automated script to delineate all the information using Powershell script. 

Let's re-create the script below together with salvage it equally Server_Inventory.PS1.
If y'all convey few servers y'all tin dismiss define mention manually or y'all tin dismiss read northward release of the organisation from a file.   


Create Pc.txt file equally inward below format

Server1 Server2 Server2 

Copy the Script together with Save as Server_Inventory.PS1.
#Define Systems Name or y'all tin dismiss read them from a file using ascendancy (Get-Content -Path D:\pc.txt) $pc = (Get-Content D:\PC.txt) #change this path amongst your .txt file $infocoll = @() foreach ($PCS inward $pc) {         #Here We tin dismiss role multiple ascendancy to become the data          $hostname = (Get-WmiObject -Class win32_processor -ComputerName $PCS).systemname          $HDDInfo = Get-WmiObject -Class win32_diskdrive -ComputerName $PCS | Measure-Object -Property size -Sum | % { [math]::Round(($_.sum / 1GB ), 2) }         $RamInfo = Get-WmiObject -Class win32_physicalmemory -ComputerName $PCS | Measure-Object -Property Capacity -Sum | % {[math]::Round(($_.sum / 1GB), 2)}         $Cdrive = Get-WmiObject -Class win32_logicaldisk -ComputerName $PCS |   where deviceid -EQ 'C:'          $CDrivePercentuse= (($Cdrive).size -($Cdrive).freespace)*100/($Cdrive).size         $CpuInfo = (Get-WmiObject -Class win32_processor -ComputerName $PCS).Name         $OSInfo = (Get-WmiObject -Class win32_operatingsystem -ComputerName $PCS).Name                 foreach($CPU inward $hostname)         { $infoObject = New-Object PSObject         #Define the Value to each objet y'all desire to add together into the .CSV file.          Add-Member -InputObject $infoObject -MemberType NoteProperty -Name "ServerName" -Value $hostname         Add-Member -InputObject $infoObject -MemberType NoteProperty -Name "HDD SIZE inward GB" -Value $HDDInfo         Add-Member -InputObject $infoObject -MemberType NoteProperty -Name "C Drive Use IN %" -Value $CDrivePercentuse         Add-Member -InputObject $infoObject -MemberType NoteProperty -Name "CPU Detail" -Value $CpuInfo         Add-Member -InputObject $infoObject -MemberType NoteProperty -Name "RAM Detail inward GB" -Value $RamInfo         Add-Member -InputObject $infoObject -MemberType NoteProperty -Name "O.S Name" -Value $OSInfo                 $infoObject         $infocoll += $infoObject                  }     }  # Export all the information to a .CSV file together with shop the somewhere else y'all want.  $infocoll | Export-Csv -Path "D:\Serverinvt.csv" -NoTypeInformation  

Run the Script together with y'all volition become output inward a CSV file equally inward the event below.




Thank y'all All!!



Sumber https://linuxhowtoguide.blogspot.com/

Tidak ada komentar:

Posting Komentar