Creating File Shares

by Dec 5, 2016

In Server 2012 R2 and Windows 8.1, there are many useful new modules with cmdlets such as New-SmbShare which creates new file shares easily.

If you don’t have these cmdlets, you can often use WMI instead. That requires more investigation and googling, but once you have a code template, it works well.

To create new file shares as an Administrator, for example, try this:

$share = [wmiclass]"Win32_Share" 
$path = 'c:\logs'
$name = 'LogShare'
$maxallowed = 10
$description = 'Place log files here'

$share.Create( $path, $name, 0, $maxallowed,$description,$null,$null)

Twitter This Tip! ReTweet this Tip!