How many times can you spot the letter n in:
Q: You cannot call a method on a null-valued expression. InvalidOperation: (GetAssociationByName:String) When trying to run this Powershell Script Im getting an error:
Param(
        [parameter(Mandatory=$true)]
        [alias(url)]
        $siteurl,
        [parameter(Mandatory=$true)]
        [alias(list)]
        $listname,
        [parameter(Mandatory=$true)]
        [alias(workflow)]
        $workflowname
        )

    $site = Get-SPSite $siteurl
    $web = $site.RootWeb;
    $list = $web.Lists[$listname];
    $statusChoices = $list.WorkflowAssociations.GetAssociationByName($workflowname,[System.Globalization.CultureInfo]::CurrentCulture).BaseTemplate.GetStatusChoices($web);

    $countChoices = $statusChoices.count;

    Write-Host Status Choice count -  $countChoices;

    $i = 0;

    while($i -lt $countChoices)
    {
      Write-Host $i  -  $statusChoices[$i];
      $i++;
    }

Error:
You cannot call a method on a null-valued expression.
At E:\PowerShellScript\test.ps1:12 char:65
+ $statusChoices = $list.WorkflowAssociations.GetAssociationByName <<<< ($workf
lowname,[System.Globalization.CultureInfo]::CurrentCulture).BaseTemplate.GetSta
tusChoices($web)
    + CategoryInfo          : InvalidOperation: (GetAssociationByName:String)
   [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull


A: $site = new-object Microsoft.SharePoint.SPSite($siteUrl)
$web = $site.OpenWeb();

Changing these two lines helped.

user
I found sixty-two "n"s in the provided passage.
assistant