O'Reilly logo

Windows PowerShell™ Scripting Guide by Ed Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required