Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.16k stars 3.78k forks source link

Username/Password login in Powershell Core #11581

Open TheOnlyWei opened 4 years ago

TheOnlyWei commented 4 years ago

Description

I was advised I should create a bug report for not being able to log in using username and password in Powershell core. This makes things difficult when we port our tests from Windows Powershell to Powershell Core since we rely on authenticating in Azure Stack using username and password before we can create service principals to use. Even then, service principals are limited in privilege and cannot be used to test everything.

I have been writing work-arounds to the rule against username and password authentication in Powershell Core, but if username and password should be supported and is a simple fix, then I would rather wait for that instead of writing work-arounds that I have to change again in the future.

This is the related source code: https://github.com/Azure/azure-powershell/blob/Az.Accounts-preview/src/Accounts/Accounts/Account/ConnectAzureRmAccount.cs#L269

But we are using modified versions of the Az modules to test with Azure Stack, so those modules would need to be changed as well.

Steps to reproduce

Simply attempt to run Connect-AzAccount in a Powershell Core session using username and password authentication such as:

PS C:\test\Workloads\DeveloperExperience\PowerShell> Connect-AzAccount -Environment <ENVIRONMENT_NAME> -Credential <PS_CREDENTIALS> -Tenant <TENANT_ID>
Connect-AzAccount: Username + Password authentication is not supported in PowerShell Core.  Please use device code authentication for interactive log in, or Service Principal authentication for script log in.

Environment data

PS C:\test\Workloads\DeveloperExperience\PowerShell> $psversiontable

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

PS C:\test\Workloads\DeveloperExperience\PowerShell> get-module -ListAvailable

    Directory: C:\program files\powershell\7\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   7.0.0.0               CimCmdlets                          Core      {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSession…}
Manifest   1.2.5                 Microsoft.PowerShell.Archive        Desk      {Compress-Archive, Expand-Archive}
Manifest   7.0.0.0               Microsoft.PowerShell.Diagnostics    Core      {Get-WinEvent, New-WinEvent, Get-Counter}
Manifest   7.0.0.0               Microsoft.PowerShell.Host           Core      {Start-Transcript, Stop-Transcript}
Manifest   7.0.0.0               Microsoft.PowerShell.Management     Core      {Add-Content, Clear-Content, Get-Clipboard, Set-Clipboard…}
Manifest   7.0.0.0               Microsoft.PowerShell.Security       Core      {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential…}
Manifest   7.0.0.0               Microsoft.PowerShell.Utility        Core      {Export-Alias, Get-Alias, Import-Alias, New-Alias…}
Manifest   7.0.0.0               Microsoft.WSMan.Management          Core      {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSManQuickConfig…}
Script     1.4.6                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource…}
Script     2.2.3                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability…}
Script     2.0.5                 PSDesiredStateConfiguration         Core      {Configuration, New-DscChecksum, Get-DscResource, Invoke-DscResource}
Script     7.0.0.0               PSDiagnostics                       Core      {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, Enable-PSTrace…}
Script     2.0.0                 PSReadLine                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remove-PSReadLineKeyHandler, Ge…
Binary     2.0.3                 ThreadJob                           Desk      Start-ThreadJob

    Directory: C:\Program Files\WindowsPowerShell\Modules\Microsoft.AzureStack.Services.Storage

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     0.0.0.0               AcsIbcAdapter                       Desk

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.0                   AS.Certificate                      Desk      {ExportCertificate, ImportPfxCertificate, GetCertificate, CreatePSDrive}
Script     1.0                   AS.DumpOnLargeHost                  Desk
Script     1.0                   AS.Group                            Desk
Script     1.0                   AS.Impersonation                    Desk
Script     1.0                   AS.Netlogon                         Desk
Script     1.0                   AS.Service                          Desk      {ServiceExists, ThrowInvalidArgumentError, TestStartupType, NormalizeUserName…}
Script     1.0                   AS.ServicePrincipalName             Desk
Script     1.0                   AS.TimeServer                       Desk
Script     1.0                   AS.WMIConfiguration                 Desk
Script     1.0                   AS.WSMan                            Desk
Manifest   1.1.0.0               AS.xAdcsDeployment                  Desk
Manifest   1.17.0.0              AS.xWebAdministration               Desk
Script     0.10.0     preview    Az                                  Core,Desk
Script     2.0.1      preview    Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzContextAutosave, Enable-AzDataCollection, Enabl…
Script     0.10.0     preview    Az.Billing                          Core,Desk Get-UsageAggregates
Script     0.1.0      preview    Az.BootStrapper                     Core,Desk {Update-AzProfile, Uninstall-AzProfile, Install-AzProfile, Use-AzProfile…}
Script     0.10.0     preview    Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAvailabilitySet, Update-AzAv…
Script     1.1.0                 Az.DataBoxEdge                      Core,Desk {Get-AzDataBoxEdgeJob, Get-AzDataBoxEdgeDevice, Invoke-AzDataBoxEdgeDevice, New-AzDa…
Script     0.10.0     preview    Az.Dns                              Core,Desk {Get-AzDnsRecordSet, New-AzDnsRecordConfig, Remove-AzDnsRecordSet, Set-AzDnsRecordSe…
Script     1.4.3                 Az.EventHub                         Core,Desk {New-AzEventHubNamespace, Get-AzEventHubNamespace, Set-AzEventHubNamespace, Remove-A…
Script     0.10.0     preview    Az.IotHub                           Core,Desk {Add-AzIotHubKey, Get-AzIotHubEventHubConsumerGroup, Get-AzIotHubConnectionString, G…
Script     0.10.0     preview    Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Set-AzKeyVaultCertificateAttribute, Stop-AzKeyVaultCerti…
Script     1.6.0                 Az.Monitor                          Core,Desk {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLogProfile, Get-AzLogProfile…}
Script     0.10.0     preview    Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthenticationCertificate, Get-AzApplicationGatewayAuthenti…
Script     0.10.0     preview    Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRoleAssignment, New-AzRoleA…
Script     0.10.0     preview    Az.Storage                          Core,Desk {Get-AzStorageTableStoredAccessPolicy, Get-AzStorageTable, New-AzStorageTableSASToke…
Script     0.10.0     preview    Az.Websites                         Core,Desk {Get-AzAppServicePlan, Set-AzAppServicePlan, New-AzAppServicePlan, Remove-AzAppServi…
Script     0.9.0      preview    Azs.AzureBridge.Admin               Core,Desk {Get-AzsAzureBridgeActivation, Get-AzsAzureBridgeDownloadedProduct, Get-AzsAzureBrid…
Script     0.9.0      preview    Azs.Backup.Admin                    Core,Desk {Get-AzsBackup, Get-AzsBackupConfiguration, Restore-AzsBackup, Set-AzsBackupConfigur…
Script     0.9.0      preview    Azs.Commerce.Admin                  Core,Desk Get-AzsSubscriberUsage
Script     0.9.0      preview    Azs.Compute.Admin                   Core,Desk {Add-AzsPlatformImage, Add-AzsVMExtension, Get-AzsComputeQuota, Get-AzsDisk…}
Script     0.9.0                 Azs.Deployment.Admin                Core,Desk {IsOperationResultTerminalState, Get-AzsProductDeployment, Get-AzsActionPlan, Invoke…
Script     0.9.0      preview    Azs.Fabric.Admin                    Core,Desk {Add-AzsScaleUnitNode, Disable-AzsInfrastructureRoleInstance, Disable-AzsScaleUnitNo…
Script     0.9.0      preview    Azs.Gallery.Admin                   Core,Desk {Add-AzsGalleryItem, Get-AzsGalleryItem, Remove-AzsGalleryItem}
Script     0.9.0      preview    Azs.InfrastructureInsights.Admin    Core,Desk {Close-AzsAlert, Get-AzsAlert, Get-AzsRegionHealth, Get-AzsRegistrationHealth…}
Script     0.9.0      preview    Azs.KeyVault.Admin                  Core,Desk Get-AzsKeyvaultQuota
Script     0.9.0      preview    Azs.Network.Admin                   Core,Desk {Get-AzsLoadBalancer, Get-AzsNetworkAdminOverview, Get-AzsNetworkQuota, Get-AzsPubli…
Script     0.9.0      preview    Azs.Storage.Admin                   Core,Desk {Get-AzsStorageAccount, Get-AzsStorageAcquisition, Get-AzsStorageQuota, Get-AzsStora…
Script     0.9.0      preview    Azs.Subscriptions                   Core,Desk {Get-AzsDelegatedProviderOffer, Get-AzsOffer, Get-AzsSubscription, New-AzsSubscripti…
Script     0.9.0      preview    Azs.Subscriptions.Admin             Core,Desk {Add-AzsPlanToOffer, Get-AzsAcquiredPlan, Get-AzsAdminManagedOffer, Get-AzsDelegated…
Script     0.9.0      preview    Azs.Update.Admin                    Core,Desk {Get-AzsUpdate, Get-AzsUpdateLocation, Get-AzsUpdateRun, Install-AzsUpdate…}
Script     2.0.0      preview    AzureStack                          Core,Desk
Script     0.0                   AzureStackInstallerCommon           Desk      {Get-MsiDatabaseInfo, Invoke-ScriptBlockWithRetries, ConvertTo-StringEncryptedByMach…
Manifest   1.0                   CloudCommon                         Desk      {Disable-RemoteClientCredSSP, Reset-RestartCallback, Get-NugetVersions, PublishAndSt…
Script     1.0                   DSC.ACS.ACSServices                 Desk
Script     1.0                   DSC.ACS.Blob                        Desk
Script     1.0                   DSC.ACS.Common                      Desk      {Get-ServiceAccountPrivilege, Add-ServiceAccountPrivilege}
Script     1.0                   DSC.ACS.Settings                    Desk      {Get-IndicatorFilePath, Test-SecureStringEqual, New-SettingsManager}
Script     1.0                   DSC.CertHelpers                     Desk      GetSubjectName
Script     1.0                   DSC.ExternalDNS                     Desk      {Retry-ScriptBlock, Stop-DnsLogging, Append-Dot, Start-DnsLogging}
Script     1.0                   DSC.HealthAgent                     Desk
Script     1.0                   DSC.MonitoringAgent                 Desk
Script     1.0                   DSC.NetworkController               Desk
Script     1.0                   DSC.ProcessorPowerManagement        Desk
Script     1.0                   DSC.ServiceWithFailureAction        Desk
Script     1.0                   DSC.Storage                         Desk
Script     1.0                   DSC.TraceCollector                  Desk
Script     0.0                   HostAgentRestart                    Desk      Restart-HostAgents
Script     0.0                   HostUpdate                          Desk      {Copy-CustomizedVHDToHost, Remove-OldHostVHD, Stop-LocalVMs}
Script     0.0                   HyperVLogging                       Desk      SetHyperVLogging
Script     1.0                   JustEnoughAdministration            Desk
Binary     2.6                   Microsoft.AzureStack.Diagnostics    Desk
Script     1.0                   Microsoft.AzureStack.Diagnostics.D… Desk      {Get-AzureStackLog, Invoke-AzureStackOnDemandLog, Get-AzureStackLogs}
Script     1.0                   Microsoft.AzureStack.Diagnostics.D… Desk      {Get-ServiceFabricStandaloneLog, Get-AzureStackAlert, Get-DiagnosticsRegistrations, …
Script     1.1                   Microsoft.AzureStack.Diagnostics.V… Desk      Test-AzureStack
Script     0.0                   Microsoft.AzureStack.Fabric.Comput… Desk      {Get-CpiBitlockerLocalVolumeObject, Pause-CpiClusterNode, Set-CpiClusterResourceGrou…
Script     0.0                   Microsoft.AzureStack.Fabric.Comput… Desk      {Remove-CpiVmHardDiskDrive, Update-CpiClusterVirtualMachineConfiguration, Unset-CpiV…
Binary     0.0.0.0               Microsoft.AzureStack.Fabric.Comput… Desk
Manifest   1.0.0.0               Microsoft.AzureStack.Fabric.Storag… Desk      {Make_SCFileShare, New-SCFileShare, Get_CimInstance, Remove-SCVolume…}
Script     0.0                   Microsoft.AzureStack.GPWmiFilter    Desk      {Enable-ADSystemOnlyChange, Set-GPWmiFilter, ConvertTo-WmiFilter, New-GPWmiFilter…}
Binary     0.0.0.0               Microsoft.AzureStack.OOBManagement  Desk
Manifest   1.0                   Microsoft.AzureStack.PrivilegedEnd… Desk      {Get-SupportSessionInfo, Get-SupportSessionToken, Unlock-SupportSession, Get-Recover…
Script     1.0.1                 Microsoft.PowerShell.Operation.Val… Desk      {Get-OperationValidation, Invoke-OperationValidation}
Script     1.0                   NET.Tracing                         Desk
Script     0.0                   NetworkControllerRESTWrappers       Desk      {IsIpPoolRangeValid, Remove-NCLoadBalancerMux, New-NCL3Tunnel, Remove-NCLogicalNetwo…
Script     0.0                   NewManagementVM                     Desk      {Attach-VMArtifactDiffDisk, Remove-ManagementVM, New-ManagementVM, New-VirtualMachin…
Script     1.4.6                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource…}
Binary     1.0.0.1               PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource…}
Manifest   1.0.0.0               PDT.DSC.HyperV                      Desk
Manifest   1.0.0.0               PDT.DSC.Networking                  Desk      {Convert-CIDRToSubhetMask, Get-LocalizedData, New-InvalidArgumentException, New-Inva…
Manifest   1.0.0.0               PDT.DSC.Service                     Desk
Script     1.0.0.0               PDT.DSC.Utilities                   Desk
Script     1.0                   PDT_MigrationProtocol               Desk
Script     3.4.0                 Pester                              Desk      {Describe, Context, It, Should…}
Script     2.2.1                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability…}
Script     1.0.0.1               PowerShellGet                       Desk      {Install-Module, Find-Module, Save-Module, Update-Module…}
Script     1.1.13                PrivateCloud.DiagnosticInfo         Desk      {Get-SddcDiagnosticInfo, Show-SddcDiagnosticReport, Show-SddcDiagnosticStorageLatenc…
Script     2.0.0      beta2      PSReadline                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remove-PSReadLineKeyHandler, Ge…
Script     0.0                   Shutdown                            Desk      Stop-LocalPhysicalComputer
Script     0.0                   StorageSubsystem                    Desk      Get-VolumesFromStorageSubsystem
Manifest   2.0.0.0               xSmbShare                           Desk

    Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   1.0.1.0               ActiveDirectory                     Core,Desk {Add-ADCentralAccessPolicyMember, Add-ADComputerServiceAccount, Add-ADDomainControll…
Manifest   2.0.1.0               Appx                                Core,Desk {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest, Remove-AppxPackage…}
Manifest   1.0.0.0               BitLocker                           Core,Desk {Unlock-BitLocker, Suspend-BitLocker, Resume-BitLocker, Remove-BitLockerKeyProtector…
Manifest   1.0.0.0               BranchCache                         Core,Desk {Add-BCDataCacheExtension, Clear-BCCache, Disable-BC, Disable-BCDowngrading…}
Manifest   2.0.0.0               DcbQos                              Core,Desk {Get-NetQosFlowControl, Set-NetQosFlowControl, Enable-NetQosFlowControl, Disable-Net…
Manifest   1.0                   Defender                            Core,Desk {Get-MpPreference, Set-MpPreference, Add-MpPreference, Remove-MpPreference…}
Manifest   1.0                   DFSN                                Core,Desk {Get-DfsnRoot, Remove-DfsnRoot, Set-DfsnRoot, New-DfsnRoot…}
Manifest   1.0.0.0               DirectAccessClientComponents        Core,Desk {Disable-DAManualEntryPointSelection, Enable-DAManualEntryPointSelection, Get-DAClie…
Manifest   1.0.0.0               DnsClient                           Core,Desk {Resolve-DnsName, Clear-DnsClientCache, Get-DnsClient, Get-DnsClientCache…}
Manifest   2.0.0.0               DnsServer                           Core,Desk {Add-DnsServerConditionalForwarderZone, Add-DnsServerDirectoryPartition, Add-DnsServ…
Manifest   1.0.0.0               EventTracingManagement              Core,Desk {Start-EtwTraceSession, New-EtwTraceSession, Get-EtwTraceSession, Update-EtwTraceSes…
Manifest   1.0.0.0               HgsDiagnostics                      Core,Desk {New-HgsTraceTarget, Get-HgsTrace, Get-HgsTraceFileData, Test-HgsTraceTarget}
Binary     2.0.0.0               Hyper-V                             Core,Desk {Add-VMAssignableDevice, Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMGpuPartitionAd…
Binary     1.1                   Hyper-V                             Core,Desk {Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMHardDiskDrive, Add-VMMigrationNetwork…}
Manifest   3.0.0.0               Microsoft.PowerShell.Diagnostics    Core,Desk {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter…}
Manifest   1.0.0.0               Microsoft.PowerShell.LocalAccounts  Core,Desk {Add-LocalGroupMember, Disable-LocalUser, Enable-LocalUser, Get-LocalGroup…}
Manifest   3.1.0.0               Microsoft.PowerShell.Management     Core,Desk {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path…}
Manifest   1.0                   MMAgent                             Core,Desk {Disable-MMAgent, Enable-MMAgent, Set-MMAgent, Get-MMAgent…}
Manifest   2.0.0.0               NetAdapter                          Core,Desk {Disable-NetAdapter, Disable-NetAdapterBinding, Disable-NetAdapterChecksumOffload, D…
Manifest   1.0.0.0               NetConnection                       Core,Desk {Get-NetConnectionProfile, Set-NetConnectionProfile}
Manifest   1.0.0.0               NetEventPacketCapture               Core,Desk {New-NetEventSession, Remove-NetEventSession, Get-NetEventSession, Set-NetEventSessi…
Manifest   2.0.0.0               NetLbfo                             Core,Desk {Add-NetLbfoTeamMember, Add-NetLbfoTeamNic, Get-NetLbfoTeam, Get-NetLbfoTeamMember…}
Manifest   1.0.0.0               NetNat                              Core,Desk {Get-NetNat, Get-NetNatExternalAddress, Get-NetNatStaticMapping, Get-NetNatSession…}
Manifest   2.0.0.0               NetQos                              Core,Desk {Get-NetQosPolicy, Set-NetQosPolicy, Remove-NetQosPolicy, New-NetQosPolicy}
Manifest   2.0.0.0               NetSecurity                         Core,Desk {Get-DAPolicyChange, New-NetIPsecAuthProposal, New-NetIPsecMainModeCryptoProposal, N…
Manifest   1.0.0.0               NetSwitchTeam                       Core,Desk {New-NetSwitchTeam, Remove-NetSwitchTeam, Get-NetSwitchTeam, Rename-NetSwitchTeam…}
Manifest   1.0.0.0               NetTCPIP                            Core,Desk {Get-NetIPAddress, Get-NetIPInterface, Get-NetIPv4Protocol, Get-NetIPv6Protocol…}
Manifest   1.0.0.0               NetWNV                              Core,Desk {Get-NetVirtualizationProviderAddress, Get-NetVirtualizationGlobal, Get-NetVirtualiz…
Manifest   1.0.0.0               NetworkConnectivityStatus           Core,Desk {Get-DAConnectionStatus, Get-NCSIPolicyConfiguration, Reset-NCSIPolicyConfiguration,…
Manifest   1.0.0.0               NetworkSwitchManager                Core,Desk {Disable-NetworkSwitchEthernetPort, Enable-NetworkSwitchEthernetPort, Get-NetworkSwi…
Manifest   1.0.0.0               NetworkTransition                   Core,Desk {Add-NetIPHttpsCertBinding, Disable-NetDnsTransitionConfiguration, Disable-NetIPHttp…
Manifest   1.0                   NFS                                 Core,Desk {Get-NfsMappedIdentity, Get-NfsNetgroup, Install-NfsMappingStore, New-NfsMappedIdent…
Manifest   1.0.0.0               PcsvDevice                          Core,Desk {Get-PcsvDevice, Start-PcsvDevice, Stop-PcsvDevice, Restart-PcsvDevice…}
Manifest   1.0.0.0               PnpDevice                           Core,Desk {Get-PnpDevice, Get-PnpDeviceProperty, Enable-PnpDevice, Disable-PnpDevice}
Manifest   1.0.0.0               ScheduledTasks                      Core,Desk {Get-ScheduledTask, Set-ScheduledTask, Register-ScheduledTask, Unregister-ScheduledT…
Manifest   2.0.0.0               SecureBoot                          Core,Desk {Confirm-SecureBootUEFI, Set-SecureBootUEFI, Get-SecureBootUEFI, Format-SecureBootUE…
Manifest   2.0.0.0               SmbShare                            Core,Desk {Get-SmbShare, Remove-SmbShare, Set-SmbShare, Block-SmbShareAccess…}
Manifest   2.0.0.0               SmbWitness                          Core,Desk {Get-SmbWitnessClient, Move-SmbWitnessClient, gsmbw, msmbw…}
Manifest   2.0.0.0               SoftwareInventoryLogging            Core,Desk {Get-SilComputer, Get-SilComputerIdentity, Get-SilSoftware, Get-SilWindowsUpdate…}
Manifest   1.0.0.0               StartLayout                         Core,Desk {Export-StartLayout, Import-StartLayout, Export-StartLayoutEdgeAssets, Get-StartApps}
Manifest   2.0.0.0               Storage                             Core,Desk {Add-InitiatorIdToMaskingSet, Add-PartitionAccessPath, Add-PhysicalDisk, Add-Storage…
Manifest   1.0.0.0               StorageQoS                          Core,Desk {Get-StorageQoSPolicy, Get-StorageQoSPolicyStore, Set-StorageQoSPolicyStore, Remove-…
Manifest   2.0.0.0               TrustedPlatformModule               Core,Desk {Get-Tpm, Initialize-Tpm, Clear-Tpm, Unblock-Tpm…}
Manifest   2.0.0.0               VpnClient                           Core,Desk {Add-VpnConnection, Set-VpnConnection, Remove-VpnConnection, Get-VpnConnection…}
Manifest   1.0.0.0               Wdac                                Core,Desk {Get-OdbcDriver, Set-OdbcDriver, Get-OdbcDsn, Add-OdbcDsn…}
Manifest   1.0.0.0               WindowsDeveloperLicense             Core,Desk {Get-WindowsDeveloperLicense, Unregister-WindowsDeveloperLicense, Show-WindowsDevelo…
Script     1.0                   WindowsErrorReporting               Core,Desk {Enable-WindowsErrorReporting, Disable-WindowsErrorReporting, Get-WindowsErrorReport…
Manifest   1.0.0.0               WindowsUpdate                       Core,Desk Get-WindowsUpdateLog
Manifest   1.0.0.2               WindowsUpdateProvider               Core,Desk {Get-WUAVersion, Get-WULastInstallationDate, Get-WULastScanSuccessDate, Get-WUIsPend…

Debug output

DEBUG: 3:42:53 PM - ConnectAzureRmAccountCommand begin processing with ParameterSet 'UserWithCredential'.
DEBUG: 3:42:53 PM - Autosave setting from startup session: 'Process'
DEBUG: 3:42:53 PM - No autosave setting detected in environment variable 'AzContextAutoSave'.
DEBUG: 3:42:53 PM - Using Autosave scope 'Process'
Connect-AzAccount: Username + Password authentication is not supported in PowerShell Core.  Please use device code authentication for interactive log in, or Service Principal authentication for script log in.
DEBUG: 3:42:53 PM - ConnectAzureRmAccountCommand end processing.

Error output

Connect-AzAccount: Username + Password authentication is not supported in PowerShell Core.  Please use device code authentication for interactive log in, or Service Principal authentication for script log in.
keystroke commented 4 years ago

My guess is that this code was added to "preemptively fail" the auth scenarios where the account has something like MFA enabled, and the authentication requires interactivity for some UI like a browser. However, this is only the case for accounts with those security properties enabled. For user accounts that do not require MFA, they can successfully authenticate using their username and password. Instead, the cmdlet can attempt the login flow and allow the error from AAD to be presented to the user, something like "Unable to complete the silent authentication flow. User interactivity is required. Please use a different account, a service principal, or the device login flow to proceed".

ghost commented 3 years ago

I encountered same error, in enterprise environment, we don't prefer to use service principal, any idea on support work account with password?