Skip to content

Commit b778478

Browse files
author
msJinLei
committed
Provide examples for creating ADServicePrincipal with Credential and Certificate
issue: #9842
1 parent 07cc78d commit b778478

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/Resources/Resources/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020
## Upcoming Release
2121
* Make -Scope optional in *-AzPolicyAssignment cmdlets with default to context subscription
22+
* Add examples of creating ADServicePrincipal with password and key credential
2223

2324
## Version 1.9.1
2425
* Fix an error in help document of `Remove-AzTag`.

src/Resources/Resources/help/New-AzADServicePrincipal.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,39 @@ PS C:\> Get-AzADApplication -ObjectId 3ede3c26-b443-4e0b-9efc-b05e68338dc3 | New
205205

206206
Gets the application with object id '3ede3c26-b443-4e0b-9efc-b05e68338dc3' and pipes that to the New-AzADServicePrincipal cmdlet to create a new AD service principal for that application.
207207

208+
### Example 7 - Create a new AD service principal using DisplayName and password credential
209+
210+
```
211+
PS C:\> $credentials = New-Object -TypeName Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential -Property @{ StartDate=Get-Date; EndDate=Get-Date -Year 2024; Password="StrongPassworld!23"}
212+
PS C:\> $sp = New-AzAdServicePrincipal -DisplayName ServicePrincipalName -PasswordCredential $credentials
213+
214+
ServicePrincipalNames : {exxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxc, http://ServicePrincipalName}
215+
ApplicationId : exxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxcc
216+
ObjectType : ServicePrincipal
217+
DisplayName : ServicePrincipalName
218+
Id : 6xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxb
219+
Type :
220+
```
221+
222+
Creates a new application with name "ServicePrincipalName" and password "StrongPassworld!23" and creates the service principal based on the application just created. The start date and end date are added to password credential.
223+
224+
225+
### Example 8 - Create a new AD service principal using DisplayName and plain key credential
226+
227+
```
228+
PS C:\> $cert = <public certificate as base64-encoded string>
229+
PS C:\> $sp = New-AzADServicePrincipal -DisplayName ServicePrincipalName -CertValue $cert -EndDate "2021-01-01"
230+
231+
ServicePrincipalNames : {cxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx6, http://ServicePrincipalName}
232+
ApplicationId : cxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx6
233+
ObjectType : ServicePrincipal
234+
DisplayName : ServicePrincipalName
235+
Id : cxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxc
236+
Type :
237+
```
238+
239+
Creates a new application with name "ServicePrincipalName" and certifcate "$cert" and creates the service principal based on the application just created. The end date is added to key credential.
240+
208241
## PARAMETERS
209242

210243
### -ApplicationId

0 commit comments

Comments
 (0)