Hi All,
I have a script to fetch the user ntaccount name. Could you pls help to get their email ID too? PFB script and let me know how to include the email id.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$mysiteUrl=Read-Host “Site URL”
$w = Get-SPWebApplication -Identity $mysiteUrl
$useraccount=Read-Host “domain\account name”
$w.GrantAccessToProcessIdentity(“$useraccount”)
$Webs=Get-SPSite “$mysiteUrl/*” -Limit All|Get-SPWeb -Limit All
$results = @()
ForEach ($Web in $Webs)
{
$webUrl = $web.url
$docLibs = $web.Lists | Where-Object {$_.baseType -eq “DocumentLibrary”}
$docLibs | Add-Member -MemberType ScriptProperty -Name WebUrl -Value {$webUrl}
#gets only the Personal and Shared documents count
$results += ($docLibs | Select-Object -Property WebUrl, Title, ItemCount|where-object {$_.Title -eq “Personal Documents” -or $_.Title -eq “Shared Documents”})
#line commented below to avoid getting all document librarires
#$results += ($docLibs | Select-Object -Property WebUrl, Title, ItemCount)
}
$results |Where-Object {$_}| Export-Csv -Path SPListDocs.csv -NoTypeInformation
Write-Host All content will be written to [Environment]::CurrentDirectory
Thanks,
KS
I have a script to fetch the user ntaccount name. Could you pls help to get their email ID too? PFB script and let me know how to include the email id.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$mysiteUrl=Read-Host “Site URL”
$w = Get-SPWebApplication -Identity $mysiteUrl
$useraccount=Read-Host “domain\account name”
$w.GrantAccessToProcessIdentity(“$useraccount”)
$Webs=Get-SPSite “$mysiteUrl/*” -Limit All|Get-SPWeb -Limit All
$results = @()
ForEach ($Web in $Webs)
{
$webUrl = $web.url
$docLibs = $web.Lists | Where-Object {$_.baseType -eq “DocumentLibrary”}
$docLibs | Add-Member -MemberType ScriptProperty -Name WebUrl -Value {$webUrl}
#gets only the Personal and Shared documents count
$results += ($docLibs | Select-Object -Property WebUrl, Title, ItemCount|where-object {$_.Title -eq “Personal Documents” -or $_.Title -eq “Shared Documents”})
#line commented below to avoid getting all document librarires
#$results += ($docLibs | Select-Object -Property WebUrl, Title, ItemCount)
}
$results |Where-Object {$_}| Export-Csv -Path SPListDocs.csv -NoTypeInformation
Write-Host All content will be written to [Environment]::CurrentDirectory
Thanks,
KS









