Deleting Only Unauthorized Shares

As part of Desired Configuration Maintenance (DCM), it is important to control the shares defined on a server or workstation. All shares should be approved and configured in a standard mechanism. If they are not authorized then they should be removed. Earlier in this chapter, you collected a list of the shares to define on your computer (WriteSharesToFile.ps1). Later, you compared the contents of the text file that is produced to the current configuration of the share, and printed the results (AuditUnauthorizedShares.ps1). However, to maintain the desired configuration of your server, you must remove all unauthorized shares. To do this, modify the AuditUnauthorizedShares.ps1 script to delete the unauthorized shares, ...

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.