Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8593461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:59:38+00:00 2026-06-11T23:59:38+00:00

This seems like a very easy thing to do; however, I don’t know anything

  • 0

This seems like a very easy thing to do; however, I don’t know anything about WMI. How would I go about determining if a directory is shared over the network on one of my servers (using PowerShell)? Also, is there a quick primer that I can read to get aquainted to WMI? I really want to be able to use it when scripting, but most resources don’t show any examples with PowerShell.

Currently, I’m running a check to see if the “Server” service is running; and another check to see if a specific group has permissions on the directory.

    $serversrvc = Get-Service -Name "Server"
    $dirpath = "C:\My\Path\"
    $pathacl = (Get-Acl -path $dirpath).Access
    $group = "Domain\User"

    # Test if the "Server" service is running
    If ($serversrvc.Status -eq "Running")
    {
        echo '"Server" service is running.'
    }
    Else
    {
        echo '"Server" is NOT running.'
    }

    # Test if the $dirpath exists
    If (Test-Path $dirpath)
    {
        echo "$dirpath exists."
    }
    Else
    {
        echo "$dirpath does not exist."
    }

    # Test if $group has permssions on $dirpath
    foreach ($id in $pathacl)
    {
        If ($id.IdentityReference -eq $group)
        {
            echo "$group has access to $dirpath"
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:59:39+00:00Added an answer on June 11, 2026 at 11:59 pm

    The Win32_Share WMI class returns all instances of shared folders on a computer. This will give you all shared folders on the local machine:

    Get-WmiObject -Class Win32_Share
    

    Notice the Path property, you can use the Filter parameter (equivalent to the WQL WHERE clause) to get back shares witha certain local path but you’d also need to double each slash (slash is a :

    Get-WmiObject -Class Win32_Share -ComputerName PC1 -Filter "Path='C:\\Windows'"
    

    If you get back a result the folder is shared, otherwise it isn’t. Notice the ComputerName parameter, you can execute the wmi command against remote computers.

    To get back a Boolean result, true if the folder is shared and false otherwise, cast the command to bool:

     [bool](Get-WmiObject -Class Win32_Share -ComputerName PC1 -Filter "Path='C:\\Windows'")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, this seems like it should be very easy to do, however I can't
This seems like it should be something very easy to do, but every time
This seems like it should be very easy...anyway, it is in MS SQL Server
This seems like an easy thing, but I'm drawing a blank. Select * from
This might seem like a very easy question for some of you folks, but
This seems like it should be very simple but I can't get it to
I have an issue that seems like very flaky behavour, is this a problem
This seems like the simplest Git question, but I can't find ANYTHING on it.
This seemed like an easy thing to do. I just wanted to pop up
This seems like it should be easy yet I must be missing something. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.