Solved

build a list disk to exclude of monitoring

Posted on 2013-05-29
4
275 Views
Last Modified: 2013-05-29
Hello

A txt file monitoring.env contains a list for exclude windows disk of monitoring

k:\\data\\sql\\:DISK:OFF
k:\\data1\\sql\\:DISK:OFF

With the folowing code, only the first line k:\\data\\sql\\:DISK:OFF is read :
$MONITORING = gci -Recurse ($CONF_INST_CONFIG) -in *.env
$EXCLUDE_DISK=get-content $MONITORING | where-object {$_.contains(":DISK:OFF")} |Foreach-Object {$_ -replace ":DISK:OFF", ""} -ErrorAction silentlycontinue
if ($EXCLUDE_DISK -ne $null) {
$LIST_EXCLUDE_DISK =  [string]::join('', $EXCLUDE_DISK) + ''
}
How can I modify it?

Thanks
0
Comment
Question by:bibi92
  • 3
4 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39204535
$MONITORING = gci -Recurse ($CONF_INST_CONFIG) -in *.env 
$EXCLUDE_DISK=$MONITORING | %{ gc $_ | where-object {$_.contains(":DISK:OFF")} 
|Foreach-Object {$_ -replace ":DISK:OFF", ""} -ErrorAction silentlycontinue
}
if ($EXCLUDE_DISK -ne $null) {
$LIST_EXCLUDE_DISK =  [string]::join('', $EXCLUDE_DISK) + ''
}

Open in new window


are you trying to change the txt file in the process?
what's the -replace used for?
0
 

Author Comment

by:bibi92
ID: 39204825
No I'm not trying to change the txt file in the process.
The replace is used before executing
$LIST_DISK_1 = Get-WmiObject Win32_Volume -Filter "DriveType!='5' and not label like '%OS%'" |where-object {$_.name -notmatch $LIST_EXCLUDE_DISK}
I try your code but the result is the same.
0
 

Author Comment

by:bibi92
ID: 39205087
where-object {$_.name -notmatch $LIST_EXCLUDE_DISK} does not work because
"k:\\data\\sql\\ k:\\data1\\sql\\"

How can I resolve it?
0
 

Author Closing Comment

by:bibi92
ID: 39206174
Thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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 …
Synchronize a new Active Directory domain with an existing Office 365 tenant
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

14 Experts available now in Live!

Get 1:1 Help Now