arrays - Creating and populating a hash table -
I'm looking to either create a non-zipped array or a hash table (I'm not sure the difference Nor do I want to work). I am trying to do this.
I want to check a list of servers for many values and then want to store these values in a CSV file. Here's the code.
$ allServers = "svr1", "svr2", "svr3" $ a = @ {} $ outdata = new object PSObject $ allServers | {$ Cpu = (Get-WMIObject win32_processor -ComputerName $ _) for every object. Length $ mem = (Get-WMIObject win32_physicalmemory -ComputerName $ _) Capacity / $ 1GB outData | Add-member-type note property -name "SERVERNAME" -pack $ _ $ outData | Add-member-type note property -name "#CPU" -Value $ cpu $ outData | Type the add-member-type NoteProperty -name "#GBRAM" -Value $ mem} Host $ outData I'm getting errors because it seems like it is repeatedly Is trying to create entries only. Is it possible to create an empty hash table (or non-toothed array) with the column name and then simply assume? "text" itemprop = "text" svr3
$ allServers = "svr1", "svr2" ":>
Create an object inside the loop, output it, and assign the value of the entire pipeline to your array variable "$ A = $ allServers | Foreach-object {$ cpu = (Get-WmiObject Win32_Processor -ComputerName $ _) Length $ mem = (Get-WmiObject win32_physicalmemory -ComputerName $ _) Capacity / 1GB $ outData = New-Object PSObject $ outData .. | Add-member-type note property -name "SERVERNAME" -pack $ _ $ outData | Add-member-type note property -name "#CPU" -Value $ cpu $ outData | Add-member-type NoteProperty -name "#GBRAM" -Value $ mem $ outData} a $ | Export-CSV $ path- Any type information
Comments
Post a Comment