select-string

Matches not captured when using -SimpleMatch with Select-String

喜你入骨 提交于 2019-12-11 20:11:44
问题 I have been using regex to parse text within some XML nodes. However, when I use -SimpleMatch with Select-String , the MatchInfo object doesn't appear to contain any matches. I am unable to find anything online that indicates this behavior is normal. I am now wondering if it is my Powershell installation. (For reference: the computer I'm using has Powershell 3.0 installed.) Using a very simple example, we can return the expected MatchInfo Object when using the regex patterning: PS H:\> $c =

Powershell - Sorting and selecting files in foreach loop

做~自己de王妃 提交于 2019-12-11 18:27:21
问题 I'm trying to create a script that will find the most recent build_info files from multiple install locations in a server's directory, select the "version: " text from each file, and compare them to see if they're all the same (which is what we hope for), or if certain install locations have different versions. As a bonus, it would also be nice to have each path's install version have its own variable so that if I have to output any differences, I can say which specific paths have which

Select-String issue working intermittently

不问归期 提交于 2019-12-11 06:12:49
问题 I have some code that works sometimes and others not. I see no errors when it fails so I am stuck as to why its intermittent. I am using the Select-String cmdlet which will find many matches which is what I want. I am also using the same text file as my test so its not the data being searched changing. $Hospinput.Text is the item being input to search for. The content of the search file is: Windows 7 Clinical Complete Nursing A3S Windows 7 Clinical Complete Nursing A3S Wireless Windows 7

PowerShell: Searching for a part of a string in a logfile

ぐ巨炮叔叔 提交于 2019-12-08 01:10:57
问题 I am trying to search for a pattern, "Error", in a series of logfiles, then writing the results to a textfile. I am using the command: foreach($file in $files){ $match = get-content $file | Select-String $p | Out-File $matchfile } The pattern $p has been taken in from the command line. I am running the script on Windows Server 2008 R2, and it returns results if "Error" is a single word in the logfile. I have instances of "ErrorCode" which I'd like the script to identify. I have the code

PowerShell: Searching for a part of a string in a logfile

烂漫一生 提交于 2019-12-06 05:58:36
I am trying to search for a pattern, "Error", in a series of logfiles, then writing the results to a textfile. I am using the command: foreach($file in $files){ $match = get-content $file | Select-String $p | Out-File $matchfile } The pattern $p has been taken in from the command line. I am running the script on Windows Server 2008 R2, and it returns results if "Error" is a single word in the logfile. I have instances of "ErrorCode" which I'd like the script to identify. I have the code working on Windows 7 as I'd like. I however am getting no results when I run the script on Windows Server

How to get the captured groups from Select-String?

耗尽温柔 提交于 2019-11-28 08:53:17
I'm trying to extract text from a set of files on Windows using the Powershell (version 4): PS > Select-String -AllMatches -Pattern <mypattern-with(capture)> -Path file.jsp | Format-Table So far, so good. That gives a nice set of MatchInfo objects: IgnoreCase LineNumber Line Filename Pattern Matches ---------- ---------- ---- -------- ------- ------- True 30 ... file.jsp ... {...} Next, I see that the captures are in the matches member, so I take them out: PS > Select-String -AllMatches -Pattern <mypattern-with(capture)> -Path file.jsp | ForEach-Object -MemberName Matches | Format-Table Which

How to get the captured groups from Select-String?

非 Y 不嫁゛ 提交于 2019-11-27 02:29:23
问题 I'm trying to extract text from a set of files on Windows using the Powershell (version 4): PS > Select-String -AllMatches -Pattern <mypattern-with(capture)> -Path file.jsp | Format-Table So far, so good. That gives a nice set of MatchInfo objects: IgnoreCase LineNumber Line Filename Pattern Matches ---------- ---------- ---- -------- ------- ------- True 30 ... file.jsp ... {...} Next, I see that the captures are in the matches member, so I take them out: PS > Select-String -AllMatches