Migrate your tenant to another data-center (2 of 3) - or where is the workflow app?

6 3 3,098

In my last post I already talked about how I migrated my Nintex for Office365 tenant to Europe and how I faced the challenge to find all the sites where the Nintex Workflow for Office365 app has been activated in order to re-publish my workflows.

PowerShell to the rescue!

It was obvious, that only PowerShell could help in this challenge. So let's walk through this step-by-step. At first we need to find all the sites where the Nintex Workflow App has been activated.

$userName = "[username]@[mydomain.fqdn]"
$siteColUrl = "https://[tenant].sharepoint.com/sites/[mysite]"

Add-Type -Path "d:\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "d:\Microsoft.SharePoint.Client.dll"

$cred = Get-Credential -UserName $userName -Message "Enter SPO credentials"
$spoCred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials ($cred.UserName, $cred.Password)

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteColUrl)
$ctx.Credentials = $spoCred
$web = $ctx.Web

$webUrl = $web.Url

$addInInstances | % {
     if ($_.ProductId -eq "353e0dc9-57f5-40da-ae3f-380cd5385ab9") {
         Write-Host "Found Nintex Forms for Office 365 on $webUrl; got to $($_.AppWebFullUrl)"
         Write-Host "... Client-ID: $($_.AppPrincipalId)"
     if ($_.ProductId -eq "5d3d5c89-3c4c-4b46-ac2c-86095ea300c7") {
         Write-Host "Found Nintex Workflow for Office 365 on $webUrl; got to $($_.AppWebFullUrl)"
         Write-Host "... Client-ID: $($_.AppPrincipalId)"

Let's have a closer look at the script:

  1. at first I'm setting my username as well as my Office365 tentant-URL
  2. then I'm loading the DLLs for the Client-Side-Object-Modell (CSOM)
  3. next I collect the credentials for further execution
  4. then I can get all installed applications of the current web (line 15)
  5. finally all installed apps are inspected to check if Nintex Workflow for Office365 is within this list

So these steps have to be repeated recursive for every sub-web of my current web. To do this I wrap lines 12 to 29 in a function "Execute-NintexAddinFinder". Additionally I create a function to walk recursive through all subwebs.

function Process-SubWebs() {
    param (
        [Microsoft.SharePoint.Client.Web] $rootWeb = $(throw "Please provide a root web"),
        [Microsoft.SharePoint.Client.ClientContext] $ctx = $(throw "Please provide a context")
    $webs = $rootWeb.Webs
    $webs | % {
        Write-Progress -Activity "Analysing Site-Collections" -Status "Processing $siteColUrl" -PercentComplete ($i / $siteCount * 100) -Id 1 -CurrentOperation "Inspecting Web $($_.Title)"
        Execute-NintexAddinFinder -web $_ -ctx $ctx
        Process-SubWebs -rootWeb $_ -ctx $ctx

This function Process-SubWebs needs to be called once for every site-collection, which can easliy be done using the PnP-PowerShell-Cmdlets:

$adminUrl = "https://[tenant]-admin.sharepoint.com/"
Connect-PnPOnline -Url $adminUrl -Credential $cred
$allSites = Get-PnPSite -Limit ALL

$allSites | % {
   $siteColUrl = $_.Url
   $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteColUrl)
   $ctx.Credentials = $spoCred
   $rootWeb = $ctx.Web


    Execute-NintexAddinFinder -web $rootWeb -ctx $ctx
   Process-SubWebs -rootWeb $rootWeb -ctx $ctx

This way I get a nice overview where Nintex Workflow for Office365 has been activated.

What's still missing is an overview of all the workflows - I'll cover that in the next part.