Skip to content

Commit f1d837a

Browse files
merillpeombwa
andauthored
Example add mg application password (#1284)
* Update Add-MgApplicationPassword.md * Update Add-MgApplicationPassword.md * Update Add-MgApplicationPassword.md Co-authored-by: Peter Ombwa <[email protected]>
1 parent ae3e77e commit f1d837a

File tree

2 files changed

+106
-16
lines changed

2 files changed

+106
-16
lines changed
Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,63 @@
1-
### Example 1: {{ Add title here }}
1+
### Example 1: Add a password credential to an application with a six month expiry
2+
23
```powershell
3-
PS C:\> {{ Add code here }}
44
5-
{{ Add output here }}
5+
Connect-MgGraph -Scopes 'Application.ReadWrite.All'
6+
7+
$appObjectId = 'eaf1e531-0d58-4874-babe-b9a9f436e6c3'
8+
9+
$passwordCred = @{
10+
displayName = 'Created in PowerShell'
11+
endDateTime = (Get-Date).AddMonths(6)
12+
}
13+
14+
$secret = Add-MgApplicationPassword -applicationId $appObjectId -PasswordCredential $passwordCred
15+
$secret | Format-List
16+
17+
CustomKeyIdentifier :
18+
DisplayName : Created in PowerShell
19+
EndDateTime : 26/11/2022 12:03:31 pm
20+
Hint : Q_e
21+
KeyId : c82bb763-741b-4575-9d9d-df7e766f6999
22+
SecretText : Q_e8Q~ZDWJD.bkgajbREp-VFFUayCuEk8b1hDcr9
23+
StartDateTime : 26/5/2022 1:03:31 pm
24+
AdditionalProperties : {[@odata.context,
25+
https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.passwordCredential]}
626
```
727

8-
{{ Add description here }}
28+
Add a password to an application that expires in six months from the current date.
29+
30+
### Example 2: Add a password credential to an application with a start date
931

10-
### Example 2: {{ Add title here }}
1132
```powershell
12-
PS C:\> {{ Add code here }}
1333
14-
{{ Add output here }}
34+
Connect-MgGraph -Scopes 'Application.ReadWrite.All'
35+
36+
$appObjectId = 'eaf1e531-0d58-4874-babe-b9a9f436e6c3'
37+
38+
$startDate = (Get-Date).AddDays(1).Date
39+
$endDate = $startDate.AddMonths(6)
40+
41+
$passwordCred = @{
42+
displayName = 'Created in PowerShell'
43+
startDateTime = $startDate
44+
endDateTime = $endDate
45+
}
46+
47+
$secret = Add-MgApplicationPassword -applicationId $appObjectId -PasswordCredential $passwordCred
48+
$secret | Format-List
49+
50+
CustomKeyIdentifier :
51+
DisplayName : Created in PowerShell
52+
EndDateTime : 26/11/2022 1:00:00 pm
53+
Hint : TiA
54+
KeyId : 082bf20f-63d6-4970-bb4e-55e504f50d8b
55+
SecretText : TiA8Q~Zs7ej1cGtlW0qnmuFi~JlxXTZew_tU1bGA
56+
StartDateTime : 26/5/2022 2:00:00 pm
57+
AdditionalProperties : {[@odata.context,
58+
https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.passwordCredential]}
1559
```
1660

17-
{{ Add description here }}
61+
Add a password to an application that becomes valid at 12:00 am the next day and is valid for six months.
1862

63+
Use `$secret.StartDateTime.ToLocalTime()` to convert the returned dates from UTC to the local timezone.
Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,63 @@
1-
### Example 1: {{ Add title here }}
1+
### Example 1: Add a password credential to an application with a six month expiry
2+
23
```powershell
3-
PS C:\> {{ Add code here }}
44
5-
{{ Add output here }}
5+
Connect-MgGraph -Scopes 'Application.ReadWrite.All'
6+
7+
$appObjectId = 'eaf1e531-0d58-4874-babe-b9a9f436e6c3'
8+
9+
$passwordCred = @{
10+
displayName = 'Created in PowerShell'
11+
endDateTime = (Get-Date).AddMonths(6)
12+
}
13+
14+
$secret = Add-MgApplicationPassword -applicationId $appObjectId -PasswordCredential $passwordCred
15+
$secret | Format-List
16+
17+
CustomKeyIdentifier :
18+
DisplayName : Created in PowerShell
19+
EndDateTime : 26/11/2022 12:03:31 pm
20+
Hint : Q_e
21+
KeyId : c82bb763-741b-4575-9d9d-df7e766f6999
22+
SecretText : Q_e8Q~ZDWJD.bkgajbREp-VFFUayCuEk8b1hDcr9
23+
StartDateTime : 26/5/2022 1:03:31 pm
24+
AdditionalProperties : {[@odata.context,
25+
https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.passwordCredential]}
626
```
727

8-
{{ Add description here }}
28+
Add a password to an application that expires in six months from the current date.
29+
30+
### Example 2: Add a password credential to an application with a start date
931

10-
### Example 2: {{ Add title here }}
1132
```powershell
12-
PS C:\> {{ Add code here }}
1333
14-
{{ Add output here }}
34+
Connect-MgGraph -Scopes 'Application.ReadWrite.All'
35+
36+
$appObjectId = 'eaf1e531-0d58-4874-babe-b9a9f436e6c3'
37+
38+
$startDate = (Get-Date).AddDays(1).Date
39+
$endDate = $startDate.AddMonths(6)
40+
41+
$passwordCred = @{
42+
displayName = 'Created in PowerShell'
43+
startDateTime = $startDate
44+
endDateTime = $endDate
45+
}
46+
47+
$secret = Add-MgApplicationPassword -applicationId $appObjectId -PasswordCredential $passwordCred
48+
$secret | Format-List
49+
50+
CustomKeyIdentifier :
51+
DisplayName : Created in PowerShell
52+
EndDateTime : 26/11/2022 1:00:00 pm
53+
Hint : TiA
54+
KeyId : 082bf20f-63d6-4970-bb4e-55e504f50d8b
55+
SecretText : TiA8Q~Zs7ej1cGtlW0qnmuFi~JlxXTZew_tU1bGA
56+
StartDateTime : 26/5/2022 2:00:00 pm
57+
AdditionalProperties : {[@odata.context,
58+
https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.passwordCredential]}
1559
```
1660

17-
{{ Add description here }}
61+
Add a password to an application that becomes valid at 12:00 am the next day and is valid for six months.
1862

63+
Use `$secret.StartDateTime.ToLocalTime()` to convert the returned dates from UTC to the local timezone.

0 commit comments

Comments
 (0)