Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Multiple computer prompt

$
0
0

I have a powershell script that goes out and collects data on multiple servers.  I have to edit a file and dump in the server names and then do get-content from within the script to get the server names.  I would like to instead kick off the script and have it prompt me for the server names I want to query.  I've tried doing read-host and entering the server names but it's not working.  How can I make that work?

$erroractionpreference = "SilentlyContinue"

$a = New-Object -comobject Excel.Application
$a.visible = $True

$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)

$c.Cells.Item(1,1)  = "Server Name"
$c.Cells.Item(1,2)  = "RAM(GB)"
$c.Cells.Item(1,3)  = "Model"
$c.Cells.Item(1,4)  = "Bios"
$c.Cells.Item(1,5)  = "CPU Count"
$c.Cells.Item(1,6)  = "Proc Model"
$c.Cells.Item(1,7)  = "Core Count"
$c.Cells.Item(1,8)  = "Drive"
$c.Cells.Item(1,9)  = "Size(GB)"
$c.Cells.Item(1,10)  = "Drive"
$c.Cells.Item(1,11)  = "Size(GB)"
$c.Cells.Item(1,12)  = "Drive"
$c.Cells.Item(1,13)  = "Size(GB)"
$c.Cells.Item(1,14)  = "Drive"
$c.Cells.Item(1,15)  = "Size(GB)"
$c.Cells.Item(1,16)  = "Drive"
$c.Cells.Item(1,17)  = "Size(GB)"
$c.Cells.Item(1,18)  = "Drive"
$c.Cells.Item(1,19)  = "Size(GB)"
$c.Cells.Item(1,20)  = "Drive"
$c.Cells.Item(1,21)  = "Size(GB)"
$c.Cells.Item(1,22)  = "Drive"
$c.Cells.Item(1,23)  = "Size(GB)"
$c.Cells.Item(1,24)  = "Drive"
$c.Cells.Item(1,25)  = "Size(GB)"
$c.Cells.Item(1,26)  = "Drive"
$c.Cells.Item(1,27)  = "Size(GB)"
$c.Cells.Item(1,28)  = "Drive"
$c.Cells.Item(1,29)  = "Size(GB)"

$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True

$intRow = 2

$colComputers = gc c:\mylist.txt

foreach ($strComputer in $colComputers)
{
$comp = gwmi Win32_computersystem -computername $strComputer
$proc = gwmi Win32_processor -computername $strComputer
$ProcType = @(get-wmiobject Win32_Processor -computername $strcomputer)
$proccount = (gwmi win32_processor -computername $strcomputer | select socketdesignation -unique | measure-object).count
$corecount = @($proc)[0].numberofcores
$disk = gwmi -computername $strcomputer -query "select * from win32_logicaldisk where drivetype = 3"
$bios = gwmi win32_bios -computername $strcomputer
$biosDate = $bios.ReleaseDate -replace '^(....)(..)(..).+$', '$2/$3/$1'
$strBios = $bios.Manufacturer + ' ' + $bios.SMBIOSBIOSVersion + ', ' + $biosDate


$c.Cells.Item($intRow,1)  = $comp.name
$c.Cells.Item($intRow,2)  = "{0:N0}" -f ($comp.TotalPhysicalMemory/1GB)
$c.Cells.Item($intRow,3)  = $comp.Model
$c.Cells.Item($intRow,4)  = $strbios
$c.Cells.Item($intRow,5)  = $proccount
$c.Cells.Item($intRow,6)  = $ProcType[0].name 
$c.Cells.Item($intRow,7)  = $corecount
$c.Cells.Item($intRow,8)  = $disk[0].deviceid
$c.Cells.Item($intRow,9)  = "{0:N2}" -f ($Disk[0].Size/1GB)
$c.Cells.Item($intRow,10)  = $disk[1].deviceid
$c.Cells.Item($intRow,11)  = "{0:N2}" -f ($Disk[1].Size/1GB)
$c.Cells.Item($intRow,12)  = $disk[2].deviceid
$c.Cells.Item($intRow,13)  = "{0:N2}" -f ($Disk[2].Size/1GB)
$c.Cells.Item($intRow,14)  = $disk[3].deviceid
$c.Cells.Item($intRow,15)  = "{0:N2}" -f ($Disk[3].Size/1GB)
$c.Cells.Item($intRow,16)  = $disk[4].deviceid
$c.Cells.Item($intRow,17)  = "{0:N2}" -f ($Disk[4].Size/1GB)
$c.Cells.Item($intRow,18)  = $disk[5].deviceid
$c.Cells.Item($intRow,19)  = "{0:N2}" -f ($Disk[5].Size/1GB)
$c.Cells.Item($intRow,20)  = $disk[6].deviceid
$c.Cells.Item($intRow,21)  = "{0:N2}" -f ($Disk[6].Size/1GB)
$c.Cells.Item($intRow,22)  = $disk[7].deviceid
$c.Cells.Item($intRow,23)  = "{0:N2}" -f ($Disk[7].Size/1GB)
$c.Cells.Item($intRow,24)  = $disk[8].deviceid
$c.Cells.Item($intRow,25)  = "{0:N2}" -f ($Disk[8].Size/1GB)
$c.Cells.Item($intRow,26)  = $disk[9].deviceid
$c.Cells.Item($intRow,27)  = "{0:N2}" -f ($Disk[9].Size/1GB)
$c.Cells.Item($intRow,28)  = $disk[10].deviceid
$c.Cells.Item($intRow,29)  = "{0:N2}" -f ($Disk[10].Size/1GB)

$intRow = $intRow + 1
}
$d.EntireColumn.AutoFit()
cls


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>