Send email after finding out the PrimaryStatus of the hard drives

Hi,
I have a script that will run through all names in the active directory and scan each to find things like the name, model, driveUsage and Primary status. However, I don't want to go through all logs to find the failing hard drive in one of the computers.
I want to be able to send an email if one of the hard drives in any computer fails (PrimaryStatus is 2 or 3). My current script is:
Import-Module ActiveDirectory
$Computers = Get-ADComputer -Filter "OperatingSystem -NotLike '*Windows Server*'" | ForEach-Object {$_.Name} | 
out-file names.txt
$computerNames = Get-Content -Path C:\scripts\names.txt
foreach ($computer in $computerNames) {
  $rtn = Test-Connection -computername $computer -Count 1 -BufferSize 16 -Quiet
  IF($rtn -match 'True') {
  write-host "$computer"
  gwmi -Namespace root\dcim\sysman -computername $computer -Class DCIM_PhysicalDiskView | select-object Ele*,Mod*,Ser*,Driveu*,pri* | Format-table –autosize
  ELSE { Write-host "$computer not pingable" }
Any help on this will be greatly appreciated. Thanks!

there's a few ways you can do that, the first that comes to mind. (insert into your script
$AlertNums = @("2","3")
$smtpserver = "1.2.3.4" # your mail server here
$smtpFrom = "[email protected]" # your from address, mail server will most likely allow any
$smtpTo = "[email protected]" #your email address here. can also be an array and will send to all
$MessageSubject = "Failed Disk in $Computer" #whatever you want the subject to be.
$Computers = Get-ADComputer -Filter "OperatingSystem -NotLike '*Windows Server*'" | ForEach-Object {$_.Name} |
out-file names.txt
$computerNames = Get-Content -Path C:\scripts\names.txt
foreach ($computer in $computerNames)
    $rtn = Test-Connection -computername $computer -Count 1 -BufferSize 16 -Quiet
    IF($rtn -match 'True')
    write-host "$computer"
    $Disks = gwmi -Namespace root\dcim\sysman -computername $computer -Class DCIM_PhysicalDiskView | select-object Ele*,Mod*,Ser*,Driveu*,pri*
    ForEach($Disk in $Disks)
            if($AlertNums -contains $($Disk.PrimaryStatus))
                Send-MailMessage -SmtpServer $smtpserver -from $smtpFrom -to $smtpto -subject $messageSubject
    ELSE
        Write-host "$computer not pingable"
Reference: http://technet.microsoft.com/en-us/library/hh849925.aspx
Edit: added my code to your original script.

Similar Messages

  • How do I find out how much of my hard drive space is used up

    I have a Mac OS X Version 10.7.5. Processor 2.66 GHz Intel Core 2 Duo; Memory 2 GB 1067 MHz DDR3. Computer is running very slow. I cleared downloads and reset Safari, emptied trash, etc. How  can I find out how much space I have left on my hard drive?

    As you appear to have at least OS 10.7 installed, you can simply highlight your hard drive and press the SPACE bar to get this:

  • How to find out size of Apple TV hard drive?

    A friend of mine recently gave me an old 1st generation Apple TV to sell on eBay. He doesn't remember which size hard drive it has (40GB or 160GB), and I'm having difficulty finding it. Does anyone know where to find that info? Thanks.

    The folllowing instructions assume that your Apple TV is up and running, and is regustered with iTunes.  If this is not te case, you'll have to resort to finding and matching model numbers as other posters have inicated.  It also applies only to the 1st Generation Apple TV (the silver one).
    In iTunes 9 or higher, select the Apple TV that appears in the devices list.  There is a capacity bar that shows you what space is used for what media type, but it also indicates the space remaining on the drive.  From that, you can deduce the size of the Apple TV's internal hard disk.
    --tonza

  • How do I find out what's on my hard drive and clean it up

    The hard drive is filled with "other", not video or photos.  I don't know what's clogging it up or how to get it cleaned up.  Please help.

    What is "Other" and What Can I Do About It?- Apple Support Communities
    Freeing Up Space on The Hard Drive
      1. See Lion/Mountain Lion/Mavericks' Storage Display.
      2. You can remove data from your Home folder except for the /Home/Library/ folder.
      3. Visit The XLab FAQs and read the FAQ on freeing up space on your hard drive.
      4. Also see Freeing space on your Mac OS X startup disk.
      5. See Where did my Disk Space go?.
      6. See The Storage Display.
    You must Empty the Trash in order to recover the space they occupied on the hard drive.
    You should consider replacing the drive with a larger one. Check out OWC for drives, tutorials, and toolkits.
    Try using OmniDiskSweeper 1.8 or GrandPerspective to search your drive for large files and where they are located.

  • ICal keeps sending email notifications from all agenda items from the last 2 years. After laptop start up this action is repeated every hour. How can I stop these 300 emails coming in every hour?

    iCal keeps sending email notifications of all agenda items from the last 2 years (then I bought my laptop). After laptop start up this action is repeated every hour. How can I stop these >300 emails coming in every hour?

    Hi,
    We have rolled out a fix for this issue.
    Please log off and log back in to your machine and the issue should be resolved automatically. In case that does not work, please manually run the msi installer posted here (may require reboot).
    For details, please refer to the KB article here: Multiple RunOnce keys created 11.0.10 and 10.1.13 Acrobat | Reader
    Please let us know if you still face any issues.
    Thanks,
    Ashu Mittal

  • TS1424 I have several incomplete songs after purchase from Itunes.  I sent out an email to find out how do I correct this problem? Follow-Up: 219141808

    I have 6-7 incomplete songs after purchase from Itunes.  I sent out an email to find out how do I correct this problem? Follow-up 219141808

    Welcome to the Apple Community.
    Try deleting the problematic file (electing to remove original file if/when prompted) and then re-downloading the file from the iTunes store.
    You can re-download content purchased from the iTunes store (availability varies depending on location) using the purchased option from the Quick Links section in the top right corner of the iTunes homepage in your iTunes application on your computer.
    You can re-download content purchased from the iTunes store (availability varies depending on location) using the purchased option at the bottom of the screen of the iTunes app (or video app) on your iOS device.
    If the problem re-occurs, select the content which is causing a problem and use the 'Report a problem' button in Your Purchase History using your computer.

  • After seeing the production in London I purchased the whole sound track and it did not completely load. I've never had this problem Today I am downloading an album only to find out it's missing the voacals. Do I have to start just settling for this kinds

    After seeing the production of Matilda in London I purchased the whole sound track and it did not completely load. I've never had this problem before so I just forgot about it. Today I am downloading an album only to find out it's missing the voacals. Do I have to start just settling for these kinds things. I'm feeling taken.

    Hello MarkFKenny,
    If you feel that there is an issue with a purchase made, you can report an issue with said purchase to the folks in our iTunes Store.
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase
    http://support.apple.com/kb/HT1933
    Cheers,
    Allen

  • HT4864 I cant send email after the IOS 7. I receive all emails normaly in the outlook 2011, bus I cant receive.

    I  cant send email after the IOS 7. I receive all emails normaly in the outlook 2011, bus I cant receive. What can I do?

    Update - I now have it working.
    am not really sure what exactly fixed it.
    I changed a lot of things but my setup now has the following which I think fixed.
    outgoing server  - p06-smtp.mail.me.com
    override default port checked - port now 587
    on more options button changed it to "use incoming server info".

  • TS3276 I lost the ability to send email after upgrading to maverick.

    I lost the ability to send email after upgrading to maverick.  Has anyone  else had this problem?

    Mail troubleshooting - Yosemite
    What does Mail/Window/Connection Doctor Show? If the server is red, select it and look at the Show Details box.
    Troubleshooting sending and receiving email messages
    Troubleshooting sending email messages

  • I want to find out how to retrieve the serial number for my product. i can't find it in my email

    i want to find out how to retrieve the serial number for my product. i can't find it in my email

    Find your serial number quickly

  • Cant send email after software update 10.0.10.85

    Email send and receive was working perfectly for early Z10 adopters at our company (SMTP / POP / IMAP, no BES). However, after the firmware update to version 10.0.10.85, sending email stopped working. In checking the logs on our email server, we found that our Z10's are correctly authorizing to the SMTP server but the connection then fails with an invalid linefeed error.
    According to our mailserver vendor (Ipswitch Imail), this has to do with  RFC 2822 Section 2 which specifically states that bare LF characters are not allowed. We are not experiencing the same problem with Gmail or AOLmail.
    Again, the Z10's did work with the initial firware release and failed after the firware update. Nothing was changed on our mail server in the meantime.
    Thanks in advance for any thoughts

    I see that K-9 Mail has recently become available on App World. On a lark, I decided to give it a try and guess what?... It works just fine. It receives and sends mail exactly the way any native email client should.
    I have an idea for you BlackBerry. Since you appear to be unable to resolve the mail sending issue, and since K-9 Mail is open source, why not download and incorporate their source code into your own mail client, (with proper attribution of course). It would save you the trouble of figuring out for yourselves what you broke in the last firmware update and we would get the fully functioning email we've all become accustomed to on our Blackberry devices.
    Ok, sarcasm off. Guys, I really want to love this phone and you know I'm pulling for you, but I can't send email from my Blackberry and right at the top of this thread is the reason why. If nothing else, a Blackberry MUST do email properly! Are you working on this? Throw us a bone here!

  • How to find out which user has the permission to execute startsap ?

    Hi All
    How do I find out which user has the permission to execute the startsap and stopsap? Do I control the permission on those script using windows standard authorization? For example: only allow certain user have the read and write permission?
    Thank you.!
    Vincent Lo

    Well to me this is really weird question..
    <b>noone un-authorized should have access to OS on your system</b>
    If this is valid you do not need to solve problems who can and who cannot start/stop SAP, because if you want to prevent some users from shutting down the SAP you have really hard job to do - there are many ways how to kill the SAP (for example killing relevant process from task manager, killing of database, messing with services etc.) - yes, this is harmful way of stopping SAP, but we are talking about attack, right? I would contact some Windows specialist to help you disable all the ways how to harm the running SAP. But still after that - there are many files that can be modified/deleted so SAP will crash after restart - you need to protect them too, etc.
    In case you take the first assumption as granted (and you really limit access to this server) you do not need to worry who can stop or start SAP - at the other hand it may be handy to be able to start/stop SAP from other users - for this you can run the stop/start script "under different user".
    But to answer the question - to me this is question just of access control (but really never tried that myself):
    <a href="http://technet2.microsoft.com/WindowsServer/en/library/c6413717-511e-42bd-bd81-82431afe4b2a1033.mspx">Permit or restrict access to a snap-in for a domain</a> (or see other related links down there on this page)
    Please award points for useful answers.
    Thanks

  • I cannot get my email to send or receive after attempting to get my MobileMe to work after a year of sitting on my hard drive. What do I need to do in order to get my email working again? A window pops up telling me my pasword is incorrect!

    I have two email addresses coming into my mail at all times. Recently, I tried to activate MobileMe after it had sat unused on my hard drive. Since then, one of my email addresses does not send or receive. The window pops up telling me my password is wrong. What do I need to accomplish to fix this issue?

    Hi Sonia,
    While transferring Adobe from laptop to PC the licensing files got corrupt and the right way to use Adobe Applications is to install first as transferring from a different machine can give you problems.
    You can try steps from this article if that helps otherwise you have to reinstall and manually delete some files , everything is mentioned.
    http://helpx.adobe.com/x-productkb/global/error-licensing-stopped-mac-os.html
    You can download CS4 from here:
    Download CS4 products

  • When you sighn in and out of an ios device some of the data fom the device sighned in stays after sighning out. Is this the same for PC and if so how do you delete all the data from my icloud from the pc

    When sighning in and out of an ios device some of the icloud data from the icloud account used to sighned in stays even after sighning out. Is it the same on pc icloud and if so how do you delete it. ( This is the online site by the way.)

    Hi turintest2
    Thanks for taking the time to respond - however your reply didn't really help as you haven't explained how to delete the compilation album that had been created.
    I managed to sort it out by doing the following (I'm posting this so that it may help others).  I don't know if this is the simplest/most elegant solution - but it works.
    In iTunes, find the compilation (in my case, the 153 songs) and, starting with the first song, follow this procedure:
    On the iPhone go to 'Songs' and scroll down the list until you find the first song that was listed in iTunes (above).  You should notice (as in my case) that the song will have the correct title (and artwork too if you'd found this previously before making the compliation) but the wring artist.
    Swipe LEFT and press the 'Delete' button.
    Repeat with second song in iTunes list, deleting the individual songs from the iPhone, one by one.
    Although tedious, this seemed to work for me.  Reason for doing down the iTunes list is that it is in a pseudo-alphabetical order and I wanted to make sure I'd got every one.
    Now busy re-importing the original albums from CD.
    Thank you APPLE for making this such a laborious process.  Why can't designers actually TEST the products they design so that they can appreciate first-hand the likely problems?
    Anyhow, thanks turintest2 for trying to help me - it was appreciated.
    RB

  • Can't send email after 3.0 upgrade

    I can receive but not send email after the 3.0 upgrade. Also, the stock and weather buttons never update.
    Email is my important issue. Any ideas?

    Yeah, I put that in the title so hopefully people would see it right off the bat. I've been in the forum, looking at threads since the update to see if I'm the only one, and seem to be. I know tons of people are seeing problems with yahoo pushing email, but that's less of a concern to me at this point. And the fact that it worked just fine until this update tells me Apple broke it with their update. Surely I'm not the only person. And switching to gmail is not a good option for me. First of all, I hate gmail. Second of all, the sbcglobal account is my main mail account for my dsl line and I use it heavily. I don't want to switch. Shouldn't have to in my opinion.
    I was in the Promenade in Santa Monica earlier, was going to ask a "Genius", but the wait to see one was ridiculous. couldn't get an appointment till Monday. I'll wait till I'm back home to go the apple store I guess. It just frustrates me because I seriously doubt they can do anything at the store I haven't done already.

Maybe you are looking for

  • Order type Personalization Problem in Standard Sales Order Form

    Hi All, We have a problem in personalization of Sales order form.Here we are trying to personalize three field based on order type Scenario 1:_ _Nav-->Oredr Management Super User-->Orders,returns-->Sales Orders-->order type-->standard_ In this type i

  • How do I determine what is my CURRENT Profile, because Profile manager shows 3 and all the Q&As are ambiguous in that respect. Thx.?

    Yes, I see ambiguity. I also have some old backed up profiles and I have 3 profiles showing under the Profile Manager. The folder under "%APPDATA%\Mozilla\Firefox\Profiles\ " shows 2 of them, but HOW do I determine WHICH ONE is my current profile?? S

  • Assemble second system audio

    We are recording multiple audio tracks in the field with Metacorder which is getting timecode from camera. The editor(s) can import these poly BWav files no problem. They unfortunately don't/won't sync them up and make a merged clips before editing s

  • I tunes told me to update.

    I bought a used touch ipod. Its a 2nd gen.I tunes told me to update, when i did the computer no longer recognizes the usb and itunes doesnt sync. I have tried to restore, and tried everything that i have found to fix it can any one help?

  • Ipod disabled will not reset?

    need help my sons ipod is disabled and will not reset and he cant remember password. I have connected it to my itunes and it gives same message that is it is disabled and his itunes account is gone.  any suggestions