Adding multiple output to rich text box
-
Wednesday, January 09, 2013 9:09 PM
I am trying to write a comp info gui tool..
input is richtextbox1....which can accept multiple hostnames
Button to run the function compinfo.
output is richtextbox2.
I want to use the same Object for all the servers and property only should change.
Note :The display should be in richtextbox2ex:
servername domain model
host1 abc xx
host2 dav XyCurrently its showing as
servername domain model
host1 abc xx
servername domain model
host1 dav Xy
==================== function what i am using is below====Function CompInfo {
$s = $s = $richtextbox1.text.split("`n")foreach ($sv in $s){
$info = Get-WmiObject win32_computersystem -computername $sv | Format-Table @{Name="Server Name";Expression={"{0:N1}" -f($_.Caption)}},Domain,Model,Systemtype,@{Name="Physical Memory(GB)";Expression={"{0:N1}" -f($_.totalphysicalmemory/1gb)}} | out-stringForEach-Object in $info {
$richtextbox2.Appendtext("{0}`n" -f $dis)
}
}- Moved by Script Explorer Administration Wednesday, January 09, 2013 11:26 PM Scripting 'how to' question (From:Script Explorer for Windows PowerShell)
All Replies
-
Wednesday, January 09, 2013 11:33 PM
Is there a question?
Happy New Year ¯\_(ツ)_/¯
-
Thursday, January 10, 2013 6:26 AM
sorry for the confusion.
I am currently getting the display as
servername domain model
host1 abc xx
servername domain model
host1 dav XyI want the display to be
servername domain model
host1 abc xx
host2 dav Xy -
Thursday, January 10, 2013 7:35 AM
Function CompInfo { $s=$richtextbox1.text.split("`n") $info=Get-WmiObject win32_computersystem -computername $s | Format-Table @{Name="Server Name";Expression={"{0:N1}" -f($_.Caption)}},Domain,Model,Systemtype,@{Name="Physical Memory(GB)";Expression={"{0:N1}" -f($_.totalphysicalmemory/1gb)}} | out-string $richtextbox2.Appendtext($info) }¯\_(ツ)_/¯
- Marked As Answer by mohdazam89 Thursday, January 10, 2013 1:11 PM
-
Thursday, January 10, 2013 2:10 PM
Hi Jrv,
Thanks that works.
For the samething if i want the diskspace for multiple computers i am getting an error.
Its working good for single computer..But if iam entering multiple hostnames...its throwing rpc error.
Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At C:\Users\Yasi\Desktop\dev.ps1:17 char:26
+ $disk = Get-WmiObject <<<< win32_logicaldisk -computername $servers |
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException
+ FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand=========
Function Disk {
$richTextBox2.Text = $richTextBox2.Text.Clear
$servers=$richTextbox1.Text.split("'n")
$disk = Get-WmiObject win32_logicaldisk -computername $server -filter "$drivetype=3" |
Format-table @{Name="Server Name";Expression={"{0:N1}" -f ($_.SystemName)}},DeviceID,VolumeName,@{Name="Size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}},@{Name="FreeSpace(GB)";Expression={"{0:N1}" -f($_.freespace/1gb)}} -autosize | Out-String
$richtextbox2.Appendtext($disk)
} -
Thursday, January 10, 2013 2:56 PM
That is not a scripting issue. You need to fix your WMI.
\
¯\_(ツ)_/¯
-
Thursday, January 10, 2013 3:53 PM
Thanks Jrv ...able to fix wmi... above in -filter have defined object as an variable...that was the issue..
Thanks for your input ...was able to fix it...
-
Thursday, January 10, 2013 3:57 PM
Thanks Jrv ...able to fix wmi... above in -filter have defined object as an variable...that was the issue..
Thanks for your input ...was able to fix it...
That is not possible. You cannot get that error from a bad variable. It can only come from accessing a machine with no WMI or faulty WMI.
¯\_(ツ)_/¯
-
Thursday, January 10, 2013 4:48 PM
i was just testing that on my local machine.
the hostnames what i have entered in the input box were
localhost
localhost...then again...i am just a fresher in powershell....not sure...
Thanks again
-
Thursday, January 10, 2013 6:55 PM
i was just testing that on my local machine.
the hostnames what i have entered in the input box were
localhost
localhost...then again...i am just a fresher in powershell....not sure...
Thanks again
so what is wrong with that. It is a name that does not exist. I don't see where this has anything to do with variables or scripting.
An old rule of the computer trade is "garbage in - garbage out"
¯\_(ツ)_/¯

