Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am partially not even sure how to Google this question because whatever I type never seems to bring back any relevant search results.

I currently have a working script that is set to go through and change the auditing settings for each site collection. I am trying to find a way to EXCLUDE one site collection specifically.

Here is my code:

$spSites = Get-SpSite -Limit All
oreach ($spSite in $SpSites) {
write-host $spsite
$spsite.TrimAuditLog = $true 
#write-host $spsite.AuditLogTrimmingRetention
$spsite.AuditLogTrimmingRetention = 90
$SpSite.Audit.AuditFlags = [Microsoft.SharePoint.SPAuditMaskType]::Delete -bxor [Microsoft.SharePoint.SPAuditMaskType]::update -bxor [Microsoft.SharePoint.SPAuditMaskType]::SecurityChange
$SpSite.Audit.Update()
}

We have a 1 site collection set up for MySites. I would like to exclude this site collection but am not sure how to go about doing so. Any help would be greatly appreciated! And as always, thank you in advance! You guys have been insanely helpful on my sharepoint journey!

share|improve this question
    
A word of advice, before you test the "exclude" function, comment out the actual update code and replace it with debug code like writing the Url of the site - to confirm it has excluded mysites. :) –  Russell Feb 19 '13 at 23:43
add comment

2 Answers

up vote 3 down vote accepted

Just filter your logic based on some property of your MySite like this:

if ($spsite.Url -ne "http://mysite.domain.com") {
   ... audit code ...
}
share|improve this answer
    
thanks, Dave! Ill give this a shot tomorrow when I am back in the office. –  Kevin Feb 19 '13 at 21:43
    
Forgot to flag this one as the solution I went with. Worked like a charm, thanks for helping out a powershell green pea! –  Kevin Mar 13 '13 at 18:32
add comment

You can specify a filter while retrieving the Site collection list from Get-SPSite:

$spsites = Get-SPSite -Filter { $_.Url -ne "http://mysite.com" }

The Filter parameter is described here.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.