title: Test to see if directory is shared using PowerShell?
body: <p>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.</p>
  
  <p>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.</p>
  
  <pre><code>    $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"
          }
      }
  </code></pre>