Inconsistent module version for global modules when retrieving modules using Get-AzureRmAutomationModule cmdlet with different parameters
Description
I'm observing the following behavior when trying to retrieve Automation modules from automation account using Get-AzureRmAutomationModule cmdlet.
When using the cmdlet with only 2 parameters (ResourceGroupName and AutomationAccountName), the modules list shows Version as null for the "global" modules. However, when running the same cmdlet by passing 3 parameters (ResourceGroupName, AutomationAccountName, and Module name), we get the version for the global modules.
Is this as designed and if so, why is it in this way? Currently, the portal also shows version as null for the global modules when in fact they have a version already. Some sample modules where this behavior is seen are listed below.
AuditPolicyDsc PSDscResources SecurityPolicyDsc StateConfigCompositeResources xDSCDomainjoin xPowerShellExecutionPolicy xRemoteDesktopAdmin
Script/Steps for Reproduction
$GlobalModulesInAutomationAccount = Get-AzureRmAutomationModule -ResourceGroupName "RG" -AutomationAccountName "AA" | Where-Object { $_.IsGlobal -eq $true }
$SingleGlobalAutomationModule = Get-AzureRmAutomationModule -Name $GlobalModulesInAutomationAccount[0].Name -ResourceGroupName "RG" -AutomationAccountName "AA"
Compare Version values of the above result
Module Version
PS C:\WINDOWS\system32> Get-Module -Name AzureRM -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 6.5.0 AzureRM
Script 6.4.0 AzureRM
Script 6.3.0 AzureRM
Environment Data
Name Value
---- -----
PSVersion 5.1.16299.547
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.547
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Debug Output
PS C:\WINDOWS\system32> Get-AzureRmAutomationModule -ResourceGroupName $AARG -AutomationAccountName $AA -Debug | Where-Object {$_.IsGlobal -eq $true}
DEBUG: 5:01:56 PM - GetAzureAutomationModule begin processing with ParameterSet 'ByAll'.
DEBUG: 5:01:57 PM - using account id '[email protected]'...
DEBUG: [Common.Authentication]: Authenticating using Account: '[email protected]', environment: 'AzureCloud', tenant
: '72f988bf-86f1-41af-91ab-2d7cd011db47'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 08/03/2018 11:31:57: - TokenCache: Serializing token cache with 9 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 08/03/2018 11:31:57: - TokenCache: Serializing token cache with 9 items.
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '72f988bf-86f1-41af-91ab-2d7cd011db4
7', Endpoint: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirect: '
urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/72f988b
f-86f1-41af-91ab-2d7cd011db47/', CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: '72f988bf-86f1-41af-91ab-2d7cd011d
b47', AdEndpoint: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirec
tUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 08/03/2018 11:31:57: c2067e67-63da-42d8-b718-db1dd6a523dd - AcquireTokenHandlerBase: === Token Acquisition start
ed:
Authority: https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/
Resource: https://management.core.windows.net/
ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (9 items)
Authentication Target: User
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 08/03/2018 11:31:57: - TokenCache: Deserialized 9 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 08/03/2018 11:31:57: c2067e67-63da-42d8-b718-db1dd6a523dd - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 08/03/2018 11:31:57: c2067e67-63da-42d8-b718-db1dd6a523dd - TokenCache: An item matching the requested resource
was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 08/03/2018 11:31:57: c2067e67-63da-42d8-b718-db1dd6a523dd - TokenCache: 58.86777602 minutes left until token in
cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 08/03/2018 11:31:57: c2067e67-63da-42d8-b718-db1dd6a523dd - TokenCache: A matching item (access token or refresh
token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 08/03/2018 11:31:57: c2067e67-63da-42d8-b718-db1dd6a523dd - AcquireTokenHandlerBase: === Token Acquisition finis
hed successfully. An access token was retuned:
Access Token Hash: vAyr//QcGOH3XJyPZ2lSK6OhYY1fDroUbxlEDzUfaLI=
Refresh Token Hash: ZFUY3+9V3gIxTAx3hjULckVDV34VOGZ91QcZZTv7YBE=
Expiration Time: 08/03/2018 12:30:49 +00:00
User Hash: VakXoPVRfumK4QmVnOoUckhAhmAG+25lrlD/prX14fs=
DEBUG: [Common.Authentication]: Received token with LoginType 'LiveId', Tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47',
UserId: '[email protected]'
DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '08/03/2018 12:30:49 +00:00', MultipleResou
rce? 'True', Tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47', UserId: '[email protected]'
DEBUG: [Common.Authentication]: User info for token DisplayId: '[email protected]', Name: Amogh Natu, IdProvider: 'h
ttps://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/', Uid: '9a506222-ce3c-4889-9720-f41fb9d3595a'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '08/03/2018 12:30:49 +00:00' Comparing to '08/
03/2018 11:31:57 +00:00' With threshold '00:05:00', calculated time until token expiry: '00:58:52.0655606'
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/4b0a58af-58ad-4588-aed6-314d1fad38f0/resourceGroups/automation-ps-rg/provide
rs/Microsoft.Automation/automationAccounts/TestAA0002/modules?api-version=2015-10-31
Headers:
Accept : application/json
ocp-referer : https://management.azure.com/subscriptions/4b0a58af-58ad-4588-aed6-314d1fad38f0/resourc
eGroups/automation-ps-rg/providers/Microsoft.Automation/automationAccounts/TestAA0002/modules?api-version=2015-10-31
x-ms-version : 2014-06-01
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Pragma : no-cache
x-ms-request-id : 84b6dd66-d39d-4552-ad5a-beb6b063b042
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 14998
x-ms-correlation-request-id : 4c52edf7-2178-4eda-b2d2-4f42efe9aa7f
x-ms-routing-request-id : SOUTHINDIA:20180803T113158Z:4c52edf7-2178-4eda-b2d2-4f42efe9aa7f
X-Content-Type-Options : nosniff
Cache-Control : no-cache
Date : Fri, 03 Aug 2018 11:31:57 GMT
Server : Microsoft-IIS/8.5
X-AspNet-Version : 4.0.30319
X-Powered-By : ASP.NET
Body:
{
"value": [
{
"id": "/subscriptions/4b0a58af-58ad-4588-aed6-314d1fad38f0/resourceGroups/automation-ps-rg/providers/Microsoft.Au
tomation/automationAccounts/TestAA0002/modules/PSDscResources",
"name": "PSDscResources",
"properties": {
"isGlobal": true,
"version": null,
"sizeInBytes": 0,
"activityCount": 0,
"creationTime": "2018-08-02T02:39:56.243+05:30",
"lastModifiedTime": "2018-08-02T02:39:56.84+05:30",
"provisioningState": "Created",
"isComposite": true
}
},
{
"id": "/subscriptions/4b0a58af-58ad-4588-aed6-314d1fad38f0/resourceGroups/automation-ps-rg/providers/Microsoft.Au
tomation/automationAccounts/TestAA0002/modules/SecurityPolicyDsc",
"name": "SecurityPolicyDsc",
"properties": {
"isGlobal": true,
"version": null,
"sizeInBytes": 0,
"activityCount": 0,
"creationTime": "2018-08-02T02:39:24.757+05:30",
"lastModifiedTime": "2018-08-02T02:39:25.32+05:30",
"provisioningState": "Created",
"isComposite": false
}
},
{
"id": "/subscriptions/4b0a58af-58ad-4588-aed6-314d1fad38f0/resourceGroups/automation-ps-rg/providers/Microsoft.Au
tomation/automationAccounts/TestAA0002/modules/StateConfigCompositeResources",
"name": "StateConfigCompositeResources",
"properties": {
"isGlobal": true,
"version": null,
"sizeInBytes": 0,
"activityCount": 0,
"creationTime": "2018-08-02T02:40:27.73+05:30",
"lastModifiedTime": "2018-08-02T02:40:28.307+05:30",
"provisioningState": "Created",
"isComposite": true
}
},
{
"id": "/subscriptions/4b0a58af-58ad-4588-aed6-314d1fad38f0/resourceGroups/automation-ps-rg/providers/Microsoft.Au
tomation/automationAccounts/TestAA0002/modules/xDSCDomainjoin",
"name": "xDSCDomainjoin",
"properties": {
"isGlobal": true,
"version": null,
"sizeInBytes": 0,
"activityCount": 0,
"creationTime": "2018-08-02T02:36:35.21+05:30",
"lastModifiedTime": "2018-08-02T02:36:35.773+05:30",
"provisioningState": "Created",
"isComposite": false
}
},
{
"id": "/subscriptions/4b0a58af-58ad-4588-aed6-314d1fad38f0/resourceGroups/automation-ps-rg/providers/Microsoft.Au
tomation/automationAccounts/TestAA0002/modules/xPowerShellExecutionPolicy",
"name": "xPowerShellExecutionPolicy",
"properties": {
"isGlobal": true,
"version": null,
"sizeInBytes": 0,
"activityCount": 0,
"creationTime": "2018-08-02T02:37:06.823+05:30",
"lastModifiedTime": "2018-08-02T02:37:07.417+05:30",
"provisioningState": "Created",
"isComposite": false
}
},
{
"id": "/subscriptions/4b0a58af-58ad-4588-aed6-314d1fad38f0/resourceGroups/automation-ps-rg/providers/Microsoft.Au
tomation/automationAccounts/TestAA0002/modules/xRemoteDesktopAdmin",
"name": "xRemoteDesktopAdmin",
"properties": {
"isGlobal": true,
"version": null,
"sizeInBytes": 0,
"activityCount": 0,
"creationTime": "2018-08-02T02:37:38.323+05:30",
"lastModifiedTime": "2018-08-02T02:37:38.903+05:30",
"provisioningState": "Created",
"isComposite": false
}
}]
}
Let me know in case any more information is required.
@vrdmr This looks like ti could be a service-side issue with the return values for listing modules. Can you take a look?
Fix (bug that results in inconsistent cmdlet behavior)
With Az.Automation 1.3.7 (Az 4.6.1) the versions returned in PowerShell is consistent with the portal. Only a handful of modules do not display any version in the portal nor in PowerShell. I'm closing this issue , please open a new one if needed.