PowerShell is a powerful scripting environment for Windows which can be used for this type of maintenance but first you…