Solved

build a list disk to exclude of monitoring

Posted on 2013-05-29
4
283 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
[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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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…

732 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