Forum Discussion

Rob Ellis's avatar
Rob Ellis
Bronze Contributor
Jun 07, 2017

Task list - setting EnableAssignToEmail using PnP powershell - not working consistently

Using the following powershell:

 

 

$csvFile = ".\SiteIDs.csv"
$sites = Import-Csv $csvfile

Connect-SPOnline -Url https://<tenantname>.sharepoint.com -Credentials <creds>

foreach ($site in $sites)
{
$web = Get-PnPWeb -Identity $site.siteid
write-host $web.Title
$List = Get-PnPList -Web $web -Identity Tasks
$list.EnableAssignToEmail = $true
$list.Update()
}

  

In some cases the property is showing as True if I enter

$list.EnableAssignToEmail

but looking in the GUI, it shows as Disabled in the majority of cases - even having left it overnight to see if it was just a display issue.

 

On a single test list it seemed to take a number of attempts to get the property to show as True in Powershell (was showing blank).

 

Any ideas?  Am I doing something fundamentally wrong?

 

 

 

 

  • Try the below script.

     

    $csvFile = ".\SiteIDs.csv"
    $sites = Import-Csv $csvfile
    $cred=Get-Credential
    
    foreach ($site in $sites)
    {
    Connect-PnPOnline -Url $site.URl -Credentials $cred
    $ctx=Get-PnPContext
    $List = Get-PnPList -Identity Tasks
    $list.EnableAssignToEmail = $true
    $list.Update()
    $ctx.load($list)      
    $ctx.executeQuery() 
    } 
    
    
  • This line is using $List (with capital L), the other lines are using $list (lowercase):

    $List = Get-PnPList -Web $web -Identity Tasks

     

    • Rob Ellis's avatar
      Rob Ellis
      Bronze Contributor
      ok - so I corrected that, and re-ran - same problem.

      (I wasn't aware that variable names were case sensitive in PoSh - I know some other things are though)

      Thanks anyway.
  • Try the below script.

     

    $csvFile = ".\SiteIDs.csv"
    $sites = Import-Csv $csvfile
    $cred=Get-Credential
    
    foreach ($site in $sites)
    {
    Connect-PnPOnline -Url $site.URl -Credentials $cred
    $ctx=Get-PnPContext
    $List = Get-PnPList -Identity Tasks
    $list.EnableAssignToEmail = $true
    $list.Update()
    $ctx.load($list)      
    $ctx.executeQuery() 
    } 
    
    
    • Rob Ellis's avatar
      Rob Ellis
      Bronze Contributor
      Works great - thanks so much!