document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <#  
  2.     .NOTES
  3.     ===========================================================================
  4.      Created on:    1-3-2018
  5.      Created by:    Chris Twiest
  6.      Organization:  Workspace-Guru.com      
  7.     ===========================================================================
  8.     .DESCRIPTION
  9.     This script will create JSON files for LiquidWare ProfileUnity Filter Management.
  10.     You fill in a base OU and the script will get all Child OU\'s in this OU.
  11.     For each Child OU in the OU it will create a JSON file.
  12.     This JSON file will contain the Condition OU User filter information based on the Child OU.
  13.     You can then import the JSON files under Filter Management.
  14. #>
  15.  
  16. $BaseOU = "OU=Groups,dc=Domain,dc=com"
  17. $WorkingDirectory = "C:\\Temp"
  18.  
  19. import-module ActiveDirectory
  20.  
  21. $ChildOUS = Get-ADOrganizationalUnit -Filter * -SearchBase $baseOU | Sort {-join ($_.distinguishedname[($_.distinguishedname.length-1)..0])}
  22.                            
  23. $TestWorkingDirectory = $WorkingDirectory | Test-Path
  24.                            
  25. if ($TestWorkingDirectory -eq $False)
  26. {
  27.     New-Item -ItemType Directory -Path $WorkingDirectory
  28. }
  29.  
  30. New-Item -ItemType Directory -Path "$WorkingDirectory\\Filters"
  31.  
  32. foreach ($ChildOU in $ChildOUS) {
  33.  
  34. $ChildOUName = $ChildOU.Name
  35. $filename = "OU="+"$ChildOUName"
  36. $ChildOUDis = $ChildOU.DistinguishedName
  37.  
  38. New-Item -ItemType file -Path "$WorkingDirectory\\Filters\\$Filename.json"
  39.  
  40. $file = "$WorkingDirectory\\Filters\\$Filename.json"
  41.  
  42. $contentfile = \'{
  43.  "DateExported": "2018-03-01T12:34:30.9207481Z",
  44.  "ProuVersion": "6.7.0.6422",
  45.  "Configurations": [],
  46.  "Filters": [
  47.    {
  48.      "Comments": "",
  49.      "Connections": 60,
  50.      "FilterRules": [
  51.        {
  52.          "ConditionType": 14,
  53.          "MatchType": 0,
  54.          "Value": "\'
  55. $contentfile2 = $ChildOUDis
  56. $contentfile3 = \'" }
  57.      ],
  58.      "MachineClasses": 62,
  59.      "Name": "\'
  60. $contentfile4 = $Filename
  61. $Contentfile5 = \'",
  62.      "OperatingSystems": 4094,
  63.      "RuleAggregate": 0,
  64.      "SystemEvents": 3,
  65.      "CreatedBy": "admin",
  66.      "DateCreated": "2018-03-01T12:32:14Z",
  67.      "DateLastModified": "2018-03-01T12:34:25.535Z",
  68.      "Disabled": false,
  69.      "LastModifiedBy": "admin",
  70.      "Id": "5a97f2ce6db5560804ba9b2f"
  71.    }
  72.  ],
  73.  "PortabilityRulesets": [],
  74.  "Templates": []
  75. }\'
  76.  
  77. $content = $contentfile + $contentfile2 + $contentfile3 + $contentfile4 + $Contentfile5
  78. Add-Content $file $content
  79.  
  80. }
');