Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - PerfMon PowerShell Query

Reply
 
Old 05-15-2008   #1 (permalink)
Amit Tank


 
 

PerfMon PowerShell Query

Below code checks the perfmon counter and gives me the value of a
instance
===============================
Function PerfMon($Server)
{
$Ojbect = "LogicalDisk"
$Counter = "% Free Space"
$Instence = "C:"
$perf = New-Object System.Diagnostics.PerformanceCounter($Ojbect,
$Counter, $Instence, $Server)
$p = $perf.RawValue
$p
}
$Computer = "ww"
PerfMon $computer
===============================

Is there any way to do a query for all instance of a counter and
object and give a value of those?

Eg. Script does a query for all available instances (_total, c:, d:,
e: etc..) itself instead of defining a value like $instence = “c:” and
gives the value of all.

Any help greatly appreciated.

My System SpecsSystem Spec
Old 05-15-2008   #2 (permalink)
Marco Shaw [MVP]


 
 

Re: PerfMon PowerShell Query

Quote:

> Is there any way to do a query for all instance of a counter and
> object and give a value of those?
>
> Eg. Script does a query for all available instances (_total, c:, d:,
> e: etc..) itself instead of defining a value like $instence = “c:” and
> gives the value of all.
>
> Any help greatly appreciated.
Try this out:
$perfc = New-Object System.Diagnostics.PerformanceCounterCategory
$perfc.categoryname="LogicalDisk"
$perfc.GetInstanceNames()

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 05-16-2008   #3 (permalink)
Amit Tank


 
 

Re: PerfMon PowerShell Query

Perfectly what I want. Thanks a lot...

On May 15, 10:44*am, "Marco Shaw [MVP]"
<marco.shaw@_NO_SPAM_gmail.com> wrote:
Quote:
Quote:

> > Is there any way to do a query for all instance of a counter and
> > object and give a value of those?
>
Quote:

> > Eg. Script does a query for all available instances (_total, c:, d:,
> > e: etc..) itself instead of defining a value like $instence = “c:”and
> > gives the value of all.
>
Quote:

> > Any help greatly appreciated.
>
> Try this out:
> $perfc = New-Object System.Diagnostics.PerformanceCounterCategory
> $perfc.categoryname="LogicalDisk"
> $perfc.GetInstanceNames()
>
> Marco
>
> --
> Microsoft MVP - Windows PowerShellhttp://www.microsoft.com/mvp
>
> PowerGadgets MVPhttp://www.powergadgets.com/mvp
>
> Blog:http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Is there a way to query DNS from powershell? PowerShell
LDS query via powershell PowerShell
Running WMI Query in without Powershell or VBS PowerShell
Query NT4 Domain from Powershell PowerShell
Query for ms-ds-creatorsid from Powershell PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46