Last active
October 26, 2020 23:49
-
-
Save joerodgers/8f8201a995260b3af1a1f60ff8e36bde to your computer and use it in GitHub Desktop.
Get-MigrationEvaluationData.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin -Name Microsoft.SharePoint.PowerShell | |
function Get-LargestList | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][Microsoft.SharePoint.SPSite]$Site | |
) | |
begin | |
{ | |
} | |
process | |
{ | |
$Site | Get-SPWeb -Limit All | SELECT -ExpandProperty Lists | ? Hidden -eq $false | SORT ItemCount -Descending | SELECT -First 1 | |
} | |
end | |
{ | |
} | |
} | |
function Get-MostRecentlyModifiedList | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][Microsoft.SharePoint.SPSite]$Site | |
) | |
begin | |
{ | |
} | |
process | |
{ | |
$Site | Get-SPWeb -Limit All | SELECT -ExpandProperty Lists | ? Hidden -eq $false | SORT LastItemModifiedDate -Descending | SELECT -First 1 | |
} | |
end | |
{ | |
} | |
} | |
function Get-EmailEnabledLists | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][Microsoft.SharePoint.SPSite]$Site | |
) | |
begin | |
{ | |
} | |
process | |
{ | |
$Site | Get-SPWeb -Limit All | SELECT -ExpandProperty Lists | ? EmailAlias -ne $null | |
} | |
end | |
{ | |
} | |
} | |
function Get-Workflow2013Instances | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][Microsoft.SharePoint.SPSite]$Site | |
) | |
begin | |
{ | |
} | |
process | |
{ | |
if( $site.WriteLocked ) | |
{ | |
Write-Warning "Skipping Workflow 2013 check on read-only site $($site.Url)" | |
return | |
} | |
$workflowServicesManager = New-Object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($site.RootWeb) | |
if( -not $workflowServicesManager.IsConnected ) | |
{ | |
return | |
} | |
foreach( $web in $site.AllWebs ) | |
{ | |
$workflowServicesManager = New-Object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web) | |
if( $workflowServicesManager.IsConnected ) | |
{ | |
$workflowSubscriptionService = $workflowServicesManager.GetWorkflowSubscriptionService() | |
$workflowSubscriptionService.EnumerateSubscriptions() | % { $_ } | |
} | |
$web.Dispose() | |
} | |
} | |
end | |
{ | |
} | |
} | |
function Get-Workflow2010Instances | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][Microsoft.SharePoint.SPSite]$Site | |
) | |
begin | |
{ | |
} | |
process | |
{ | |
foreach( $web in $site.AllWebs ) | |
{ | |
$web.WorkflowAssociations | |
foreach( $list in $Web.Lists ) | |
{ | |
$list.WorkflowAssociations | |
} | |
} | |
} | |
end | |
{ | |
} | |
} | |
function Get-LockStatus | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][Microsoft.SharePoint.SPSite]$Site | |
) | |
begin | |
{ | |
} | |
process | |
{ | |
if( $site.IsReadLocked ) | |
{ | |
return "ReadLocked" | |
} | |
if( $site.WriteLocked ) | |
{ | |
return "WriteLocked" | |
} | |
if( $site.ReadOnly ) | |
{ | |
return "ReadOnly" | |
} | |
return "NoLock" | |
} | |
end | |
{ | |
} | |
} | |
function Get-MigrationEvaluationData | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][Microsoft.SharePoint.SPSite]$Site | |
) | |
begin | |
{ | |
} | |
process | |
{ | |
Write-Verbose "$(Get-Date) - Processing: $($site.Url)" | |
$result = [PSCustomObject] @{ | |
SiteUrl = $Site.Url | |
Origin = $null | |
PrimaryAdministrator = $null | |
SecondaryAdministrator = $null | |
Classification = $null | |
ContentDatabase = $null | |
SizeMB = $null | |
SubSiteCount = $null | |
LockStatus = $null | |
LargestListItemCount = $null | |
LargestListUrl = $null | |
LastContentModifiedDate = $null | |
EmailEnabledListCount = $null | |
LastSecurityModifiedDate = $null | |
Workflow2013Count = $null | |
Workflow2010Count = $null | |
} | |
if( $site.IsReadLocked ) | |
{ | |
$siteAdmin = Get-SPSiteAdministration -Identity $Site.Url | |
$result.PrimaryAdministrator = $siteAdmin.OwnerLoginName | |
$result.SecondaryAdministrator = $siteAdmin.SecondaryContactLoginName | |
$result.SizeMB = ($siteAdmin.DiskUsed / 1MB).ToString("N0") | |
$result.LockStatus = "ReadLocked" | |
$siteAdmin.Dispose() | |
} | |
else | |
{ | |
$largestList = $Site | Get-LargestList | |
$lockStatus = $Site | Get-LockStatus | |
$recentList = $Site | Get-MostRecentlyModifiedList | |
$2010Workflows = @($Site | Get-Workflow2010Instances) | |
$2013Workflows = @($Site | Get-Workflow2013Instances) | |
$emailLists = @($Site | Get-EmailEnabledLists) | |
$result.Origin = $Site.RootWeb.GetProperty("Aetna_Source_Farm") | |
$result.PrimaryAdministrator = $Site.Owner.LoginName -replace "i:0#\.w\|", "" | |
$result.SecondaryAdministrator = $Site.SecondaryContact.LoginName -replace "i:0#\.w\|", "" | |
$result.Classification = $Site.RootWeb.GetProperty("Data_Classification") | |
$result.ContentDatabase = $Site.ContentDatabase.Name | |
$result.SizeMB = ($Site.StorageUsed / 1MB).ToString("N0") | |
$result.SubSiteCount = $Site.AllWebs.Count - 1 | |
$result.LockStatus = $lockStatus | |
$result.LargestListItemCount = $largestList.ItemCount.ToString("N0") | |
$result.LargestListUrl = $largestList.DefaultViewUrl | |
$result.LastContentModifiedDate = $recentList.LastItemModifiedDate | |
$result.LastSecurityModifiedDate = $Site.LastSecurityModifiedDate | |
$result.EmailEnabledListCount = $emailLists.Count | |
$result.Workflow2013Count = $2013Workflows.Count | |
$result.Workflow2010Count = $2010Workflows.Count | |
} | |
$result | |
} | |
end | |
{ | |
} | |
} | |
Get-SPSite -Limit All | Get-MigrationEvaluationData | Export-Csv -Path "MigrationEvaluationData_$(Get-Date -Format FileDateTime).csv" -NoTypeInformation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment