Solved

select-string and exclude

Posted on 2013-06-03
5
1,302 Views
Last Modified: 2013-06-03
Hello,

I try to add exclude on this command, but it does not work :
$SPEC_DISK = @( Select-String $MONITORING_ENV -Pattern "^(.+):DISK:$"  -exclude "^([A-Z]:\\.+):DISK:OFF"| ForEach-Object { $_.matches } | ForEach-Object { $_.groups[1].value } | Select -Unique)

How can I resolve it?

Thanks
0
Comment
Question by:bibi92
  • 3
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
Comment Utility
Try..
$SPEC_DISK = @( Select-String $MONITORING_ENV -Pattern "^(.+):DISK:$" |? {$_ -notmatch "^([A-Z]:\\.+):DISK:OFF"} | ForEach-Object { $_.matches } | ForEach-Object { $_.groups[1].value } | Select -Unique)

Open in new window

0
 

Author Comment

by:bibi92
Comment Utility
No result, $Monitoring_env is a txt file which contains
z:\mssql:FS:20%:30%
z:\mssql\:FS:20%:30%
k:\mssql:FS:OFF
k:\mssql\:FS:OFF
Thanks
0
 

Author Closing Comment

by:bibi92
Comment Utility
I have remove $
$SPEC_DISK = @( Select-String $MONITORING_ENV -Pattern "^(.+):DISK:" |? {$_ -notmatch "^([A-Z]:\\.+):DISK:OFF"} | ForEach-Object { $_.matches } | ForEach-Object { $_.groups[1].value } | Select -Unique)
Thanks
0
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
No result, $Monitoring_env is a txt file which contains
z:\mssql:FS:20%:30%
z:\mssql\:FS:20%:30%
k:\mssql:FS:OFF
k:\mssql\:FS:OFF
Thanks
BTB the the lines which you posted doesn't contain anything which is matching to the pattern in code..
0
 

Author Comment

by:bibi92
Comment Utility
Sorry, like I'm on several IT Operations, I don't note this.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Hi all.   The other day I had to change the passwords for a bunch of users on the fly. Because they were so many, I decided to do it in an automated way and I would like to share it with you all.   If you are not doing it directly in a Domain Co…
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now