Skip to content

Instantly share code, notes, and snippets.

@SQLvariant
Created August 5, 2022 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SQLvariant/5a74d8a6eac7267fc54c0bba9b2958ba to your computer and use it in GitHub Desktop.
Save SQLvariant/5a74d8a6eac7267fc54c0bba9b2958ba to your computer and use it in GitHub Desktop.
A simple Find & Replace script for changing names of things withing Linked Service, Dataset, or Pipeline files.
<# Search for something inside an ADF file and replace it. #>
$Datasets = dir 'C:\temp\MDD-ADF-Test-Repo\dataset' -Recurse
foreach($Dataset in $Datasets.Where({$_.Mode -ne 'd----'})){
$Dataset.Name
if((Get-Content $Dataset.FullName | foreach{ $_ -match 'AzureSqlDatabase1' }) -eq $true ){"Fix it"
(Get-Content $Dataset.FullName).Replace('Azure_SqlDatabase1', 'MDD_SampleSQL_LS') | Set-Content -Path $Dataset.FullName }
else{"Nothing to do"}
}
<# This isn't limited to just Datasets. you can go up one level and do the replace on every directory if you include the -Recurse parameter. #>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment