When I do run this via Powershell Universal I do get an Error:
[information] de-pscron02\svc-pscron
[information] Major Minor Build Revision
[information] ----- ----- ----- --------
[information] 5 1 17763 3770
[information] Debug: Get-PnPListItem
[error] Exception has been thrown by the target of an invocation.
When I run it via Powershell on the Machine directly with the same user, all is fine:
de-pscron02\svc-pscron
Major Minor Build Revision
----- ----- ----- --------
5 1 17763 3770
Debug: Get-PnPListItem
I noticed that running with Powershell 7 works also in PSU, but some other parts of the script do require the old AzureAD module that can only run in PS 5.1.
I just updated to 4.3 and have tried it with a PowerShell 7 environment and integrated. I know we have had challenges in the past with MS modules and Universal. This was working until one of the 4.x versions came out (sorry, not sure exactly which one seemed to break it).
sorry to res the thread, but i’m running into a very similar issue. using connect-pnponline with a cert thumbprint for entra app auth, and set-pnptenantsite to modify a site collector.
if i run pwsh as the service account running PSU using the exact same commands, it works perfectly.
as soon as it is trying to run the app in PSU i get the below errors. i’ve been fighting this for a bit now and i’m all out of ideas… reinstalled PnP, reinstalled the sharepoint client sdk assemblies, rebooted the box, restarted the service, etc.
if anyone can offer any advise it would be appreciated.