I have a SP 2013 environment with documents uploaded to the sub site Document centre. I need to know which files was uploaded and which content type (also if no content type was selected) was uploaded. So the script needs to loop through the subsite Document Centre and list all files with content type. Thanks to Amal Hashim's script I got the following: But this goes through the whole site and list content types assigned to all libraries. If someone can help me to modify it to loop only through the sub site and list files with their content type assigned and where they are saved - I would very much appreciate that:
$Site= Get-SPSite "http://dbnsrv06"
$spWebApp = $Site.WebApplication
$ct = @()
$spWebApp = $Site.WebApplication
foreach($allSites in $spWebApp.Sites)
{
foreach($Web in $allSites.AllWebs)
{
foreach($list in $Web.Lists)
{
if($list.BaseTemplate -eq "DocumentLibrary" -and $list.AllowContentTypes -eq $true)
{
if(-not ($systemlibs -Contains $list.Title))
{
if ($list.AllowContentTypes -eq $true)
{
foreach ($contenttype in $list.ContentTypes)
{
$ctObject = New-Object -TypeName PSObject
$ctObject | Add-Member -Name 'WebTitle' -MemberType Noteproperty -Value $web.Title
$ctObject | Add-Member -Name 'WebUrl' -MemberType Noteproperty -Value $web.URL
$ctObject | Add-Member -Name 'ListTitle' -MemberType Noteproperty -Value $list.Title
$ctObject | Add-Member -Name 'ContentType' -MemberType Noteproperty -Value $contenttype.Name
$ct += $ctObject
}
}
}
}
}
}
}
$ct | export-csv "C:/filename.csv"