-
Notifications
You must be signed in to change notification settings - Fork 4
/
init.ps1
34 lines (28 loc) · 1.12 KB
/
init.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
<#
This script prepare the polcicy to fit with your environment.
#>
$OldCompanyName = "MVP"
$NewCompanyName = "SPACEX"
$OldManagementGroupId = "/providers/Microsoft.Management/managementGroups/core"
$NewManagementGroupId = "/providers/Microsoft.Management/managementGroups/xxxxxxxxxxx"
#Rename multiple files
$items = Get-ChildItem -Path *.json -Recurse -File
foreach ($item in $items) {
$content = Get-Content -Path $item.FullName
if ($content -like "*$OldCompanyName*") {
Write-Host "Modifying file : $($item.FullName)"
$content -replace $OldCompanyName, $NewCompanyName > $item.FullName
}
if ($content -like "*$OldManagementGroupId*") {
Write-Host "Modifying file : $($item.FullName)"
$content -replace $OldManagementGroupId, $NewManagementGroupId > $item.FullName
}
}
#Rename multiple folders
$items = Get-ChildItem -Path ./ -Recurse -Directory
foreach ($item in $items) {
if ($item.Name -like "*$OldCompanyName*") {
Write-Host "Renaming folder : $($item.FullName)"
Move-Item -Path $item.FullName $item.FullName.Replace($OldCompanyName, $NewCompanyName)
}
}