Skip to content

Commit cccdd65

Browse files
Merge pull request #94688 from cocallaw/main
Update Packer AAD SP Creation PowerShell Commands
2 parents d297bd4 + c48106c commit cccdd65

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

articles/virtual-machines/windows/build-image-with-packer.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,14 @@ Create a service principal with [New-AzADServicePrincipal](/powershell/module/az
4242

4343
```azurepowershell
4444
$sp = New-AzADServicePrincipal -DisplayName "PackerSP$(Get-Random)"
45-
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sp.Secret)
46-
$plainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
45+
$plainPassword = (New-AzADSpCredential -ObjectId $sp.Id).SecretText
4746
```
4847

4948
Then output the password and application ID.
5049

5150
```powershell
5251
$plainPassword
53-
$sp.ApplicationId
52+
$sp.AppId
5453
```
5554

5655

@@ -68,7 +67,7 @@ Create a file named *windows.json* and paste the following content. Enter your o
6867

6968
| Parameter | Where to obtain |
7069
|-------------------------------------|----------------------------------------------------|
71-
| *client_id* | View service principal ID with `$sp.applicationId` |
70+
| *client_id* | View service principal ID with `$sp.AppId` |
7271
| *client_secret* | View the auto-generated password with `$plainPassword` |
7372
| *tenant_id* | Output from `$sub.TenantId` command |
7473
| *subscription_id* | Output from `$sub.SubscriptionId` command |

0 commit comments

Comments
 (0)