Skip to content

Commit c991ab5

Browse files
author
BradleyBartlett
committed
Update RegisterWithAzure.ps1 to use PSCredential
1 parent 36fc2f6 commit c991ab5

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

Registration/RegisterWithAzure.ps1

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ This script must be run from the Host machine of the POC.
5858
[CmdletBinding()]
5959
param(
6060
[Parameter(Mandatory=$false)]
61-
[SecureString] $azureAccountPassword,
61+
[PSCredential] $azureCredential,
6262

6363
[Parameter(Mandatory=$true)]
6464
[String] $azureAccountId,
@@ -114,16 +114,15 @@ else
114114
Import-Module C:\CloudDeployment\Setup\Common\AzureADConfiguration.psm1 -ErrorAction Stop
115115
$AzureDirectoryTenantId = Get-TenantIdFromName -azureEnvironment $azureEnvironment -tenantName $azureDirectoryTenantName
116116

117-
if($azureAccountPassword)
117+
if(-not $azureCredential)
118118
{
119-
Write-Verbose "Using provided Azure Credentials to get refresh token"
120-
$AzureCredential = New-Object System.Management.Automation.PSCredential($azureAccountId, $azureAccountPassword)
121-
$tenantDetails = Get-AzureADTenantDetails -AzureEnvironment $azureEnvironment -AADDirectoryTenantName $azureDirectoryTenantName -AADAdminCredential $AzureCredential
119+
Write-Verbose "Prompt user to enter Azure Credentials to get refresh token"
120+
$tenantDetails = Get-AzureADTenantDetails -AzureEnvironment $azureEnvironment -AADDirectoryTenantName $azureDirectoryTenantName
122121
}
123122
else
124123
{
125-
Write-Verbose "Prompt user to enter Azure Credentials to get refresh token"
126-
$tenantDetails = Get-AzureADTenantDetails -AzureEnvironment $azureEnvironment -AADDirectoryTenantName $azureDirectoryTenantName
124+
Write-Verbose "Using provided Azure Credentials to get refresh token"
125+
$tenantDetails = Get-AzureADTenantDetails -AzureEnvironment $azureEnvironment -AADDirectoryTenantName $azureDirectoryTenantName -AADAdminCredential $azureCredential
127126
}
128127

129128
$refreshToken = (ConvertTo-SecureString -string $tenantDetails["RefreshToken"] -AsPlainText -Force)

0 commit comments

Comments
 (0)