search
top

How To Display Windows Shares Using PowerShell and WMI

Introduction

By using PowerShell to call WMI we can gather information on the share on a system or on  a remote system. In this post we will cover how retrieve basic nd some detailed information using PowerShell and WMI. With Windows 8.1 ans Server 2012 R2 there have been added cmdlets called Get-SmbShare which will be covered in future posts.

The Commands

So let’s get started on getting some information.

To display a list of all the objects properties, never miss an opportunity to research properties with Get-Member

Get-WmiObject Win32_share | Get-Member

win32_share1

Now let’s display what shares are on the server, which if none are defined we will see the default hidden shares.

Get-WmiObject Win32_share

win32share2

Retrieve Shares from a named server, change YourServer to the name of the server you want to query.

Get-WmiObject Win32_share -computer YourServer

Display Shares, which are not hidden ($)

WmiObject Win32_share | Where {$_.name -NotLike "*$"}

Conclusion

As we can see there is much you can do using PowerShell and WMI to retrieve information on Windows shares.

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

top