Skip to content

Commit 1650d49

Browse files
author
BradleyBartlett
committed
Update RegisterWithAzure.ps1
1 parent 6bfffd7 commit 1650d49

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

Registration/RegisterWithAzure.ps1

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,27 @@ param(
6565
[String] $azureSubscriptionId,
6666

6767
[Parameter(Mandatory=$true)]
68-
[String] $AzureDirectoryTenantName,
68+
[String] $azureDirectoryTenantName,
6969

7070
[Parameter(Mandatory=$false)]
71-
[String] $AzureEnvironment = "AzureCloud",
71+
[String] $azureEnvironment = "AzureCloud",
7272

7373
[Parameter(Mandatory=$false)]
74-
[String] $AzureResourceManagerEndpoint = "https://management.azure.com"
74+
[String] $azureResourceManagerEndpoint = "https://management.azure.com"
7575

7676
)
7777

78+
#requires -Module AzureRM.Profile
79+
#requires -Module AzureRM.Resources
80+
#requires -RunAsAdministrator
7881

7982
#
8083
# Wrapper script to test registration and activation
8184
# Uses refresh tokens and supports 2fa, MSA accounts
8285
#
8386

84-
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
85-
$VerbosePreference = [System.Management.Automation.ActionPreference]::Continue
87+
#$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
88+
#$VerbosePreference = [System.Management.Automation.ActionPreference]::Continue
8689

8790
Import-Module C:\CloudDeployment\ECEngine\EnterpriseCloudEngine.psd1 -Force
8891
cd C:\CloudDeployment\Setup\Activation\Bridge
@@ -92,18 +95,18 @@ cd C:\CloudDeployment\Setup\Activation\Bridge
9295
#
9396
Import-Module C:\CloudDeployment\Setup\Common\AzureADConfiguration.psm1 -ErrorAction Stop
9497

95-
$AzureCredential = New-Object System.Management.Automation.PSCredential($AzureAccountId, (ConvertTo-SecureString -String $AzureCredentialPassword -AsPlainText -Force))
96-
$AzureDirectoryTenantId = Get-TenantIdFromName -azureEnvironment $AzureEnvironment -tenantName $AzureDirectoryTenantName
98+
$AzureCredential = New-Object System.Management.Automation.PSCredential($azureAccountId, (ConvertTo-SecureString -String $azureCredentialPassword -AsPlainText -Force))
99+
$AzureDirectoryTenantId = Get-TenantIdFromName -azureEnvironment $azureEnvironment -tenantName $azureDirectoryTenantName
97100

98101
if($AzureCredential)
99102
{
100103
Write-Verbose "Using provided Azure Credentials to get refresh token"
101-
$tenantDetails = Get-AzureADTenantDetails -AzureEnvironment $AzureEnvironment -AADDirectoryTenantName $AzureDirectoryTenantName -AADAdminCredential $AzureCredential
104+
$tenantDetails = Get-AzureADTenantDetails -AzureEnvironment $azureEnvironment -AADDirectoryTenantName $azureDirectoryTenantName -AADAdminCredential $AzureCredential
102105
}
103106
else
104107
{
105108
Write-Verbose "Prompt user to enter Azure Credentials to get refresh token"
106-
$tenantDetails = Get-AzureADTenantDetails -AzureEnvironment $AzureEnvironment -AADDirectoryTenantName $AzureDirectoryTenantName
109+
$tenantDetails = Get-AzureADTenantDetails -AzureEnvironment $azureEnvironment -AADDirectoryTenantName $azureDirectoryTenantName
107110
}
108111

109112
$refreshToken = (ConvertTo-SecureString -string $tenantDetails["RefreshToken"] -AsPlainText -Force)
@@ -112,7 +115,7 @@ $refreshToken = (ConvertTo-SecureString -string $tenantDetails["RefreshToken"] -
112115
# Step 1: Configure Bridge identity
113116
#
114117

115-
.\Configure-BridgeIdentity.ps1 -RefreshToken $refreshToken -AzureAccountId $AzureAccountId -AzureDirectoryTenantName $AzureDirectoryTenantName -AzureEnvironment "AzureCloud" -Verbose
118+
.\Configure-BridgeIdentity.ps1 -RefreshToken $refreshToken -AzureAccountId $azureAccountId -AzureDirectoryTenantName $azureDirectoryTenantName -AzureEnvironment $azureEnvironment -Verbose
116119
Write-Verbose "Configure Bridge identity completed"
117120

118121
#
@@ -131,7 +134,7 @@ Write-Verbose "New registration request completed"
131134
$registrationRequestFile = "c:\temp\registration.json"
132135
$registrationOutputFile = "c:\temp\registrationOutput.json"
133136
.\Register-AzureStack.ps1 -BillingModel PayAsYouUse -EnableSyndication -ReportUsage -SubscriptionId $azureSubscriptionId -AzureAdTenantId $AzureDirectoryTenantId `
134-
-RefreshToken $refreshToken -AzureAccountId $AzureAccountId -AzureEnvironmentName AzureCloud -RegistrationRequestFile $registrationRequestFile `
137+
-RefreshToken $refreshToken -AzureAccountId $azureAccountId -AzureEnvironmentName $azureEnvironment -RegistrationRequestFile $registrationRequestFile `
135138
-RegistrationOutputFile $registrationOutputFile -Location "westcentralus" -Verbose
136139
Write-Verbose "Register Azure Stack with Azure completed"
137140

@@ -162,5 +165,5 @@ $regResponse = Get-Content -path $activationDataFile
162165
$bytes = [System.Text.Encoding]::UTF8.GetBytes($regResponse)
163166
$activationCode = [Convert]::ToBase64String($bytes)
164167

165-
.\Activate-Bridge.ps1 -activationCode $activationCode -AzureResourceManagerEndpoint $AzureResourceManagerEndpoint -Verbose
168+
.\Activate-Bridge.ps1 -activationCode $activationCode -AzureResourceManagerEndpoint $azureResourceManagerEndpoint -Verbose
166169
Write-Verbose "Azure Stack activation completed"

0 commit comments

Comments
 (0)