none
powershell monitor net use disk mounted availability

    Question

  • Hi All,

    Can i monitor in powershell net use disk availability?

    i have two disk in my windows:

    \\nameserver\share\

    \\nameserver\share1\

    Can i monitor this share from powershell? i want to add this script to ManageEngine OpManager.

    BR/Cichy

    Thursday, March 21, 2013 12:37 PM

Answers

  • You can even use...test-path

    #----------------------------------------

    $path = "\\server\share1,\\server\share2"

    foreach ($pat in $path){

    if (Test-path $pat )
    {
    "$pat good"
    }
    else
    {
    " $pat bad"
    }
    }

    #-----------------------------------
    Copy the above and save it as *.ps1 ....change the network paths.


    Thanks Azam When you see answers please Mark as Answer if Helpful..vote as helpful.


    Tuesday, March 26, 2013 1:38 PM

All replies

  • Hi,

    I guess you want to check this on a server/client to see if the computer are connected to your shares?

    You can achieve this with the following cmdlets.

    Win7/8/2008R2/2012 (Using WMI)

    Get-WmiObject win32_networkconnection

    Win8/Server 2012 (Using CIM)

    Get-CimInstance win32_networkconnection

    Hope this helps you on your way!


    MCT | MCSE: Private Cloud/Server, Desktop Infrastructure

    Thursday, March 21, 2013 2:24 PM
  • Yes, Thank You. this is it. But in powershell can I achieve this:

    I need information about status of share.  how can i do this? When status is "ok" then nothing to do. When status is "disconected" return error.

    BR/Cichy

    Thursday, March 21, 2013 4:04 PM
  • Yes. With above powershell cmdlets you can achieve this.

    MCT | MCSE: Private Cloud/Server, Desktop Infrastructure

    Thursday, March 21, 2013 6:11 PM
  • Would You be so kind and wrote for me example script? in powershell i'm not too strong, and i do not know how to do this :(

    BR/Cichy

    Tuesday, March 26, 2013 1:26 PM
  • You can even use...test-path

    #----------------------------------------

    $path = "\\server\share1,\\server\share2"

    foreach ($pat in $path){

    if (Test-path $pat )
    {
    "$pat good"
    }
    else
    {
    " $pat bad"
    }
    }

    #-----------------------------------
    Copy the above and save it as *.ps1 ....change the network paths.


    Thanks Azam When you see answers please Mark as Answer if Helpful..vote as helpful.


    Tuesday, March 26, 2013 1:38 PM
  • THX :D. It works.

     BR/Cichy

    Tuesday, March 26, 2013 4:30 PM