El siguiente código de powershell permite recorrer un sitio y subsitios que devuelve una lista de archivos desprotegidos.
1: function GetCheckedOutFiles($web)
2: {
3: Write-Host "Processing Web: $($web.Url)..."
4: foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
5: Write-Host "`tProcessing List: $($list.RootFolder.ServerRelativeUrl)..."
6: foreach ($item in $list.CheckedOutFiles) {
7: if (!$item.Url.EndsWith(".aspx")) { continue }
8: $hash = @{
9: "URL"=$web.Site.MakeFullUrl("$($web.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)");
10: "CheckedOutBy"=$item.CheckedOutBy;
11: "CheckedOutByEmail"=$item.CheckedOutByEmail
12: }
13: New-Object PSObject -Property $hash
14: }
15: foreach ($item in $list.Items) {
16: if ($item.File.CheckOutStatus -ne "None") {
17: if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) { continue }
18: $hash = @{
19: "URL"=$web.Site.MakeFullUrl("$($web.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)");
20: "CheckedOutBy"=$item.File.CheckedOutByUser;
21: "CheckedOutByEmail"=$item.File.CheckedOutByUser.Email
22: }
23: New-Object PSObject -Property $hash
24: }
25: }
26: }
27: foreach($subWeb in $web.Webs)
28: {
29: GetCheckedOutFiles($subweb)
30: }
31: $web.Dispose()
32: }
33:
34: $web = get-spweb $args[0]
35:
36: GetCheckedOutFiles($web)
./GetCheckedOutFiles http://urltoweb | Format-Table url | out-file output.txt -width 500
Fuente:
http://www.thorntontechnical.com/tech/powershell-tech/powershell-tip-find-all-checked-out-files
No hay comentarios:
Publicar un comentario