?
Solved

build a list disk to exclude of monitoring

Posted on 2013-05-29
4
Medium Priority
?
285 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 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

777 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