From f10692ec1663d8cd53280681abcc083036ddab88 Mon Sep 17 00:00:00 2001 From: Alex Bevan Date: Mon, 5 Nov 2018 14:49:37 +0000 Subject: [PATCH 1/2] added support for service principle --- Utility/ARM/New-OnPremiseHybridWorker.ps1 | 42 +++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/Utility/ARM/New-OnPremiseHybridWorker.ps1 b/Utility/ARM/New-OnPremiseHybridWorker.ps1 index dc8efd5..c84d987 100644 --- a/Utility/ARM/New-OnPremiseHybridWorker.ps1 +++ b/Utility/ARM/New-OnPremiseHybridWorker.ps1 @@ -1,4 +1,4 @@ -<#PSScriptInfo +<#PSScriptInfo .VERSION 1.5 @@ -110,6 +110,15 @@ See: https://github.com/Azure/azure-powershell/issues/2915 +.PARAMETER ServicePrincipal + + Optional. Switch required if using service principle to authenticate + +.PARAMETER TenantId + + Optional. TenentId to use if using service principle, otherwise is calculated. + + .EXAMPLE @@ -122,6 +131,12 @@ New-OnPremiseHybridWorker -AutomationAccountName "ContosoAA" -AAResourceGroupName "ContosoResources" -HybridGroupName "ContosoHybridGroup" -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -Credential $Credentials +.EXAMPLE + + $Credentials = Get-Credential + + New-OnPremiseHybridWorker -AutomationAccountName "ContosoAA" -AAResourceGroupName "ContosoResources" -HybridGroupName "ContosoHybridGroup" -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -Credential $Credentials -ServicePrincipal -TenantId "0fderfb0-401b-4568c-b540-bc7458d67256" + .NOTES @@ -155,16 +170,26 @@ Param ( [Parameter(Mandatory=$true)] [String] $AutomationAccountName , -# Hyprid Group +# Hybrid Group [Parameter(Mandatory=$true)] [String] $HybridGroupName, -# Hyprid Group +# Hybrid Group +[Parameter(Mandatory=$false)] +[PSCredential] $Credential, + +# Hybrid Group +[Parameter(Mandatory=$false)] +[Switch] $ServicePrincipal, + +# Hybrid Group [Parameter(Mandatory=$false)] -[PSCredential] $Credential +[String] $TenantID + ) + # Stop the script if any errors occur $ErrorActionPreference = "Stop" @@ -215,7 +240,12 @@ if ($Credential) { $paramsplat.Credential = $Credential } -$Account = Add-AzureRmAccount @paramsplat +if ($ServicePrincipal){ + $Account = Add-AzureRmAccount @paramsplat -ServicePrincipal -TenantId $TenantID +}else{ + $Account = Add-AzureRmAccount @paramsplat +} + # Get a reference to the current subscription $Subscription = Get-AzureRmSubscription -SubscriptionId $SubscriptionID @@ -368,4 +398,4 @@ if ($i -le 0) { # Register the hybrid runbook worker Write-Output "Registering the hybrid runbook worker..." -Add-HybridRunbookWorker -Name $HybridGroupName -EndPoint $AutomationEndpoint -Token $AutomationPrimaryKey \ No newline at end of file +Add-HybridRunbookWorker -Name $HybridGroupName -EndPoint $AutomationEndpoint -Token $AutomationPrimaryKey From 22e11f25595468008bc0c1a70697c659070d4748 Mon Sep 17 00:00:00 2001 From: Alex Bevan Date: Mon, 5 Nov 2018 15:03:25 +0000 Subject: [PATCH 2/2] added edit notes --- Utility/ARM/New-OnPremiseHybridWorker.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Utility/ARM/New-OnPremiseHybridWorker.ps1 b/Utility/ARM/New-OnPremiseHybridWorker.ps1 index c84d987..92464e4 100644 --- a/Utility/ARM/New-OnPremiseHybridWorker.ps1 +++ b/Utility/ARM/New-OnPremiseHybridWorker.ps1 @@ -26,6 +26,10 @@ .RELEASENOTES +1.6 - 11/5/2018 + -- MODIFIED BY Alex Bevan + -- Added support for user principle authentication + 1.5 - 5/29/2018 -- MODIFIED BY Jenny Hunter -- updated use of New-AzureRmOperationInsightsWorkspace cmdlet to user the "PerNode" SKU @@ -140,11 +144,11 @@ .NOTES - AUTHOR: Jenny Hunter, Azure Automation Team + AUTHOR: Jenny Hunter, Azure Automation Team & Alex Bevan - LASTEDIT: May 29, 2018 + LASTEDIT: Nov 5, 2018 - EDITBY: Jenny Hunter + EDITBY: Alex Bevan #>