SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-75711%22%20slang%3D%22en-US%22%3ETask%20list%20-%20setting%20EnableAssignToEmail%20using%20PnP%20powershell%20-%20not%20working%20consistently%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-75711%22%20slang%3D%22en-US%22%3E%3CP%3EUsing%20the%20following%20powershell%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%24csvFile%20%3D%20%22.%5CSiteIDs.csv%22%0A%24sites%20%3D%20Import-Csv%20%24csvfile%0A%0AConnect-SPOnline%20-Url%20https%3A%2F%2F%26lt%3Btenantname%26gt%3B.sharepoint.com%20-Credentials%20%26lt%3Bcreds%26gt%3B%0A%0Aforeach%20(%24site%20in%20%24sites)%0A%7B%0A%24web%20%3D%20Get-PnPWeb%20-Identity%20%24site.siteid%0Awrite-host%20%24web.Title%0A%24List%20%3D%20Get-PnPList%20-Web%20%24web%20-Identity%20Tasks%0A%24list.EnableAssignToEmail%20%3D%20%24true%0A%24list.Update()%0A%7D%3C%2FPRE%3E%3CP%3E%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20some%20cases%20the%20property%20is%20showing%20as%20True%20if%20I%20enter%3C%2FP%3E%3CPRE%3E%24list.EnableAssignToEmail%3C%2FPRE%3E%3CP%3Ebut%20looking%20in%20the%20GUI%2C%20it%20shows%20as%20Disabled%20in%20the%20majority%20of%20cases%20-%20even%20having%20left%20it%20overnight%20to%20see%20if%20it%20was%20just%20a%20display%20issue.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOn%20a%20single%20test%20list%20it%20seemed%20to%20take%20a%20number%20of%20attempts%20to%20get%20the%20property%20to%20show%20as%20True%20in%20Powershell%20(was%20showing%20blank).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%3F%26nbsp%3B%20Am%20I%20doing%20something%20fundamentally%20wrong%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-76454%22%20slang%3D%22en-US%22%3ERe%3A%20Task%20list%20-%20setting%20EnableAssignToEmail%20using%20PnP%20powershell%20-%20not%20working%20consistently%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-76454%22%20slang%3D%22en-US%22%3EWorks%20great%20-%20thanks%20so%20much!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-76076%22%20slang%3D%22en-US%22%3ERe%3A%20Task%20list%20-%20setting%20EnableAssignToEmail%20using%20PnP%20powershell%20-%20not%20working%20consistently%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-76076%22%20slang%3D%22en-US%22%3E%3CP%3ETry%20the%20below%20script.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%24csvFile%20%3D%20%22.%5CSiteIDs.csv%22%0A%24sites%20%3D%20Import-Csv%20%24csvfile%0A%24cred%3DGet-Credential%0A%0Aforeach%20(%24site%20in%20%24sites)%0A%7B%0AConnect-PnPOnline%20-Url%20%24site.URl%20-Credentials%20%24cred%0A%24ctx%3DGet-PnPContext%0A%24List%20%3D%20Get-PnPList%20-Identity%20Tasks%0A%24list.EnableAssignToEmail%20%3D%20%24true%0A%24list.Update()%0A%24ctx.load(%24list)%20%20%20%20%20%20%0A%24ctx.executeQuery()%20%0A%7D%20%0A%0A%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-75746%22%20slang%3D%22en-US%22%3ERe%3A%20Task%20list%20-%20setting%20EnableAssignToEmail%20using%20PnP%20powershell%20-%20not%20working%20consistently%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-75746%22%20slang%3D%22en-US%22%3E%3CP%3ESPO%20-%20trying%20to%26nbsp%3Benable%20the%20setting%20on%20a%20Task%20list%20-%26nbsp%3B%20'send%20e-mail%20when%20ownership%20is%20assigned'%26nbsp%3B%20(under%20advanced%20settings%20on%20the%20GUI).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-75739%22%20slang%3D%22en-US%22%3ERe%3A%20Task%20list%20-%20setting%20EnableAssignToEmail%20using%20PnP%20powershell%20-%20not%20working%20consistently%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-75739%22%20slang%3D%22en-US%22%3EWhat%20are%20you%20exactly%20trying%20to%20do%3F%20Are%20you%20executing%20on%20SPO%20or%20SP%20OnPrem%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-75725%22%20slang%3D%22en-US%22%3ERe%3A%20Task%20list%20-%20setting%20EnableAssignToEmail%20using%20PnP%20powershell%20-%20not%20working%20consistently%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-75725%22%20slang%3D%22en-US%22%3Eok%20-%20so%20I%20corrected%20that%2C%20and%20re-ran%20-%20same%20problem.%3CBR%20%2F%3E%3CBR%20%2F%3E(I%20wasn't%20aware%20that%20variable%20names%20were%20case%20sensitive%20in%20PoSh%20-%20I%20know%20some%20other%20things%20are%20though)%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20anyway.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-75714%22%20slang%3D%22en-US%22%3ERe%3A%20Task%20list%20-%20setting%20EnableAssignToEmail%20using%20PnP%20powershell%20-%20not%20working%20consistently%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-75714%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20line%20is%20using%20%24List%20(with%20capital%20L)%2C%20the%20other%20lines%20are%20using%20%24list%20(lowercase)%3A%3C%2FP%3E%3CPRE%3E%24List%20%3D%20Get-PnPList%20-Web%20%24web%20-Identity%20Tasks%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Valued 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 Rob Ellis (Valued 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() 
}