Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for service principle #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 43 additions & 9 deletions Utility/ARM/New-OnPremiseHybridWorker.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#PSScriptInfo
<#PSScriptInfo

.VERSION 1.5

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -110,6 +114,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

Expand All @@ -122,14 +135,20 @@

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

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

#>

Expand All @@ -155,16 +174,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"

Expand Down Expand Up @@ -215,7 +244,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
Expand Down Expand Up @@ -368,4 +402,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
Add-HybridRunbookWorker -Name $HybridGroupName -EndPoint $AutomationEndpoint -Token $AutomationPrimaryKey