Hello all,
I am new to reading powershell scripts so I wanted to ask you if my reading of this short script is corrrect.
Here is the script:
[pre]
$user = “someuser”
foreach ($site in gets spsite -Limit ALL)
{
if (($site.Owner.UserLogin -eq $user) -OR ($site.SecondaryContact.UserLogin -eq $user))
{
Write-host 'Deleting audit data for site: ’ $sc.URL
$i = -50
do {
Write-Host $site.URL ’ - Delete day ’ $i ':
’ ([System.DateTime]::Now.ToLocalTime().AddDays($i))
$site.audit.deleteentries([System.DateTime]::NowToLocalTime().AddDays($i))
$site.audit.update()
$i++
}
while ($i -le 1)
}
$site.Dispose()
}
[/pre]
My reading of this script is:
For each site on the server, if the value of UserLogin OR the value of SecondaryContact.UserLogin IS ‘someuser’, write a string of text that reads, "Deleting audit data for: <name of website>.
The script will then display the text “<name of website> - Delete day 50”
The script will delete audit log entries for files in the name format of date and time followed by the number 50 in the filename.
The script will then change $i to 49 and repeat until it gets to 1, deleting each audit log that matches the name format specified.
Is that a correct reading?