Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

PerfMon PowerShell Query

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 05-15-2008   #1 (permalink)
Amit Tank
Guest


 

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]
Guest


 

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
Guest


 

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
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
LDS query via powershell H4mm3r PowerShell 12 07-09-2008 05:53 AM
Translate WMIC query to Powershell Chad PowerShell 0 12-06-2007 12:24 PM
Running WMI Query in without Powershell or VBS greatbarrier86 PowerShell 5 08-23-2007 01:58 AM
Query NT4 Domain from Powershell Gaurhoth PowerShell 1 01-16-2007 03:37 PM
Query for ms-ds-creatorsid from Powershell gaurhoth PowerShell 6 11-04-2006 03:42 PM


Vistax64.com 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 2005-2008

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 47 48 49 50 51