From 32f44e112964bcf556078075f54f5d772c51f285 Mon Sep 17 00:00:00 2001 From: Justin Chen Date: Fri, 8 Mar 2024 11:31:42 -0800 Subject: [PATCH 1/2] added tag support --- DeployGPO.ps1 | 5 ++++- EnableAzureArc.ps1 | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/DeployGPO.ps1 b/DeployGPO.ps1 index a2c68a5..d5a8e49 100644 --- a/DeployGPO.ps1 +++ b/DeployGPO.ps1 @@ -63,6 +63,9 @@ Param ( [System.String]$ArcRemoteShare, [System.String]$AgentProxy, + + [Hashtable]$Tags, + [System.String]$PrivateLinkScopeId, [switch]$AssessOnly ) @@ -255,7 +258,7 @@ try { Write-Host "Install file `'AzureConnectedMachineAgent.msi`' successfully copied to $AzureArcDeployPath" -ForegroundColor Green } - $infoTable = @{"ServicePrincipalClientId"="$ServicePrincipalClientId";"SubscriptionId"="$SubscriptionId";"ResourceGroup"="$ResourceGroup";"Location"="$Location";"TenantId"="$TenantId";"PrivateLinkScopeId"="$PrivateLinkScopeId"} + $infoTable = @{"ServicePrincipalClientId"="$ServicePrincipalClientId";"SubscriptionId"="$SubscriptionId";"ResourceGroup"="$ResourceGroup";"Location"="$Location";"TenantId"="$TenantId";"PrivateLinkScopeId"="$PrivateLinkScopeId"; "Tags"=$tags} $infoTableJSON = $infoTable | ConvertTo-Json -Compress if (Test-Path "$AzureArcDeployPath\ArcInfo.json" -ErrorAction SilentlyContinue) { diff --git a/EnableAzureArc.ps1 b/EnableAzureArc.ps1 index f4eb638..fb2d2b2 100644 --- a/EnableAzureArc.ps1 +++ b/EnableAzureArc.ps1 @@ -89,6 +89,10 @@ $tags = @{ # Tags to be added to the Arc servers Responsible = "Responsible" } +if($arcInfo.Tags){ + $tags = $arcInfo.Tags +} + $workfolder = "$env:SystemDrive\temp" $logpath = "$workfolder\AzureArcOnboarding.log" #Local log file ########################################################################################################### From ced6e31bb2b77e76e57331c7e5e1bff821490ac8 Mon Sep 17 00:00:00 2001 From: Justin Chen Date: Fri, 8 Mar 2024 14:27:37 -0800 Subject: [PATCH 2/2] update tags logic --- EnableAzureArc.ps1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/EnableAzureArc.ps1 b/EnableAzureArc.ps1 index fb2d2b2..8e266eb 100644 --- a/EnableAzureArc.ps1 +++ b/EnableAzureArc.ps1 @@ -84,13 +84,11 @@ $location = $arcInfo.Location $PrivateLinkScopeId = $arcInfo.PrivateLinkScopeId $tags = @{ # Tags to be added to the Arc servers - Department = "Department" - deployedBY = "GPO" - Responsible = "Responsible" + DeployedBy = "GPO" } if($arcInfo.Tags){ - $tags = $arcInfo.Tags + $arcInfo.Tags.psobject.properties | Foreach { $tags[$_.Name] = $_.Value } } $workfolder = "$env:SystemDrive\temp"