Link to home
Start Free TrialLog in
Avatar of bibi92
bibi92Flag for France

asked on

select-string and exclude

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
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bibi92

ASKER

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
Avatar of bibi92

ASKER

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
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..
Avatar of bibi92

ASKER

Sorry, like I'm on several IT Operations, I don't note this.