Solved

select-string and exclude

Posted on 2013-06-03
5
1,442 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
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to set share permission on folders - Everyone Permission 20 48
powershell mailbox move question 8 43
Powershell Code 3 41
Ruby or Python 7 41
Synchronize a new Active Directory domain with an existing Office 365 tenant
This article will help you understand what HashTables are and how to use them in PowerShell.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
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…

680 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