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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access