This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 167
/
Reset-Configs.ps1
48 lines (42 loc) · 2.13 KB
/
Reset-Configs.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#################################################################################################
#
#
# Use this script to reset the app.config and web.config files to their original unmodified state
#
#
#################################################################################################
$ClientId= "[CLIENT ID]"
$ClientSecret = "[CLIENT SECRET]"
$ADTenant = "[TENANT].onmicrosoft.com"
$InfrastructureSiteUrl = "[INFRASTRUCTURE SITE URL]"
# DO NOT MODIFY BELOW
$basePath = "$(convert-path ..)\OfficeDevPnP.PartnerPack.SiteProvisioning"
$configFiles = "OfficeDevPnP.PartnerPack.CheckAdminsJob\App.config",
"OfficeDevPnP.PartnerPack.ExternalUsersJob\App.config",
"OfficeDevPnP.PartnerPack.ContinousJob\App.config",
"OfficeDevPnP.PartnerPack.ScheduledJob\App.config",
"OfficeDevPnP.PartnerPack.SiteProvisioning\Web.config"
$azureWebJobsDashBoardNodeValue = "";
foreach($configFile in $configFiles)
{
$configDoc = (Get-Content "$basePath\$configFile") -As [Xml]
$azureWebJobsDashboardNode = $configDoc.configuration.connectionStrings.add | ?{$_.name -eq "AzureWebJobsDashboard"}
if($azureWebJobsDashboardNode -ne $null)
{
$azureWebJobsDashboardNode.connectionString = $azureWebJobsDashBoardNodeValue
}
$azureWebJobsStorageNode = $configDoc.configuration.connectionStrings.add | ?{$_.name -eq "AzureWebJobsStorage"}
if($azureWebJobsStorageNode -ne $null)
{
$azureWebJobsStorageNode.connectionString = $azureWebJobsDashBoardNodeValue
}
$clientIdNode = $configDoc.configuration.appSettings.add | ? {$_.key -eq "ida:ClientId"}
$clientIdNode.value = $ClientId
$clientSecretNode = $configDoc.configuration.appSettings.add | ? {$_.key -eq "ida:ClientSecret"}
$clientSecretNode.value = $ClientSecret
$tenantSettingsNode = $configDoc.configuration.PnPPartnerPackConfiguration.TenantSettings
$tenantSettingsNode.tenant = $ADTenant
$tenantSettingsNode.appOnlyCertificateThumbprint = "[CERTIFICATE THUMBPRINT]"
$tenantSettingsNode.infrastructureSiteUrl = $InfrastructureSiteUrl
$configDoc.Save("$basePath\$configFile")
}