The last few months I’ve been involved in a lot of SharePoint migrations. Most of these migrations are in on premise environment and involve moving large amounts of sites. As part of the migration process it is important to get the migrated content checked. When it involves large amount of content, it gets time consuming to check everything. As migrator you do not have the time and more importantly, you are not aware of all the important pieces of content within a site. Therefore it is handy to get the business owners involved.

With lots of sites, it is difficult to manually create a list of these business owners. When a business owner is responsible for the content of a site, he or she is most likely one of the site owners.

The following PowerShell script iterates through all the sites within a web application and enumerates per site the site owners. The list contains the title, the old URL, the new URL and per site owner its name and e-mail. Due to the delimiter used it’s easy to import the file into Excel.  Send the list to all the site owners and let them check the content for the sites they are responsible for.

 

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$webAppOldUrl = "http://www.old-contoso.com";
$webAppUrl = "http://www.contoso.com";
function IterateSubSites($site) 
{ 
    foreach($subSite in $site.Webs)
    {
        $urlName = $subSite.Url
        $urlName = $urlName.SubString($urlName.LastIndexOf("/") + 1)


        $outtext =  $subSite.Title + "|" + $urlName +  "|" + $webAppOldUrl "/" + $subSite.Url + "|" + $webAppUrl + "/" + $subSite.Url;

        foreach($group in $subSite.Groups) 
        {
            if($group.Name -like "*Owners*")
            {                          
                foreach($user in $group.Users)
                {
                    $outtext =  $outtext + $user.Name + "(" + $user.Email +  "); "
                }
            }
        }

        Write-Host  $outtext
           $outtext | Out-File c:SiteOwnerList.txt -Append

        IterateSubSites($subSite);
    }
}

$webApp = Get-SPWebApplication $webAppUrl

foreach($site in $webApp.Sites)
{
    IterateSubSites($site.RootWeb)
}

The PowerShell script is based on existing scripts found on the internet. It is altered for the purpose of generating business owner lists for migration projects. Feel free to copy and use the script.

Previous articleThe Microsoft IT world is changing and so am I
Next articleConfigure an environment to run your provider-hosted high trust apps in SharePoint 2013.
A professional which inspires, motivates and educates businesses on how to leverage emerging technologies using Virtual, Augmented and Mixed Reality in their journey to digital innovation. He has a strong background on SharePoint, Office 365 and Microsoft Azure and is working with machine learning, artificial intelligence and cognitive services. Primarily focused on manufacturing, construction, industry, logistics and maritime/offshore, his goal is helping businesses to achieve more on creating, improving, smartening and shortening of business processes by using services, apps and devices. Furthermore, he engages in speaking, blogging and is organizer of events like the Mixed Reality User Group, Mixed Reality Talk @ VR, SP&C and the Global AI/MR Bootcamp. With more than 20 years of IT Business experience, acting in different roles like solution architect, he believes the future is just starting! Highly experienced in all realities, HoloLens and other devices, User experiences on devices and connecting the world to the cloud will help him to shape that future!

1 COMMENT

  1. Hello.

    First there is a / missing in
    $webAppOldUrl “/”

    Job fails:

    PS C:\temp> .\SpOwner.ps1
    Get-SPWebApplication : The term ‘Get-SPWebApplication’ is not recognized as the name of a cmdlet, function, script
    file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
    and try again.
    At C:\temp\SpOwner.ps1:31 char:11
    + $webApp = Get-SPWebApplication $webAppUrl
    + ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Get-SPWebApplication:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    So looks the procedure is not visible …

LEAVE A REPLY

Please enter your comment!
Please enter your name here