Creating New Shares

To create new shares, continue to use the Win32_Share WMI class. This time, try a different method: the create method from the Win32_Share WMI class. To do this, rather than the Get-WmiObject cmdlet, you retrieve a new instance of the Win32_Share class by using the [wmiclass] type accelerator. When using [wmiclass] you are working with an instance of the System.Management.ManagementObject .NET Framework class.

In creating the CreateShare.ps1 script, once again use the param statement to specify named parameters to the script. There are four parameters as options to the script: the folderpath, the sharename, the maxallowed, and the description. In the param statement, supply default values for both the maxallowed parameter and ...

Get Windows PowerShell™ Scripting Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.