I have a Powershell script that outputs data from all libraries in a site shown below:
Add-PSSnapin Microsoft.sharepoint.powershell
$url = "http://contoso.com"
$site = New-Object Microsoft.SharePoint.SPSite($url)
$web = $site.OpenWeb()
function GetCheckedOutFiles($web)
{
Write-Host "Processing Web: $($web.Url)..."
foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
Write-Host "`tProcessing List: $($list.RootFolder.ServerRelativeUrl)..."
foreach ($item in $list.CheckedOutFiles) {
#$modifiedTime = $web.RegionalSettings.TimeZone
if (!$item.Url.EndsWith(".aspx")) { continue }
$data = @{
#"URL"=$web.Site.MakeFullUrl("$($web.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)");
"Version" = $item["Version"]
"Title" = $item.Title
#"CheckedOut By" = $item.File.CheckedOutBy.Name
"#Time last Modified" = $modifiedTime.UTCToLocalTime($item.File.TimeLastModified)
}
New-Object PSObject -Property $data
}
foreach ($item in $list.Items) {
#$modifiedTime = $web.RegionalSettings.TimeZone
if ($item.File.CheckOutStatus -ne "None") {
if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) { continue }
$data = @{
"URL"=$web.Site.MakeFullUrl("$($web.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)");
"Version" = $item["Version"]
"Library" = $item.Title
"Created By" = $item["Author"]
"Created Date" = $item["Created"]
"Modified By" = $item["Editor"]
"Modified Date" = $item["Modified"]
"Title" = $item.File.Name
"CheckedOut By" = $item.File.CheckedOutBy.Name
"Time last Modified" = $modifiedTime.UTCToLocalTime($item.File.TimeLastModified)
}
New-Object PSObject -Property $data
}
}
}
foreach($subWeb in $web.Webs)
{
GetCheckedOutFiles($subweb)
}
$web.Dispose()
}
#Get-DocInventory | Out-GridView
GetCheckedOutFiles($web) | Export-Csv -NoTypeInformation -Path C:\NewDocInventory.csv
In addition to outputting libraries how can I also output all lists from contoso.com? What line must I add to the script to pull lists as well? Can someone please advise?