I'm quite new to SharePoint and powershell scripting. I need some assistance in getting document details of the below from Mysite.
It currently has several user profiles storing both their Personal and Shared docs. I need to get the below details across both libraries:
- Document names
- Usernames
- Date modified
So far I've tried using the below script which comes close to what I'm looking for, but info is quite limited.
It gets the user's profile URL (so that covers the usernames bit) and the number of documents, but not the other details stated above.
Please help on how I can get the extra info. I suspect I'll have to query more in the 'Select-Object' line, but I'm unsure as to what the keywords might be?
Add-PSSnapin Microsoft.SharePoint.PowerShell
Start-SPAssignment -Global
$OutputFile = "C:\temp\MysiteDocsProd.csv"
$results = @()
$webApps = Get-SPWebApplication https://mysite.sharepoint.com
foreach($webApp in $webApps)
{
foreach($siteColl in $webApp.Sites)
{
foreach($web in $siteColl.AllWebs)
{
$webUrl = $web.url
$docLibs = $web.Lists | Where-Object {$_.baseType -eq "DocumentLibrary"}
$docLibs | Add-Member -MemberType ScriptProperty -Name WebUrl -Value {$webUrl}
$results += ($docLibs | Select-Object -Property WebUrl, Title, ItemCount)
}
}
}
$results | Export-Csv -Path $OutputFile -NoTypeInformation
Stop-SPAssignment -Global
Thanking you in advance.