Powershell Using CSOM - Exception on Connecting to Governance Site: Exception calling "ExecuteQuery" with "0" argument(s): "The IDCRL response header from server 'https://XXXXXXXX.sharepoint.com/' is not valid. The response header value is 'NTLM'. The response
status code is 'Unauthorized'.
Somtimes, Using PnP, I am getting 403 forbidden.
I am using P2 PIM to elevate myself to SharePoint Service Admin role.
Sometimes, if I restart my machine or if I de-activate and reactivate SSA using the PIM, I am able to run the same script without any issues and sometimes it doesn't and the script works the next day.
Example: I was creating 6 sites and creating SP groups in those sites using PnP. The first two sites were created successfully with groups. Then rest of the 4 sites are created and got 403 for each of the Group creation in those sites.
I cleared temp and de-activate, reactivate SSA and restarted machine -> ran the same script without site creation, the groups were created for the next 2 sites. But, got same 403 error for the sites 5,6.
Add-PnPUserToGroup : The remote server returned an error: (403) Forbidden.
Thanks in Advance.
Please note that this has nothing to do with MFA, password files, incorrect pwd etc....