Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

select-string and exclude

Posted on 2013-06-03
5
Medium Priority
?
1,652 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 39216046
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
ID: 39216074
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
ID: 39216093
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
ID: 39216116
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
ID: 39216942
Sorry, like I'm on several IT Operations, I don't note this.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief introduction to what I consider to be the best editor for PowerShell.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

597 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