SOLVED

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

Bronze Contributor

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?

 

 

 

 

6 Replies

This line is using $List (with capital L), the other lines are using $list (lowercase):

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

 

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.
What are you exactly trying to do? Are you executing on SPO or SP OnPrem?

SPO - trying to enable the setting on a Task list -  'send e-mail when ownership is assigned'  (under advanced settings on the GUI).

 

 

best response confirmed by VI_Migration (Silver Contributor)
Solution

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() 
} 

1 best response

Accepted Solutions
best response confirmed by VI_Migration (Silver Contributor)
Solution

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() 
} 

View solution in original post