Solved

find $warning and the $critical for a FS

Posted on 2013-06-03
2
223 Views
Last Modified: 2013-06-04
Hello

Monitoring.txt contains :

z:\mssql:FS:20%:30%
z:\mssql\:FS:20%:30%
k:\mssql:FS:OFF
k:\mssql\:FS:OFF

I search to modify the following code to find the $warning and the $critical for a FS
$thresholds = @()
get-content $MONITORING | ? { $_ -like '*:FS:*%' } | % {
  $val = $_ -split ':' -replace '%'
  $thresholds += New-Object PsObject -Property @{
    $fs       = $val[0]+':'+$val[1]
    $warning  = $val[3]
    $critical = $val[4]
  }
}
$thresholds

How can I do it?
0
Comment
Question by:bibi92
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39216400
When you create PS object use the property name (you have used VAR, if you have property names assigned to this VAR's then it will work)..

$thresholds = @()
get-content $MONITORING | ? { $_ -like '*:FS:*%' } | % {
  $val = $_ -split ':' -replace '%'
  $thresholds += New-Object PsObject -Property @{
    fs       = $val[0]+':'+$val[1]
    warning  = $val[3]
    critical = $val[4]
  }
}
$thresholds 

Open in new window

0
 

Author Closing Comment

by:bibi92
ID: 39218494
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

25 Experts available now in Live!

Get 1:1 Help Now