Bulk-add URL whitelist/blacklist to Profile

SecureBrowser whitelisting/blacklisting

Written by Ines

Last published at: February 15th, 2022

Script Events:

  1. Import data from CSV
  2. Load data into array
  3. Convert json profile
  4. Replace the existing url list
  5. Convert back to json
  6. Save json file under a different name


Delete

Mandatory fields in CSV


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