Script Events:
- Import data from CSV
- Load data into array
- Convert json profile
- Replace the existing url list
- Convert back to json
- Save json file under a different name
Script example:
Script:
$oldjson = "C:\Temp\oldprofile.json" #Specify location of the profile you're editing
$newjson = "C:\Temp\newprofile.json" #Specify the location where the new profile will be saved
$newRuleList = Import-Csv -Delimiter "," -Path "C:\Temp\urls.csv" #Specify the location of the csv file containing urls
#do not edit below this line
#########################################
$ruleList = @()
foreach ($l in $newRuleList) {
$ruleFormat = [PSCustomObject]@{
Name = $l.Name
Enabled = $true
Action = 0
FilterType = 1
Filter = $l.Filter
}
$ruleList += $ruleFormat
}
$currentProfile = Get-Content $oldjson
$profileOuter = $currentProfile |ConvertFrom-Json
$profileData = $profileOuter.profileData | ConvertFrom-Json
$profileData.SecureBrowser.UrlFilters.Rules = $ruleList
$profileOuter.profileData = $profileData | ConvertTo-Json -Depth 99
$updatedProfile = $profileOuter | ConvertTo-Json -Depth 99
$updatedProfile | Set-Content $newjson