From 1eb43eba2a02ea0227925874b1e9275aa2c6c7d9 Mon Sep 17 00:00:00 2001 From: nickcandy Date: Wed, 25 May 2022 11:21:41 +0800 Subject: [PATCH 1/2] add createtime and changetime for get-azresource --- .../ResourceManager/SdkModels/Resources/PSResource.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resources/ResourceManager/SdkModels/Resources/PSResource.cs b/src/Resources/ResourceManager/SdkModels/Resources/PSResource.cs index dea27a95ff7f..5486933a0aa1 100644 --- a/src/Resources/ResourceManager/SdkModels/Resources/PSResource.cs +++ b/src/Resources/ResourceManager/SdkModels/Resources/PSResource.cs @@ -149,8 +149,8 @@ public PSResource(Resource resource): this( TagsHelper.GetTagsDictionary(TagsHelper.GetTagsHashtable(resource.Tags)) ) { - this.CreatedTime = resource.CreatedTime; - this.ChangedTime = resource.ChangedTime; + this.CreatedTime = Convert.ToDateTime(resource.Properties["lastModifiedTime"]?.ToString()); + this.ChangedTime = Convert.ToDateTime(resource.Properties["lastModifiedTime"]?.ToString()); this.SubscriptionId = string.IsNullOrEmpty(resource.Id) ? null : ResourceIdUtility.GetSubscriptionId(resource.Id); this.ResourceGroupName = string.IsNullOrEmpty(resource.Id) ? null : ResourceIdUtility.GetResourceGroupName(resource.Id); From 1b2e1d432d98f4379be80f09edab5d40e792212b Mon Sep 17 00:00:00 2001 From: nickcandy Date: Wed, 25 May 2022 18:46:51 +0800 Subject: [PATCH 2/2] add changelog for change --- .../ResourceManager/SdkModels/Resources/PSResource.cs | 5 ++--- src/Resources/Resources/ChangeLog.md | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Resources/ResourceManager/SdkModels/Resources/PSResource.cs b/src/Resources/ResourceManager/SdkModels/Resources/PSResource.cs index 5486933a0aa1..99b963ed653c 100644 --- a/src/Resources/ResourceManager/SdkModels/Resources/PSResource.cs +++ b/src/Resources/ResourceManager/SdkModels/Resources/PSResource.cs @@ -149,9 +149,8 @@ public PSResource(Resource resource): this( TagsHelper.GetTagsDictionary(TagsHelper.GetTagsHashtable(resource.Tags)) ) { - this.CreatedTime = Convert.ToDateTime(resource.Properties["lastModifiedTime"]?.ToString()); - this.ChangedTime = Convert.ToDateTime(resource.Properties["lastModifiedTime"]?.ToString()); - + if ( resource.Properties["creationTime"] == null) { this.CreatedTime = null;} else {this.CreatedTime = Convert.ToDateTime(resource.Properties["creationTime"]);} + if ( resource.Properties["lastModifiedTime"] == null) { this.ChangedTime = null;} else {this.ChangedTime = Convert.ToDateTime(resource.Properties["lastModifiedTime"]);} this.SubscriptionId = string.IsNullOrEmpty(resource.Id) ? null : ResourceIdUtility.GetSubscriptionId(resource.Id); this.ResourceGroupName = string.IsNullOrEmpty(resource.Id) ? null : ResourceIdUtility.GetResourceGroupName(resource.Id); this.ExtensionResourceName = string.IsNullOrEmpty(resource.Id) ? null : ResourceIdUtility.GetExtensionResourceName(resource.Id); diff --git a/src/Resources/Resources/ChangeLog.md b/src/Resources/Resources/ChangeLog.md index 09f6195bd895..f2d5452c05a1 100644 --- a/src/Resources/Resources/ChangeLog.md +++ b/src/Resources/Resources/ChangeLog.md @@ -19,6 +19,7 @@ --> ## Upcoming Release +* Fixed logic of `createtime` and `ChangedTime` in `Get-AzResource --ExpandProperties`. [#18206] ## Version 6.0.0 * Added cmdlet for Application federated identity credential