Preston_Cole
Mar 14, 2024Copper Contributor
Am I doing something wrong?
Hi all
I am clearly missing something obvious.
I have two CSV files. One with a list of 'Project names' One with a list of 'partial' group names.
I need to make an AzureAD group name based on the data in each CSV.
So, for example, Projects.csv looks like this:
PROJECTS
Project-1
Project-2
Project-3
Groups.csv looks like this:
GROUPS
-Group-1
-Group-2
-Group-3
I'm looking to work though each and have a group created that looks like this:
SharePoint-Project-1-Group-1
SharePoint-Project-1-Group-2
etc etc
The code I'm currently trying to use is like this:
# Path to CSV files
$projectCSV = "C:\path\to\project.csv"
$groupCSV = "C:\path\to\group.csv"
# Read CSV files
$projects = Import-Csv $projectCSV
$groups = Import-Csv $groupCSV
# Loop through each combination of project and group
foreach ($project in $projects) {
foreach ($group in $groups) {
# Create Azure AD group
$groupName = 'SharePoint-' + $project.ProjectName + $group.GroupName
$groupDescription = "Group for project '$($project.ProjectName)' and SharePoint group '$($group.GroupName)'"
# Create the group
New-AzureADGroup -DisplayName $groupName -Description $groupDescription -MailEnabled $false -SecurityEnabled $true -MailNickName $groupName
}
}
Seems the $projectName and $groupName s are empty 😞
Am I being thick?
Any help would be awesome.
Cheers
Preston