First published on TECHNET on Aug 09, 2018 Hello All,
I'm sure many of you know about the Site Deletion feature, if you don't please read here . My customer was having some issues as users weren't responding to emails then they were complaining when sites were deleted. They also realized later on that the feature doesn't look at SPWeb object (Sub Sites) so I wrote a quick script to help get around some of there concerns.
The script does the following:
Reports to CSV on Url, CertificationDate (Last date confirmed), DeadWebNotificationCount (Emails sent)
ConfirmUsage() on all Sites in whitelist
Reviews LastItemModifiedDate for all subsites and ConfirmUsage() for all sites that have active subsites.
First thing to do is set the variables and I have 4 of them
The first variable sets which Web Applications you will interrogate, then we need to know how long subsites have to be inactive before we don't Confirm Usage for them, then come the white list which is a text file with Site Url's for all sites that we want to exclude from the Site Usage feature and the output file.
Then lastly the script goes thru all sub sites and compares the LastItemModifiedDate to today() and if the difference is less then the variable $SubWebAge that means the sub site is active and we run ConfirmUsage() on the parent Site Collection.