I am attempting to write my first PS script and would like to check if a Name of an Office 365 group already exists in the system. So I set the vars and want to check if GN matches a group name already in the system, how can I access all the names from the Get-UnifiedGroup var?
$Groupname = "test group"
$Alias = "testing"
$AccessType = "Public"
$GN = Get-UnifiedGroup
#Check if Group Exists already
if ($GN = $Groupname)
{
write-Host "Group $GroupName exists Already!" -ForegroundColor Red
}
else
New-UnifiedGroup –DisplayName "$Groupname" -Alias ="$Alias" -AccessType = "$AccessType"