The below script will not only list the checked out version but also lets us know if it is having checked in version or draft version
.ps1 code
# Add SharePoint cmdlets reference
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
function enumerateWebParts($Url) {
$site = new-object Microsoft.SharePoint.SPSite $Url
foreach($web in $site.AllWebs) {
foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
foreach ($item in $list.CheckedOutFiles) {
$string1 = $item.File.Url;
try{
if(!($string1.ToLower().Contains("_catalogs/".ToLower())) -and !($string1.ToLower().Contains("pages/".ToLower()))) {
$item| select-object @{Expression={$Web.Url};Label="Web URL"},@{Expression={$_.File.Url};Label="Document URL"}, @{Expression={$_.File.CheckedOutBy};Label="Checked Out By"}, @{Expression={$_.File.CheckedOutBy.Email};Label="Checked Out Email"},@{Expression={"No"};Label="Checked In Version"}
}
}
catch [Exception]
{
}
}
foreach ($item in $list.Items) {
if ($item.File.CheckOutStatus -ne "None") {
$string1 = $item.File.Url;
try{
if(!($string1.ToLower().Contains("_catalogs/".ToLower())) -and !($string1.ToLower().Contains("pages/".ToLower()))){
$item| select-object @{Expression={$Web.Url};Label="Web URL"},@{Expression={$_.File.Url};Label="Document URL"}, @{Expression={$_.File.CheckedOutBy};Label="Checked Out By"}, @{Expression={$_.File.CheckedOutBy.Email};Label="Checked Out Email"},@{Expression={"Yes"};Label="Checked In Version"}
}
}
catch [Exception]
{
}
}
}
}
$web.Dispose()
}
}
$webAppUrl = Read-Host "Enter the web application URL for ex:Myprogress-dev.progress.com"
$csvpath = Read-Host "Enter the csv file path to create for ex: c:\test.csv"
$row = enumerateWebParts($webAppUrl)
$row | Out-Gridview
.ps1 code
# Add SharePoint cmdlets reference
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
function enumerateWebParts($Url) {
$site = new-object Microsoft.SharePoint.SPSite $Url
foreach($web in $site.AllWebs) {
foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
foreach ($item in $list.CheckedOutFiles) {
$string1 = $item.File.Url;
try{
if(!($string1.ToLower().Contains("_catalogs/".ToLower())) -and !($string1.ToLower().Contains("pages/".ToLower()))) {
$item| select-object @{Expression={$Web.Url};Label="Web URL"},@{Expression={$_.File.Url};Label="Document URL"}, @{Expression={$_.File.CheckedOutBy};Label="Checked Out By"}, @{Expression={$_.File.CheckedOutBy.Email};Label="Checked Out Email"},@{Expression={"No"};Label="Checked In Version"}
}
}
catch [Exception]
{
}
}
foreach ($item in $list.Items) {
if ($item.File.CheckOutStatus -ne "None") {
$string1 = $item.File.Url;
try{
if(!($string1.ToLower().Contains("_catalogs/".ToLower())) -and !($string1.ToLower().Contains("pages/".ToLower()))){
$item| select-object @{Expression={$Web.Url};Label="Web URL"},@{Expression={$_.File.Url};Label="Document URL"}, @{Expression={$_.File.CheckedOutBy};Label="Checked Out By"}, @{Expression={$_.File.CheckedOutBy.Email};Label="Checked Out Email"},@{Expression={"Yes"};Label="Checked In Version"}
}
}
catch [Exception]
{
}
}
}
}
$web.Dispose()
}
}
$webAppUrl = Read-Host "Enter the web application URL for ex:Myprogress-dev.progress.com"
$csvpath = Read-Host "Enter the csv file path to create for ex: c:\test.csv"
$row = enumerateWebParts($webAppUrl)
$row | Out-Gridview
No comments:
Post a Comment