BUG: Connect-AzureAD command does not work inside CloudShell if it is in a .ps1 script
Repro: If you just type Connect-AzureAD on a PowerShell Cloud Shell, it works.
If you type in an save "Connect-AzureAD" in a ps1 file, upload your ps1 file and then call the ps1 file from Cloud Shell, it fails with below errors:
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:60
Line |
60 | & ($script:PSCloudShellUtilityModuleInfo){param([string]$Label, [ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The expression after '&' in a pipeline element produced an object that was
| not valid. It must result in a command name, a script block, or a CommandInfo
| object.
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:167
Line |
167 | $azureADParameters = @{'Identity' = $true; 'TenantId' = $env: …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot index into a null array.
