Hi All,
I'm trying to bulk create some new security groups by utilising the names of some existing ones in our AD.
Essentially, all I'm looking to do is read in the name of the existing group and then append "-Shared" to the end of it when creating the new one.
I'm thinking this will do the trick, however being a little cautious I wanted to throw this out there for review before I hit the button as -WhatIf doesn't work with script blocks.
Get-ADGroup -Filter {name -like "<ExistingGroup>*"} | Select-Object name | ForEach-Object {New-ADGroup -Name "$_.-Shared" -DisplayName "$_.-Shared" -Description "Shared folder" -Path "<DistinguishedPathName>" -GroupCategory Security -GroupScope DomainLocal}
Any expert advice would be greatly appreciated!
Cheers.