Closed AlexSen closed 4 years ago
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
I can't reproduce this issue. I tried to follow your steps and have thus created a new Azure App Registration with just these permissions:
I then went to /_layouts/appinv.aspx for the same Client ID and gave it these permissions:
<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl" />
</AppPermissionRequests>
I just get an access denied, but not the object reference error you're seeing. I had a look at the code and in this way you are connecting, it will only use the permissions set on AAD and not the ones you set through appinv.aspx for executing Send-PnPMail. So you would need to raise the AAD permissions to at least Sites.ReadWrite.All and then Send-PnPMail should work.
There are some known issues with PowerShell sessions not getting cleaned up correctly, even when using Disconnect-PnPOnline. Could it be that your PowerShell session has gotten polluted because of that and that makes you get into the object reference error?
Closing as no response received. Feel free to reopen in case you have further information to share.
Reporting an Issue or Missing Feature
Reporting an Issue
Expected behavior
Email sent from SPO Site used in Connection
Actual behavior
Steps to reproduce behavior
AzApp has:
Which version of the PnP-PowerShell Cmdlets are you using?
What is the version of the Cmdlet module you are running?
How did you install the PnP-PowerShell Cmdlets?