This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# recycle bin's are tied to a site collection so we need a site collection object | |
$site = get-spsite https://webapplication/sitecollection | |
#we can see everything in the recycle bin like this: | |
$site.Recyclebin | |
#unfortunately, the above command dumps quite a lot to the screen. | |
#fortunately, we can pipe the output to other commands for filtering and cleanup. | |
#This command will return all the webs in the recyclebin | |
$site.Recyclebin | where {$_.itemtype -eq "web"} | |
#we can build on this by adding a sort statement, | |
#here I sort by dirname, which is the URL path the item would have been at before it was deleted | |
$site.Recyclebin | where {$_.itemtype -eq "web"} | sort dirname | |
# we can format the output into a nice list | |
$site.Recyclebin | where {$_.itemtype -eq "web"} | sort dirname | select title, itemtype, dirname, itemstate | |
#note that in the above listing, itemstate shows which recycle bin it's in (FirstStageRecyclebin = End user Recycle Bin Items, SecondStageRecycleBin = Deleted from end user Recycle Bin) | |
#here's one more application of filtering to show everything that's not a page nor a list item | |
$site.RecycleBin | where { $_.itemtype -ne "file" -and $_.itemtype -ne "ListItem" } | sort dirname | select title, itemtype, dirname | |
$site.RecycleBin | where { $_.itemtype -ne "ListItem" -and $_.dirname -like "team/jst/crm*" -and $_.itemtype -ne "FileVersion" } | sort dirname | select title, itemtype, DeletedDate, dirname | Out-GridView |
No comments:
Post a Comment