Last active
January 10, 2020 21:38
-
-
Save alexc-MSFT/2d3c8f4ad531788609fb39fed2406a76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# Script to update the configuration (definition) of a Power Automate Flow | |
# This is an EXAMPLE script and assumes you have a flow with the two placeholder values - amend the parameters and config accordingly #> | |
<# | |
.SYNOPSIS | |
Update the config/any hardcoded values in a Flow using placeholders | |
.EXAMPLE | |
Update-FlowConfig.ps1 -SiteURL 'https://mytenant.sharepoint.com/sites/testsite' -ListID '0d1caedb-c38d-48b0-ba4a-e0fd5218c38b' -FlowPackagePath 'C:\Users\johndoe\Documents\Flows\MyFlow\' | |
SiteURL : URL to the SharePoint site (assuming a SharePoint trigger) | |
ListID: ID of the SharePoint list | |
FlowPackagePath: File path to your extracted Flow package, must be the TOP level folder of the package e.g. "C:\Users\johndoe\Documents\Flows\MyFlow\*" | |
#> | |
param( | |
[Parameter(Mandatory = $true)] | |
[string]$SiteURL, | |
[Parameter(Mandatory = $true)] | |
[string]$ListID, | |
[Parameter(Mandatory = $true)] | |
[string]$FlowPackagePath | |
) | |
# Set path to definition JSON file | |
$jsonPath = Get-ChildItem -Path $FlowPackagePath -Recurse -Include definition.json | Select -ExpandProperty Directory | |
# Append filename | |
$jsonPath = "$jsonPath\definition.json" | |
# Get path of top level directory (where flow package is ectracted to) | |
$topFolderPath = (get-item $jsonPath).Directory.Parent.Parent.Parent.Parent.FullName | |
# Get JSON content and update placeholders based on parameters | |
(Get-Content $jsonPath).Replace("{SiteURL}", $SiteURL).Replace("{RequestsListID}", $ListID) | Set-Content $jsonPath | |
# Re-zip the flow package ready for import - rename the zip file or update script to replace with the name of your flow | |
Compress-Archive -Path $FlowPackagePath -DestinationPath "$topFolderPath\Flow.zip" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment