I am trying to write an azure function in PowerShell to connect to a Microsoft Teams account:
using namespace System.Net # Input bindings are passed in via param block. param($Request, $TriggerMetadata) # Write to the Azure Functions log stream. Write-Host "Running teams account setup." [string]$userName = 'xxx' [string]$userPassword = 'xxx' [securestring]$secStringPassword = ConvertTo-SecureString $userPassword -AsPlainText -Force Write-Host ($secStringPassword | Format-Table | Out-String) [pscredential]$credentials = New-Object System.Management.Automation.PSCredential ($userName, $secStringPassword) Write-Host ($credentials | Format-Table | Out-String) Connect-MicrosoftTeams -Credential $credentials
The error message I'm getting is essentially: ERROR: password_required_for_managed_user: Password is required for managed user
I read that it might be necessary to replace -Credentials with -Identity, but I can't find any documentation on how to implement that.