Skip to content

Commit b894a7e

Browse files
paulewertVesaJuvonen
authored andcommitted
PowerShell correction (SharePoint#2826)
Correct the PowerShell given in the "Generate a report that lists each add-in and the date that its secret expires..." step. The current script simply outputs a static date (today) instead of the expiration date of the secret.
1 parent 045f61f commit b894a7e

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,14 @@ Ensure the following before you begin:
4141
- From the remainder, it filters out non-SharePoint add-ins and add-ins that use asymmetric keys, such as workflows.
4242

4343
```powershell
44-
$applist = Get-MsolServicePrincipal -all |Where-Object -FilterScript { ($_.DisplayName -notlike "*Microsoft*") -and ($_.DisplayName -notlike "autohost*") -and ($_.ServicePrincipalNames -notlike "*localhost*") }
44+
$applist = Get-MsolServicePrincipal -all |Where-Object -FilterScript { ($_.DisplayName -notlike "*Microsoft*") -and ($_.DisplayName -notlike "autohost*") -and ($_.ServicePrincipalNames -notlike "*localhost*") }
4545
46-
foreach ($appentry in $applist)
47-
{
48-
$principalId = $appentry.AppPrincipalId
49-
$principalName = $appentry.DisplayName
50-
51-
Get-MsolServicePrincipalCredential -AppPrincipalId $principalId -ReturnKeyValues $false | Where-Object { ($_.Type -ne "Other") -and ($_.Type -ne "Asymmetric") }
52-
53-
$date = get-date
54-
Write-Host "$principalName;$principalId;$appentry.KeyId;$appentry.type;$date;$appentry.Usage"
55-
56-
} > c:\temp\appsec.txt
46+
foreach ($appentry in $applist) {
47+
$principalId = $appentry.AppPrincipalId
48+
$principalName = $appentry.DisplayName
49+
50+
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
51+
}
5752
```
5853

5954
4. 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.
@@ -180,4 +175,4 @@ For expired client secrets, first you must delete all of the expired secrets for
180175

181176
- [Provider Hosted App fails on SPO](https://blogs.technet.microsoft.com/sharepointdevelopersupport/2015/03/11/provider-hosted-app-fails-on-spo/)
182177
- [Creating SharePoint Add-ins that use low-trust authorization](creating-sharepoint-add-ins-that-use-low-trust-authorization.md)
183-
- [Authorization and authentication of SharePoint Add-ins](authorization-and-authentication-of-sharepoint-add-ins.md)
178+
- [Authorization and authentication of SharePoint Add-ins](authorization-and-authentication-of-sharepoint-add-ins.md)

0 commit comments

Comments
 (0)