we’ve seen a few things we can do with shares – its time to look at creating them. A simple share craetion script will look like this
New-Item -Path c:\ -Name share1 -ItemType Directory
New-Item -Path c:\share1 -Name shareA -ItemType Directory
New-Item -Path c:\share1 -Name shareB -ItemType Directory
$s = [WmiClass]"Win32_Share"
We create some folders in a hierarchy with New-Item and then create an instance of the Win32_Share class using the [WmiClass] type accelerator.
We can then call the create method. The parameters are:
- folder path
- share name
- share type – 0 = disk share
- maximum connections allowed – $null means unlimited
This sets default permissions on the share