January 2008
Intermediate to advanced
688 pages
19h 12m
English
To delete a share using a Windows PowerShell script, you once again use the Win32_Share WMI class. As you may already suspect, the method you use is named delete.
The DeleteShare.ps1 script begins by using the param keyword to provide command-line input. One parameter is required—the name of the share to delete. The computername parameter will use localhost if a value is not specified, and will allow you to delete a local share. This line of code is shown here:
Param($shareName, $computerName="localhost")
When the script is run, it first evaluates the command-line parameters; the next line of code that is processed checks for the existence of the shareName parameter. If the shareName parameter is not supplied to the script, a message ...
Read now
Unlock full access