Not related to Connect-azureAD powershell in azure function
I have a simple Azure function (HTTP trigger) written in PowerShell.
$user = '[email protected]';
$pass = 'password';
Import-Module AzureAD -UseWindowsPowerShell;
$secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($Username, $secpasswd);
Connect-AzureAD -Credential $cred;
Disconnect-AzureAD;
Get-PSSession | Remove-PSSession;
The first time it runs, it works. If I hit it again, it throws an exception "Exception calling "GetSteppablePipeline" with "1" argument(s): "The parameter is incorrect." If I call it again after an hour, it works again (1 time), then it fails again with the same error.
Any ideas?
Thank you!
CodePudding user response:
I have tested in my environment.
Please use the below code :
$user = '[email protected]';
$secpasswd = 'password' | ConvertTo-SecureString -AsPlainText -Force;
Import-Module AzureAD -UseWindowsPowerShell;
$cred = New-Object Management.Automation.PSCredential ($user, $secpasswd);
Connect-AzureAD -Credential $cred;
Disconnect-AzureAD;