Created
September 16, 2020 12:40
-
-
Save OlafD/2cb5e22712e75bce18f9a8dd1912f427 to your computer and use it in GitHub Desktop.
To be used with the output of the Get-PnPProvisioningTemplate cmdlet, this script will replace all mail addresses (user accounts) in the xml file of the output with one static mail address. This is useful, when also content (pages) need to be moved to another tenant.
This file contains hidden or 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
param ( | |
$InFile, | |
$OutFile, | |
$MailDomain, | |
$ReplaceWith | |
) | |
$regexFind = "\b[A-Z0-9._%+-]+@$MailDomain\b" | |
$inputContent = Get-Content $InFile | |
$lineCount = $inputContent.Length | |
$outputContent = $inputContent | |
for ($i = 0; $i -lt $lineCount; $i++) | |
{ | |
if (($inputContent[$i] -match $regexFind) -eq $true) | |
{ | |
$outputContent[$i] = $inputContent[$i] -replace $regexFind, $ReplaceWith | |
} | |
} | |
$outputContent | Out-File $OutFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment