AzureRM.Profile: Importing a context does not replace the token cache
Description
When using Save-AzureRMContext in one PowerShell window and Import-AzureRMContext in another window does not allow me to call commands.
Script/Steps for Reproduction
# After Login
PS> Save-AzureRMContext -Path $path
# After Login
PS> Import-AzureRMContext -Path $path
PS> Get-AzureRMVM
Get-AzureRMVm : Your Azure credentials have not been set up or have expired, please run Connect-AzureRmAccount to set up your Azure credentials.
At line:1 char:1
+ Get-AzureRMVm
+ ~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureRmVM], ArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.GetAzureVMCommand
Module Version
Get-Module -ListAvailable
Directory: C:\Users\AzureStackAdmin\Documents\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.2.0 Azs.Azurebridge.Admin {Get-AzsAzureBridgeProduct, Invoke-AzsAzureBridgeProductDownload, Get-AzsAzureBridgeActivation, Remove-AzsAzureBridgeDownloadedP...
Script 0.2.0 Azs.Backup.Admin {Get-AzsBackupConfiguration, Get-AzsBackup, Restore-AzsBackup, Set-AzsBackupConfiguration...}
Script 0.2.0 Azs.Commerce.Admin Get-AzsSubscriberUsage
Script 0.2.0 Azs.Compute.Admin {Get-AzsVMExtension, Remove-AzsComputeQuota, New-AzsComputeQuota, Add-AzsPlatformImage...}
Script 0.2.0 Azs.Fabric.Admin {Restart-AzsInfrastructureRoleInstance, Get-AzsStorageSystem, Get-AzsScaleUnitNode, Disable-AzsScaleUnitNode...}
Script 0.2.0 Azs.Gallery.Admin {Add-AzsGalleryItem, Remove-AzsGalleryItem, Get-AzsGalleryItem}
Script 0.2.0 Azs.Infrastructureinsights.Admin {Close-AzsAlert, Get-AzsRegionHealth, Get-AzsAlert, Get-AzsRPHealth...}
Script 0.2.0 Azs.Keyvault.Admin Get-AzsKeyVaultQuota
Script 0.2.0 Azs.Network.Admin {Get-AzsNetworkQuota, New-AzsNetworkQuota, Get-AzsNetworkAdminOverview, Remove-AzsNetworkQuota...}
Script 0.2.0 Azs.Storage.Admin {Restore-AzsStorageAccount, New-AzsStorageQuota, Get-AzsStorageFarmMetricDefinition, Get-AzsQueueServiceMetricDefinition...}
Script 0.2.0 Azs.Subscriptions {Get-AzsDelegatedProviderOffer, Remove-AzsSubscription, Get-AzsOffer, New-AzsSubscription...}
Script 0.3.0 Azs.Subscriptions.Admin {Add-AzsPlanToOffer, Get-AzsSubscriptionsQuota, Get-AzsDelegatedProviderManagedOffer, Test-AzsNameAvailability...}
Script 0.2.0 Azs.Update.Admin {Resume-AzsUpdateRun, Get-AzsUpdateLocation, Get-AzsUpdateRun, Get-AzsUpdate...}
Script 4.1.1 Azure.Storage {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-AzureStorageTableStoredAccessPolicy, New-AzureStorageTable...}
Script 2.3.0 AzureRM
Script 4.0.2 AzureRM.Compute {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet, New-AzureRmAvailabilitySet, Update-AzureRmAvailabilitySet...}
Script 3.5.1 AzureRM.Dns {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remove-AzureRmDnsRecordSet, Set-AzureRmDnsRecordSet...}
Script 4.2.0 AzureRM.KeyVault {Add-AzureKeyVaultCertificate, Set-AzureKeyVaultCertificateAttribute, Stop-AzureKeyVaultCertificateOperation, Get-AzureKeyVaultC...
Script 5.0.1 AzureRM.Network {Add-AzureRmApplicationGatewayAuthenticationCertificate, Get-AzureRmApplicationGatewayAuthenticationCertificate, New-AzureRmAppl...
Script 5.5.1 AzureRM.Profile {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-AzureRmDataCollection, Enable-AzureRmContextAutosave...}
Script 6.0.2 AzureRM.Resources {Get-AzureRmProviderOperation, Remove-AzureRmRoleAssignment, Get-AzureRmRoleAssignment, New-AzureRmRoleAssignment...}
Script 1.1.0.1 AzureRM.Storage {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, New-AzureRmStorageAccount, New-AzureRmStorageAccountKey...}
Script 4.0.2 AzureRM.Tags {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}
Script 4.0.3 AzureRM.UsageAggregates Get-UsageAggregates
Script 1.5.0 AzureStack
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0 AS.Certificate {New-InvalidOperationError, Test-Thumbprint, New-InvalidArgumentError, Test-CertificatePath}
Script 1.0 AS.DumpOnLargeHost
Script 1.0 AS.Group
Script 1.0 AS.Impersonation
Script 1.0 AS.Netlogon
Script 1.0 AS.Service {GetUserNameAndPassword, NormalizeStartupType, Write-Log, StopService...}
Script 1.0 AS.ServicePrincipalName
Script 1.0 AS.TimeServer
Script 1.0 AS.WSMan
Manifest 1.1.0.0 AS.xAdcsDeployment
Manifest 1.17.0.0 AS.xWebAdministration
Script 0.2.0 Azs.Azurebridge.Admin {Get-AzsAzureBridgeProduct, Invoke-AzsAzureBridgeProductDownload, Get-AzsAzureBridgeActivation, Remove-AzsAzureBridgeDownloadedP...
Script 0.2.0 Azs.Backup.Admin {Get-AzsBackupConfiguration, Get-AzsBackup, Restore-AzsBackup, Set-AzsBackupConfiguration...}
Script 0.2.0 Azs.Commerce.Admin Get-AzsSubscriberUsage
Script 0.2.0 Azs.Compute.Admin {Get-AzsVMExtension, Remove-AzsComputeQuota, New-AzsComputeQuota, Add-AzsPlatformImage...}
Script 0.2.0 Azs.Fabric.Admin {Restart-AzsInfrastructureRoleInstance, Get-AzsStorageSystem, Get-AzsScaleUnitNode, Disable-AzsScaleUnitNode...}
Script 0.2.0 Azs.Gallery.Admin {Add-AzsGalleryItem, Remove-AzsGalleryItem, Get-AzsGalleryItem}
Script 0.2.0 Azs.Infrastructureinsights.Admin {Close-AzsAlert, Get-AzsRegionHealth, Get-AzsAlert, Get-AzsRPHealth...}
Script 0.2.0 Azs.Keyvault.Admin Get-AzsKeyVaultQuota
Script 0.2.0 Azs.Network.Admin {Get-AzsNetworkQuota, New-AzsNetworkQuota, Get-AzsNetworkAdminOverview, Remove-AzsNetworkQuota...}
Script 0.2.0 Azs.Storage.Admin {Restore-AzsStorageAccount, New-AzsStorageQuota, Get-AzsStorageFarmMetricDefinition, Get-AzsQueueServiceMetricDefinition...}
Script 0.2.0 Azs.Subscriptions {Get-AzsDelegatedProviderOffer, Remove-AzsSubscription, Get-AzsOffer, New-AzsSubscription...}
Script 0.2.0 Azs.Update.Admin {Resume-AzsUpdateRun, Get-AzsUpdateLocation, Get-AzsUpdateRun, Get-AzsUpdate...}
Script 4.1.1 Azure.Storage {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-AzureStorageTableStoredAccessPolicy, New-AzureStorageTable...}
Script 1.0.5.4 Azure.Storage {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-AzureStorageTableStoredAccessPolicy, New-AzureStorageTable...}
Script 2.3.0 AzureRM
Script 1.2.11 AzureRM
Script 0.3.0 AzureRM.BootStrapper {Update-AzureRmProfile, Uninstall-AzureRmProfile, Install-AzureRmProfile, Use-AzureRmProfile...}
Script 1.2.3.4 AzureRM.Compute {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet, New-AzureRmAvailabilitySet, Update-AzureRmAvailabilitySet...}
Script 3.5.1 AzureRM.Dns {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remove-AzureRmDnsRecordSet, Set-AzureRmDnsRecordSet...}
Script 3.4.1 AzureRM.Dns {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remove-AzureRmDnsRecordSet, Set-AzureRmDnsRecordSet...}
Script 3.4.1 AzureRM.KeyVault {Add-AzureKeyVaultCertificate, Set-AzureKeyVaultCertificateAttribute, Stop-AzureKeyVaultCertificateOperation, Get-AzureKeyVaultC...
Script 5.0.1 AzureRM.Network {Add-AzureRmApplicationGatewayAuthenticationCertificate, Get-AzureRmApplicationGatewayAuthenticationCertificate, New-AzureRmAppl...
Script 1.0.5.4 AzureRM.Network {Add-AzureRmApplicationGatewayAuthenticationCertificate, Get-AzureRmApplicationGatewayAuthenticationCertificate, New-AzureRmAppl...
Script 3.4.1 AzureRM.profile {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-AzureRmDataCollection, Enable-AzureRmContextAutosave...}
Script 4.4.1 AzureRM.Resources {Get-AzureRmProviderOperation, Remove-AzureRmRoleAssignment, Get-AzureRmRoleAssignment, New-AzureRmRoleAssignment...}
Script 1.1.0.1 AzureRM.Storage {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, New-AzureRmStorageAccount, New-AzureRmStorageAccountKey...}
Script 1.0.5.4 AzureRM.Storage {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, New-AzureRmStorageAccount, New-AzureRmStorageAccountKey...}
Script 4.0.2 AzureRM.Tags {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}
Script 3.4.1 AzureRM.Tags {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}
Script 4.0.3 AzureRM.UsageAggregates Get-UsageAggregates
Script 3.4.1 AzureRM.UsageAggregates Get-UsageAggregates
Script 1.5.0 AzureStack
Manifest 1.0 CloudCommon {Test-PSSessionConnection, Get-NugetStorePath, New-Credential, Mount-WindowsImageWithRetry...}
Script 1.0 DSC.ACS.ACSServices
Script 1.0 DSC.ACS.Blob
Script 1.0 DSC.ACS.Common {Add-ServiceAccountPrivilege, Get-ServiceAccountPrivilege}
Script 1.0 DSC.ACS.Settings {Test-SecureStringEqual, Get-IndicatorFilePath, New-SettingsManager}
Script 1.0 DSC.CertHelpers GetSubjectName
Script 1.0 DSC.ExternalDNS {Start-DnsLogging, Stop-DnsLogging, Append-Dot, Retry-ScriptBlock}
Script 1.0 DSC.MonitoringAgent
Script 1.0 DSC.NetworkController
Script 1.0 DSC.ProcessorPowerManagement
Script 1.0 DSC.ServiceWithFailureAction
Script 1.0 DSC.Storage
Script 1.0 DSC.TraceCollector
Script 0.0 HostAgentRestart Restart-HostAgents
Script 0.0 HostUpdate {Copy-CustomizedVHDToHost, Remove-OldHostVHD, Stop-LocalVMs}
Script 0.0 HyperVLogging SetHyperVLogging
Script 1.0 JustEnoughAdministration
Binary 2.3 Microsoft.AzureStack.Diagnostics {Get-ASAggregate, Get-ASHotPath, Get-ASTimeLapse, Get-ASChildEvent...}
Script 1.0 Microsoft.AzureStack.Diagnostics... {Get-AzureStackLog, Invoke-AzureStackOnDemandLog, Get-AzureStackLogs}
Script 1.0 Microsoft.AzureStack.Diagnostics... {Get-ServiceFabricStandaloneLog, Get-AzureStackAlert}
Script 1.1 Microsoft.AzureStack.Diagnostics... Test-AzureStack
Script 0.0 Microsoft.AzureStack.Fabric.Comp... {Remove-CpiVmReservation, ShutDown-CpiClusterNode, Check-CpiVmInRightHost, Get-CpiClusterAvailabilitySet...}
Script 0.0 Microsoft.AzureStack.Fabric.Comp... {Get-CpiVmHardwareProfile, Disconnect-CpiVmNic, Set-CpiVmTempDisk, Set-CpiVmNotes...}
Manifest 1.0.0.0 Microsoft.AzureStack.Fabric.Stor... {Remove-SCFileShare, Get-SCPhysicalDisk, Get-SCFileShare, New-SCVolume...}
Script 0.0 Microsoft.AzureStack.GPWmiFilter {New-GPWmiFilter, Get-GPWmiFilter, Remove-GPWmiFilter, Set-GPWmiFilter...}
Binary 1.1809.0.0 Microsoft.AzureStack.OOBManagement {Set-IpmiDeviceOneTimePxeBoot, Restart-IpmiDevice, Get-IpmiDevicePowerState, Get-IpmiDeviceSystemEventLogs...}
Manifest 1.0 Microsoft.AzureStack.PrivilegedE... {Get-SupportSessionToken, Unlock-SupportSession, Get-RecoverySessionToken, Unlock-RecoverySession...}
Script 1.0.1 Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValidation}
Script 1.0 NET.Tracing
Script 0.0 NetworkControllerRESTWrappers {New-NCGreTunnel, New-NCVirtualSubnet, New-NCL3Tunnel, Remove-NCServer...}
Manifest 6.1.0.0 NetworkingDsc
Script 0.0 NewManagementVM {New-ManagementVM, Set-ManagementVmLocalFolderAcl, Remove-ManagementVM, Get-ManagementVM...}
Script 1.0.1.141 newtonsoft.json {ConvertFrom-JsonNewtonsoft, ConvertTo-JsonNewtonsoft}
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Manifest 1.0.0.0 PDT.DSC.HyperV
Manifest 1.0.0.0 PDT.DSC.Networking {Convert-CIDRToSubhetMask, Test-IsNanoServer, New-InvalidOperationException, Get-LocalizedData...}
Manifest 1.0.0.0 PDT.DSC.Service
Script 1.0.0.0 PDT.DSC.Utilities Get-LogMan
Script 1.0 PDT_MigrationProtocol
Script 3.4.0 Pester {Describe, Context, It, Should...}
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
Script 1.1.0 PrivateCloud.DiagnosticInfo {Get-SddcDiagnosticInfo, Show-SddcDiagnosticReport, gsddcdi, Get-PCStorageDiagnosticInfo...}
Script 1.2 PSReadline {Get-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Remove-PSReadlineKeyHandler, Get-PSReadlineOption...}
Script 0.0 Shutdown Stop-LocalPhysicalComputer
Script 0.0 StorageSubsystem Get-VolumesFromStorageSubsystem
Manifest 2.0.0.0 xSmbShare
Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.0.0 ActiveDirectory {Add-ADCentralAccessPolicyMember, Add-ADComputerServiceAccount, Add-ADDomainControllerPasswordReplicationPolicy, Add-ADFineGrain...
Manifest 1.0.0.0 ADDSDeployment {Add-ADDSReadOnlyDomainControllerAccount, Install-ADDSForest, Install-ADDSDomain, Install-ADDSDomainController...}
Manifest 1.0.0.0 AppBackgroundTask {Disable-AppBackgroundTaskDiagnosticLog, Enable-AppBackgroundTaskDiagnosticLog, Set-AppBackgroundTaskResourcePolicy, Unregister-...
Manifest 2.0.0.0 AppLocker {Get-AppLockerFileInformation, Get-AppLockerPolicy, New-AppLockerPolicy, Set-AppLockerPolicy...}
Manifest 1.0.0.0 AppvClient {Add-AppvClientConnectionGroup, Add-AppvClientPackage, Add-AppvPublishingServer, Disable-Appv...}
Manifest 2.0.0.0 Appx {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest, Remove-AppxPackage...}
Script 1.0.0.0 AssignedAccess {Clear-AssignedAccess, Get-AssignedAccess, Set-AssignedAccess}
Manifest 1.0 BestPractices {Get-BpaModel, Get-BpaResult, Invoke-BpaModel, Set-BpaResult}
Manifest 2.0.0.0 BitsTransfer {Add-BitsFile, Complete-BitsTransfer, Get-BitsTransfer, Remove-BitsTransfer...}
Manifest 1.0.0.0 BranchCache {Add-BCDataCacheExtension, Clear-BCCache, Disable-BC, Disable-BCDowngrading...}
Manifest 1.0.0.0 CimCmdlets {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSession...}
Binary 2.0.0.0 ClusterAwareUpdating {Get-CauPlugin, Register-CauPlugin, Unregister-CauPlugin, Invoke-CauScan...}
Manifest 1.0 ConfigCI {Get-SystemDriver, New-CIPolicyRule, New-CIPolicy, Get-CIPolicy...}
Manifest 2.0.0.0 DcbQos {Get-NetQosFlowControl, Set-NetQosFlowControl, Enable-NetQosFlowControl, Disable-NetQosFlowControl...}
Manifest 1.0 Defender {Get-MpPreference, Set-MpPreference, Add-MpPreference, Remove-MpPreference...}
Manifest 1.0 DFSN {Get-DfsnRoot, Remove-DfsnRoot, Set-DfsnRoot, New-DfsnRoot...}
Binary 2.0.0.0 DFSR {New-DfsReplicationGroup, Get-DfsReplicationGroup, Set-DfsReplicationGroup, Remove-DfsReplicationGroup...}
Manifest 1.0.0.0 DirectAccessClientComponents {Disable-DAManualEntryPointSelection, Enable-DAManualEntryPointSelection, Get-DAClientExperienceConfiguration, Get-DAEntryPointT...
Script 3.0 Dism {Add-AppxProvisionedPackage, Add-WindowsDriver, Add-WindowsCapability, Add-WindowsImage...}
Manifest 1.0.0.0 DnsClient {Resolve-DnsName, Clear-DnsClientCache, Get-DnsClient, Get-DnsClientCache...}
Manifest 2.0.0.0 DnsServer {Add-DnsServerConditionalForwarderZone, Add-DnsServerDirectoryPartition, Add-DnsServerForwarder, Add-DnsServerPrimaryZone...}
Manifest 1.0.0.0 EventTracingManagement {New-EtwTraceSession, Get-EtwTraceSession, Set-EtwTraceSession, Send-EtwTraceSession...}
Manifest 2.0.0.0 FailoverClusters {Add-ClusterCheckpoint, Add-ClusterDisk, Add-ClusterFileServerRole, Add-ClusterGenericApplicationRole...}
Manifest 1.0.0.0 GroupPolicy {Backup-GPO, Block-GPInheritance, Copy-GPO, Get-GPInheritance...}
Manifest 1.0.0.0 HgsClient {Get-HgsAttestationBaselinePolicy, Get-HgsClientConfiguration, Set-HgsClientConfiguration, New-HgsGuardian...}
Manifest 1.0.0.0 HgsDiagnostics {New-HgsTraceTarget, Get-HgsTrace, Get-HgsTraceFileData, Test-HgsTraceTarget}
Manifest 1.0.0.0 HNVDiagnostics {Get-CustomerRoute, Get-PACAMapping, Get-ProviderAddress, Test-VirtualNetworkConnection...}
Binary 2.0.0.0 Hyper-V {Add-VMAssignableDevice, Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMGpuPartitionAdapter...}
Binary 1.1 Hyper-V {Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMHardDiskDrive, Add-VMMigrationNetwork...}
Script 1.0.0.0 IISAdministration {Get-IISAppPool, Start-IISCommitDelay, Stop-IISCommitDelay, Get-IISSite...}
Manifest 2.0.0.0 International {Get-WinDefaultInputMethodOverride, Set-WinDefaultInputMethodOverride, Get-WinHomeLocation, Set-WinHomeLocation...}
Manifest 1.0.0.0 iSCSI {Get-IscsiTargetPortal, New-IscsiTargetPortal, Remove-IscsiTargetPortal, Update-IscsiTargetPortal...}
Manifest 2.0.0.0 IscsiTarget {Add-ClusteriSCSITargetServerRole, Add-IscsiVirtualDiskTargetMapping, Checkpoint-IscsiVirtualDisk, Convert-IscsiVirtualDisk...}
Script 1.0.0.0 ISE {New-IseSnippet, Import-IseSnippet, Get-IseSnippet}
Manifest 1.0.0.0 Kds {Add-KdsRootKey, Get-KdsRootKey, Test-KdsRootKey, Set-KdsConfiguration...}
Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\JEAModules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.0.0 Microsoft.AzureStack.Fabric.Stor... {Remove-SCFileShare, Get-SCPhysicalDisk, Get-SCFileShare, New-SCVolume...}
Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.1.0 Microsoft.PowerShell.Archive {Compress-Archive, Expand-Archive}
Manifest 3.0.0.0 Microsoft.PowerShell.Diagnostics {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter...}
Manifest 3.0.0.0 Microsoft.PowerShell.Host {Start-Transcript, Stop-Transcript}
Manifest 1.0.0.0 Microsoft.PowerShell.LocalAccounts {Add-LocalGroupMember, Disable-LocalUser, Enable-LocalUser, Get-LocalGroup...}
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}
Script 1.0 Microsoft.PowerShell.ODataUtils Export-ODataEndpointProxy
Manifest 3.0.0.0 Microsoft.PowerShell.Security {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...}
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Format-List, Format-Custom, Format-Table, Format-Wide...}
Manifest 3.0.0.0 Microsoft.WSMan.Management {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSManQuickConfig...}
Manifest 1.0 MMAgent {Disable-MMAgent, Enable-MMAgent, Set-MMAgent, Get-MMAgent...}
Manifest 1.0.0.0 MsDtc {New-DtcDiagnosticTransaction, Complete-DtcDiagnosticTransaction, Join-DtcDiagnosticResourceManager, Receive-DtcDiagnosticTransa...
Manifest 2.0.0.0 NetAdapter {Disable-NetAdapter, Disable-NetAdapterBinding, Disable-NetAdapterChecksumOffload, Disable-NetAdapterEncapsulatedPacketTaskOfflo...
Manifest 1.0.0.0 NetConnection {Get-NetConnectionProfile, Set-NetConnectionProfile}
Manifest 1.0.0.0 NetEventPacketCapture {New-NetEventSession, Remove-NetEventSession, Get-NetEventSession, Set-NetEventSession...}
Manifest 2.0.0.0 NetLbfo {Add-NetLbfoTeamMember, Add-NetLbfoTeamNic, Get-NetLbfoTeam, Get-NetLbfoTeamMember...}
Manifest 1.0.0.0 NetNat {Get-NetNat, Get-NetNatExternalAddress, Get-NetNatStaticMapping, Get-NetNatSession...}
Manifest 2.0.0.0 NetQos {Get-NetQosPolicy, Set-NetQosPolicy, Remove-NetQosPolicy, New-NetQosPolicy}
Manifest 2.0.0.0 NetSecurity {Get-DAPolicyChange, New-NetIPsecAuthProposal, New-NetIPsecMainModeCryptoProposal, New-NetIPsecQuickModeCryptoProposal...}
Manifest 1.0.0.0 NetSwitchTeam {New-NetSwitchTeam, Remove-NetSwitchTeam, Get-NetSwitchTeam, Rename-NetSwitchTeam...}
Manifest 1.0.0.0 NetTCPIP {Get-NetIPAddress, Get-NetIPInterface, Get-NetIPv4Protocol, Get-NetIPv6Protocol...}
Manifest 1.0.0.0 NetWNV {Get-NetVirtualizationProviderAddress, Get-NetVirtualizationGlobal, Get-NetVirtualizationLookupRecord, Get-NetVirtualizationCust...
Manifest 1.0.0.0 NetworkConnectivityStatus {Get-DAConnectionStatus, Get-NCSIPolicyConfiguration, Reset-NCSIPolicyConfiguration, Set-NCSIPolicyConfiguration}
Manifest 1.0.0.0 NetworkSwitchManager {Disable-NetworkSwitchEthernetPort, Enable-NetworkSwitchEthernetPort, Get-NetworkSwitchEthernetPort, Remove-NetworkSwitchEtherne...
Manifest 1.0.0.0 NetworkTransition {Add-NetIPHttpsCertBinding, Disable-NetDnsTransitionConfiguration, Disable-NetIPHttpsProfile, Disable-NetNatTransitionConfigurat...
Manifest 1.0 NFS {Get-NfsMappedIdentity, Get-NfsNetgroup, Install-NfsMappingStore, New-NfsMappedIdentity...}
Manifest 1.0.0.0 Nps {Export-NpsConfiguration, Get-NpsRadiusClient, Get-NpsSharedSecretTemplate, Import-NpsConfiguration...}
Manifest 1.0.0.0 PcsvDevice {Get-PcsvDevice, Start-PcsvDevice, Stop-PcsvDevice, Restart-PcsvDevice...}
Manifest 1.0.0.0 PKI {Add-CertificateEnrollmentPolicyServer, Export-Certificate, Export-PfxCertificate, Get-CertificateAutoEnrollmentPolicy...}
Manifest 1.0.0.0 PlatformIdentifier Get-PlatformIdentifier
Manifest 1.0.0.0 PnpDevice {Get-PnpDevice, Get-PnpDeviceProperty, Enable-PnpDevice, Disable-PnpDevice}
Manifest 1.1 PrintManagement {Add-Printer, Add-PrinterDriver, Add-PrinterPort, Get-PrintConfiguration...}
Manifest 1.1 PSDesiredStateConfiguration {Set-DscLocalConfigurationManager, Start-DscConfiguration, Test-DscConfiguration, Publish-DscConfiguration...}
Script 1.0.0.0 PSDiagnostics {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, Enable-PSTrace...}
Binary 1.1.0.0 PSScheduledJob {New-JobTrigger, Add-JobTrigger, Remove-JobTrigger, Get-JobTrigger...}
Manifest 2.0.0.0 PSWorkflow {New-PSWorkflowExecutionOption, New-PSWorkflowSession, nwsn}
Manifest 1.0.0.0 PSWorkflowUtility Invoke-AsWorkflow
Manifest 3.0.0.0 RemoteAccess {Add-DAAppServer, Add-DAClient, Add-DAClientDnsConfiguration, Add-DAEntryPoint...}
Manifest 2.0.0.0 RemoteDesktop {Get-RDCertificate, Set-RDCertificate, New-RDCertificate, New-RDVirtualDesktopDeployment...}
Manifest 1.0.0.0 ScheduledTasks {Get-ScheduledTask, Set-ScheduledTask, Register-ScheduledTask, Unregister-ScheduledTask...}
Manifest 2.0.0.0 SecureBoot {Confirm-SecureBootUEFI, Set-SecureBootUEFI, Get-SecureBootUEFI, Format-SecureBootUEFI...}
Manifest 1.0.0.0 SecurityCmdlets {Backup-SecurityPolicy, Restore-SecurityPolicy, Backup-AuditPolicy, Restore-AuditPolicy}
Script 1.0.0.0 ServerCore {Get-DisplayResolution, Set-DisplayResolution}
Script 2.0.0.0 ServerManager {Get-WindowsFeature, Install-WindowsFeature, Uninstall-WindowsFeature, Enable-ServerManagerStandardUserRemoting...}
Cim 1.0.0.0 ServerManagerTasks {Get-SMCounterSample, Get-SMPerformanceCollector, Start-SMPerformanceCollector, Stop-SMPerformanceCollector...}
Manifest 2.0.0.0 SmbShare {Get-SmbShare, Remove-SmbShare, Set-SmbShare, Block-SmbShareAccess...}
Manifest 2.0.0.0 SmbWitness {Get-SmbWitnessClient, Move-SmbWitnessClient, gsmbw, msmbw...}
Manifest 2.0.0.0 SoftwareInventoryLogging {Get-SilComputer, Get-SilComputerIdentity, Get-SilSoftware, Get-SilWindowsUpdate...}
Manifest 1.0.0.0 StartLayout {Export-StartLayout, Import-StartLayout, Get-StartApps}
Manifest 2.0.0.0 Storage {Add-InitiatorIdToMaskingSet, Add-PartitionAccessPath, Add-PhysicalDisk, Add-TargetPortToMaskingSet...}
Manifest 1.0.0.0 StorageQoS {Get-StorageQoSPolicy, Get-StorageQoSPolicyStore, Set-StorageQoSPolicyStore, Remove-StorageQoSPolicy...}
Manifest 2.0.0.0 TLS {New-TlsSessionTicketKey, Enable-TlsSessionTicketKey, Disable-TlsSessionTicketKey, Export-TlsSessionTicketKey...}
Manifest 1.0.0.0 TroubleshootingPack {Get-TroubleshootingPack, Invoke-TroubleshootingPack}
Manifest 2.0.0.0 TrustedPlatformModule {Get-Tpm, Initialize-Tpm, Clear-Tpm, Unblock-Tpm...}
Binary 2.1.639.0 UEV {Clear-UevConfiguration, Clear-UevAppxPackage, Restore-UevBackup, Set-UevTemplateProfile...}
Manifest 2.0.0.0 UpdateServices {Add-WsusComputer, Approve-WsusUpdate, Deny-WsusUpdate, Get-WsusClassification...}
Manifest 1.0.0.0 UserAccessLogging {Enable-Ual, Disable-Ual, Get-Ual, Get-UalDns...}
Manifest 2.0.0.0 VpnClient {Add-VpnConnection, Set-VpnConnection, Remove-VpnConnection, Get-VpnConnection...}
Manifest 1.0.0.0 Wdac {Get-OdbcDriver, Set-OdbcDriver, Get-OdbcDsn, Add-OdbcDsn...}
Manifest 1.0.0.0 WebAdministration {Start-WebCommitDelay, Stop-WebCommitDelay, Get-WebConfigurationLock, Remove-WebConfigurationLock...}
Manifest 2.0.0.0 Whea {Get-WheaMemoryPolicy, Set-WheaMemoryPolicy}
Manifest 1.0.0.0 WindowsDeveloperLicense {Get-WindowsDeveloperLicense, Unregister-WindowsDeveloperLicense, Show-WindowsDeveloperLicenseRegistration}
Script 1.0 WindowsErrorReporting {Enable-WindowsErrorReporting, Disable-WindowsErrorReporting, Get-WindowsErrorReporting}
Manifest 1.0.0.0 WindowsSearch {Get-WindowsSearchSetting, Set-WindowsSearchSetting}
Manifest 1.0.0.0 WindowsUpdate Get-WindowsUpdateLog
Environment Data
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.2430
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.2430
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Debug Output
Save
PS> Save-AzureRmContext -Path $path
DEBUG: 9:41:57 AM - SaveAzureRMContextCommand begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 9:41:57 AM - using account id '<ValidAccount>'...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:42:01: - TokenCache: Serializing token cache with 24 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:42:01: - TokenCache: Serializing token cache with 24 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:42:01: - TokenCache: Serializing token cache with 24 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:42:01: - TokenCache: Serializing token cache with 24 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:42:01: - TokenCache: Serializing token cache with 24 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:42:01: - TokenCache: Serializing token cache with 24 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:42:01: - TokenCache: Serializing token cache with 24 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:42:01: - TokenCache: Serializing token cache with 24 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:42:01: - TokenCache: Serializing token cache with 24 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:42:01: - TokenCache: Serializing token cache with 24 items.
DEBUG: 9:42:01 AM - SaveAzureRMContextCommand end processing.
DEBUG: 9:42:01 AM - SaveAzureRMContextCommand end processing.
Load
PS> Import-AzureRmContext -Path $path
DEBUG: 9:37:03 AM - Autosave setting from startup session: 'CurrentUser'
DEBUG: 9:37:03 AM - No autosave setting detected in environment variable 'AzureRmContextAutoSave'.
DEBUG: 9:37:03 AM - Using Autosave scope 'CurrentUser'
Account : <ValidAccount>
SubscriptionName : Default Provider Subscription
SubscriptionId : <Guid>
TenantId : <Guid>
Environment : <EnvironmentName>
DEBUG: 9:37:04 AM - ImportAzureRMContextCommand end processing.
DEBUG: 9:37:04 AM - ImportAzureRMContextCommand end processing.
PS> Get-AzureRMVM
DEBUG: 9:38:19 AM - GetAzureVMCommand begin processing with ParameterSet 'ListAllVirtualMachinesParamSet'.
DEBUG: 9:38:19 AM - using account id '<ValidAccount>'...
DEBUG: [Common.Authentication]: Authenticating using Account: '<ValidAccount>',
environment: '<EnvironmentName>', tenant: '<Guid>'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:38:19: - AuthenticationContext: ADAL .NET with assembly version '2.28.3.860', file version
'2.28.31117.1411' and informational version '<Guid>' is running...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:38:20: <Guid> - AcquireTokenHandlerBase: === Token Acquisition
started:
Authority: https://login.microsoftonline.com/<Guid>/
Resource: <MicrosoftInternal>
ClientId: <Guid>
CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (0 items)
Authentication Target: User
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:38:20: - TokenCache: Deserialized 0 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 09/11/2018 16:38:20: <Guid> - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/11/2018 16:38:20: <Guid> - TokenCache: No matching token was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 09/11/2018 16:38:20: <Guid> - AcquireTokenSilentHandler: No token matching
arguments found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Error: 4 :
DEBUG: 09/11/2018 16:38:20: <Guid> - <RunAsync>d__0:
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalSilentTokenAcquisitionException: Failed to acquire token silently.
Call method AcquireToken
at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenSilentHandler.SendTokenRequestAsync()
at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.<RunAsync>d__0.MoveNext()
ErrorCode: failed_to_acquire_token_silently
DEBUG: [Common.Authentication]: Received exception Authentication error while acquiring token: 'Failed to acquire token
silently. Call method AcquireToken'., while authenticating.
Get-AzureRMVm : Your Azure credentials have not been set up or have expired, please run Connect-AzureRmAccount to set
up your Azure credentials.
At line:1 char:1
+ Get-AzureRMVm
+ ~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureRmVM], ArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.GetAzureVMCommand
DEBUG: 9:38:20 AM - GetAzureVMCommand end processing.
DEBUG: 9:38:20 AM - GetAzureVMCommand end processing.
@cormacpayne , @markcowl , any update on this bug yet? Wanted to get a sense of what the issue is, and if you guys had an ETA for the fix. We have a couple of our customers try to use this functionality.
@knithinc @deathly809 Yes, the issue is that, if there is an existing context, the token cache from the imported context does not overwrite it - this is because we cannot combine two token caches.
If the TokenCache is completely new, then the problem does not occur, however, we are not checking for an existing but empty token cache. The right fix is to replace the token cache in all cases, but we have deprioritized this because using Context AutoSave should make this unnecessary.
@markcowl We also have reports saying passing the Context to a Job is also broken.. root cause is likely the same?
Agree that enabling context auto save will make this pattern unnecessary and we have suggested the same.
$context = Get-AzureRMContext;
$vms = get-azurermvm | where {$_.Tags.pool -eq $vmPool} | where ResourceGroupName -eq $rg | sort Name
$script = {
Param( $rg, $vm, $context )
$vmname = $vm.Name
$vm.NetworkProfile.NetworkInterfaces[0].id -match "Interfaces/(.*)"
$nicname = $matches[1]
$osdiskname = $vm.StorageProfile.OSDisk.Name
$datadisknames = $vm.StorageProfile.DataDisks.Name
Remove-AzureRmVm -Name $vmName -ResourceGroupName $rg -AzureRmContext $context -force -verbose
Remove-AzureRmNetworkInterface -Name $nicname -ResourceGroupName $rg -AzureRmContext $context -force -verbose
Remove-AzureRmDisk -Name $osdiskname -ResourceGroupName $rg -AzureRmContext $context -force -verbose
$datadisknames | %{ Remove-AzureRmDisk -Name $_ -ResourceGroupName $rg -AzureRmContext $context -force -verbose }
}
$jobs = @()
$vms | %{
$job = Start-Job -Name $_.Name $script -ArgumentList $rg, $_, $context
Write-Output "($_.Name) being removed in background job $($job.Name) ID $($job.Id)"
$jobs += @($job)
}
No this is separate, and my guess is that you have one or more parameter passing issues in this case.
Closing this as a duplicate of #7456
The issue is fixed in Az module, Keeping this open for AzureRm.Profile module fix as this exists in AzureRm
PR is here, https://github.com/Azure/azure-powershell/pull/8234
The fix is part of AzureRM.Profile 5.8.3