Need help with text file parse
i know powershell (enough by); however, have ran issue in cant find answer on google..
have test.audit file (for example) contains
<check_type> <custom_item> system : "linux" type : "check" description : "8.1.1.2 other text blah blah" </custom_item> <custom_item> system : "linux" type : "check" description : "8.1.1.1 more text blah blah" </custom_item> <custom_item> system : "linux" type : "check" description : "8.1.1.3 text blah blah" </custom_item> </check_type>
looks xml file, not in traditional format i'm use to.
anyway, using test.audit file.. trying delete entire "custom_item" string contains description of "8.1.1.1".
new file like
<check_type> <custom_item> system : "linux" type : "check" description : "8.1.1.2 other text blah blah" </custom_item> <custom_item> system : "linux" type : "check" description : "8.1.1.3 text blah blah" </custom_item> </check_type>
the thing has replied me on forum create parser, when makes seem single line of text only.
can me this..
thanks
there smarter way, worked me:
[xml]$weirdfile = get-content 'c:\users\mikecrowley\desktop\new folder\file.txt' $resultsarray = $weirdfile.check_type.custom_item | {$_ -notlike '*description : "8.1.1.2*'} #display results $resultsarray
mike crowley | mvp
my blog -- baseline technologies
Windows Server > Windows PowerShell
Comments
Post a Comment