Skip to content

Commit 3cacf7a

Browse files
Merge pull request SharePoint#7875 from arjancornelissen/patch-1
Updated export of ServicePrincipalCredentials
2 parents 5f0286a + 21e0c64 commit 3cacf7a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

docs/sp-add-ins/replace-an-expiring-client-secret-in-a-sharepoint-add-in.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Replace an expiring client secret in a SharePoint Add-in
33
description: Add a new client secret for a SharePoint Add-in that is registered with AppRegNew.aspx.
4-
ms.date: 03/03/2022
4+
ms.date: 04/12/2022
55
ms.prod: sharepoint
66
ms.localizationpriority: high
77
---
@@ -48,13 +48,20 @@ Ensure the following before you begin:
4848
4949
foreach ($appentry in $applist) {
5050
$principalId = $appentry.AppPrincipalId
51-
$principalName = $appentry.DisplayName
5251
53-
Get-MsolServicePrincipalCredential -AppPrincipalId $principalId -ReturnKeyValues $false | ? { $_.Type -eq "Password" } | % { "$principalName;$principalId;" + $_.KeyId.ToString() +";" + $_.StartDate.ToString() + ";" + $_.EndDate.ToString() } | out-file -FilePath c:\temp\appsec.txt -append
52+
Get-MsolServicePrincipalCredential -AppPrincipalId $principalId -ReturnKeyValues $false | Where-Object { $_.Type -eq "Password" } | ForEach-Object {
53+
[PSCustomObject][Ordered]@{
54+
PrincipalName = $appentry.DisplayName
55+
PrincipalId = $principalId
56+
KeyID = $_.KeyId
57+
StartDate = $_.StartDate
58+
EndDate = $_.EndDate
59+
} | Export-Csv -Path C:\temp\appsec.csv -NoTypeInformation -Delimiter ';' -Append
60+
}
5461
}
5562
```
5663
57-
1. Open the file C:\temp\appsec.txt to see the report. Leave the Windows PowerShell window open for the next procedure, if any of the secrets are near expiration.
64+
1. Open the file C:\temp\appsec.csv to see the report. Leave the Windows PowerShell window open for the next procedure, if any of the secrets are near expiration.
5865
5966
## Generate a new secret
6067

0 commit comments

Comments
 (0)