![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Different results from the same -match statement Based on this page (http://blogs.technet.com/otto/archive/2007/03/04/ quick-and-dirty-software-inventory-with-psinfo-and-powershell.aspx) I'm playing around with finding the version of SQL Server running on different boxes. Because there are multiple SQL server programs on the install list returned by psinfo.exe, I'm filtering the output to try and get just the one with the main version on. This is an excerpt of the list returned: Microsoft SQL Server 2005 9.2.3042.00 Microsoft SQL Server 2005 Microsoft SQL Server 2005 Backward compatibility 8.05.2004 Microsoft SQL Server 2005 Integration Services 9.2.3042.00 Microsoft SQL Server 2005 Tools 9.2.3042.00 and I want just the first one (with 9.2.3042.00, which is what I'm interested in). Now what's puzzling me is if I run this command: psinfo.exe -S Applications|?{$_ -like "Microsoft SQL Server 2005 [0-9]"} I get nothing returned - but if I copy the output from psinfo.exe into a text file and then run that through powershell, I get this: PSH H:\WindowsPowerShell > get-content c:\work\tmp.txt|?{$_ -match "Microsoft SQL Server 2005 [0-9]"} Microsoft SQL Server 2005 9.2.3042.00 PSH H:\WindowsPowerShell > i.e. the same -match statement picks up the row i want if it's from get-content but not as the piped output from psinfo.exe. I've done a get-member on each and they're both system.string. Am i missing something obvious here? Thanks, robin. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Different results from the same -match statement > Am i missing something obvious here? Probably, look, you use -like in your command, mot -match -- Thanks, Roman Kuzmin PowerShellFar and FarNET: http://code.google.com/p/farnet/ |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Different results from the same -match statement On Aug 13, 12:10 pm, "Roman Kuzmin" <z...@z.z> wrote: > > Am i missing something obvious here? > > Probably, look, you use -like in your command, mot -match > d'oh :-) double d'oh because i've realised that the software listing doesn't report the latest patch version of sql server but anyway, my question about the difference between the two statements stands, I'm just interested to why it is cheers. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Different results from the same -match statement -like = Wild Card Comparison -match = Regex Comparison May I recommend: PS> Get-help about_Comparison_Operators p.s. I believe there are native POSH ways to get the info your looking for. What is your goal? "Robin Moffatt" <robin.moffatt@gmail.com> wrote in message news:1187004432.494029.220580@g4g2000hsf.googlegroups.com... > On Aug 13, 12:10 pm, "Roman Kuzmin" <z...@z.z> wrote: >> > Am i missing something obvious here? >> >> Probably, look, you use -like in your command, mot -match >> > > d'oh :-) > > double d'oh because i've realised that the software listing doesn't > report the latest patch version of sql server > > but anyway, my question about the difference between the two > statements stands, I'm just interested to why it is > > cheers. > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| If statement with a message | VB Script | |||
| Help with SQL statement | VB Script | |||
| Results from Regular Expression Match | PowerShell | |||
| just a statement | Vista General | |||