![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Newbie question This works ok if I run this directly from a ps prompt but I get an error when I try to pass it to powershell.exe. What am I doing wrong? C:\....v1.0>powershell.exe "(get-wmiobject Win32_PerfFormattedData_PerfProc_Process -filter "name = 'sqlservr'").PercentProcessorTime" Get-WmiObject : A parameter cannot be found that matches parameter name 'sqlservr'. At line:1 char:15 + (get-wmiobject <<<< Win32_PerfFormattedData_PerfProc_Process - filter name = 'sqlservr').PercentProcessorTime |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Newbie question The quotes hell . Here's a workaround. It works when typed into CMD.exepowershell.exe "(get-wmiobject Win32_PerfFormattedData_PerfProc_Process -filter """name ='sqlservr'""").PercentProcessorTime" -or- powershell.exe -command "(get-wmiobject Win32_PerfFormattedData_PerfProc_Process -filter """name ='sqlservr'""").PercentProcessorTime" Shay http://scriptolog.blogspot.com Quote: > This works ok if I run this directly from a ps prompt but I get an > error when I try to pass it to powershell.exe. What am I doing wrong? > > C:\....v1.0>powershell.exe "(get-wmiobject > Win32_PerfFormattedData_PerfProc_Process -filter "name = > 'sqlservr'").PercentProcessorTime" > Get-WmiObject : A parameter cannot be found that matches parameter > name 'sqlservr'. > At line:1 char:15 > + (get-wmiobject <<<< Win32_PerfFormattedData_PerfProc_Process - > filter name = 'sqlservr').PercentProcessorTime |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Newbie question Or escape the inside double quotes powershell.exe -command "(get-wmiobject Win32_PerfFormattedData_PerfProc_Process -filter \"name ='sqlservr'\").PercentProcessorTime" Shay http://scriptolog.blogspot.com Quote: > The quotes hell . Here's a workaround. It works when typed into> CMD.exe > > powershell.exe "(get-wmiobject > Win32_PerfFormattedData_PerfProc_Process -filter """name > ='sqlservr'""").PercentProcessorTime" > > -or- > > powershell.exe -command "(get-wmiobject > Win32_PerfFormattedData_PerfProc_Process -filter """name > ='sqlservr'""").PercentProcessorTime" > > Shay > http://scriptolog.blogspot.com Quote: >> This works ok if I run this directly from a ps prompt but I get an >> error when I try to pass it to powershell.exe. What am I doing wrong? >> >> C:\....v1.0>powershell.exe "(get-wmiobject >> Win32_PerfFormattedData_PerfProc_Process -filter "name = >> 'sqlservr'").PercentProcessorTime" >> Get-WmiObject : A parameter cannot be found that matches parameter >> name 'sqlservr'. >> At line:1 char:15 >> + (get-wmiobject <<<< Win32_PerfFormattedData_PerfProc_Process - >> filter name = 'sqlservr').PercentProcessorTime |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Newbie question Thanks Shay. That worked like a champ. I actually had to add more quotes when I moved it into SQL. I am having more problems with this one. PS C:\Windows\System32\WindowsPowerShell\v1.0> (get-wmiobject Win32_PerfFormattedData_PerfDisk_PhysicalDisk -filter "name = 'c:'").AvgDiskSecPerRead It is coming back with nothing even if I remove the filter. All google gets me is vb script samples for this and similar classes. Is there a good starting place? I guess I need something more basic than http://www.microsoft.com/technet/scr...mshandwmi.mspx |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Newbie question Here is a start (get-wmiobject Win32_PerfFormattedData_PerfDisk_PhysicalDisk -filter "name like '%c%'").AvgDiskSecPerRead Shay http://scriptolog.blogspot.com Quote: > Thanks Shay. That worked like a champ. I actually had to add more > quotes when I moved it into SQL. I am having more problems with this > one. > > PS C:\Windows\System32\WindowsPowerShell\v1.0> (get-wmiobject > Win32_PerfFormattedData_PerfDisk_PhysicalDisk -filter "name = > 'c:'").AvgDiskSecPerRead > > It is coming back with nothing even if I remove the filter. All google > gets me is vb script samples for this and similar classes. > > Is there a good starting place? I guess I need something more basic > than > http://www.microsoft.com/technet/scr.../mshandwmi.msp > x > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Newbie question BTW, this NG is the best place to start ![]() Shay http://scriptolog.blogspot.com Quote: > Here is a start > > (get-wmiobject Win32_PerfFormattedData_PerfDisk_PhysicalDisk -filter > "name like '%c%'").AvgDiskSecPerRead > > Shay > http://scriptolog.blogspot.com Quote: >> Thanks Shay. That worked like a champ. I actually had to add more >> quotes when I moved it into SQL. I am having more problems with this >> one. >> >> PS C:\Windows\System32\WindowsPowerShell\v1.0> (get-wmiobject >> Win32_PerfFormattedData_PerfDisk_PhysicalDisk -filter "name = >> 'c:'").AvgDiskSecPerRead >> >> It is coming back with nothing even if I remove the filter. All >> google gets me is vb script samples for this and similar classes. >> >> Is there a good starting place? I guess I need something more basic >> than >> http://www.microsoft.com/technet/scr...h/mshandwmi.ms >> p x >> |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Newbie question Here are some simple SQL scripts. Getting this info inside SQL was relatively difficult before. Thanks again! insert into @tmp(c1) exec xp_cmdshell 'powershell.exe -command "(get-wmiobject Win32_PerfFormattedData_PerfProc_Process -filter """name =''sqlservr''""").PercentProcessorTime"' select c1 as cpu from @tmp where c1 is not null declare @tmp table (c1 int) insert into @tmp(c1) exec xp_cmdshell 'powershell.exe -command "(get-wmiobject Win32_PerfFormattedData_PerfDisk_PhysicalDisk -filter """name like''%total%''""").AvgDiskSecPertransfer"' select c1 as AvgDiskSecPertransfer from @tmp where c1 is not null |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| a newbie with a question | Virtual PC | |||
| Newbie question | PowerShell | |||
| Newbie question | Graphic cards | |||
| Just a newbie question | General Discussion | |||
| RE: Newbie Question | PowerShell | |||