I am failing to use the SharePointPnpPowerShellOnline PS Module as part of my release pipeline. We are using Azure DevOps with a hosted build agent on a Azure VM. I want to accomplish uploading build artifacts into Microsoft Teams/Sharepoint.
- I installed SharePointPnpPowerShellOnline on the server (under the account that the DevOps build agent operates with), yet the build agent fails to execute the script on the first line that uses said module (a call to
Connect-PnPOnline -Url https://... -Credentials ...). Error message: "Connect-PnPOnline : The term 'Connect-PnPOnline' is not recognized as the name of a cmdlet, function, script file". So it behaves as if the module is not installed at all. - yet when I log onto the server (with the correct account), the module is found and I can execute Connect-PnPOnline succesfully.
- the used Azure DevOps pipeline task is "PowerShell".
Shouldn't the build agent be able to find the installed module, as I installed it for its user?
Edit: I did some more "debugging", namely:
- logging the Username the script is running under by [Environment]::UserName, to make sure I installed the module for the right user. result: matches the expected user.
- Listing the installed modules by Get-InstalledModule in my script. Once it is executed in the Release pipeline by the agent it yields an empty list. yet executing the same script on the VM (via RemoteDesktop) yields the installed modules
My guess is I'm doing a stupid beginner mistake because I haven't that much experience with PowerShell...