From 4e2007e54a910c75b936f989abd4274176b33adb Mon Sep 17 00:00:00 2001 From: itlifeskills <106455363+itlifeskills@users.noreply.github.com> Date: Sun, 22 Sep 2024 11:52:51 -0500 Subject: [PATCH] Add files via upload --- Createnewgroups.ps1 | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Createnewgroups.ps1 diff --git a/Createnewgroups.ps1 b/Createnewgroups.ps1 new file mode 100644 index 0000000..ab35d7a --- /dev/null +++ b/Createnewgroups.ps1 @@ -0,0 +1,55 @@ +$department = "Art and Design" +$name = $department.Split(" ") +$groupName= "grp" +foreach($word in $name){ + + if($word -ne "and"){ + + $groupName = $groupName + "-" + ($word).ToLower() + } +} + + + +$departments = (Import-Csv -Path "C:\Scripts\Data\Departments.csv").Department + +$path = "OU=Groups,OU=ITLifeSkills,DC=hq,DC=itlifeskills,DC=local" + +foreach ($department in $departments){ + + $name = $department.Split(" ") + $groupName= "grp" + foreach($word in $name){ + + if($word -ne "and"){ + + $groupName = $groupName + "-" + ($word).ToLower() + } + } + + New-ADGroup -Name $groupName -SamAccountName $groupName -GroupCategory Security -GroupScope Global -DisplayName $groupName -Path $path -Description $department +} + + + +$projects = (Import-Csv -Path "C:\Scripts\Data\Projects.csv").Project + +$path = "OU=Groups,OU=ITLifeSkills,DC=hq,DC=itlifeskills,DC=local" + +foreach ($project in $projects){ + + $name = $project.Split(" ") + $groupName= "grp" + foreach($word in $name){ + + if($word -ne "and"){ + + $groupName = $groupName + "-" + ($word).ToLower() + } + } + + New-ADGroup -Name $groupName -SamAccountName $groupName -GroupCategory Security -GroupScope Global -DisplayName $groupName -Path $path -Description $project +} + + +