You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Write-Information"Debug: Group where [$($correlationProperty)] = [$($correlationValue)] already exists, but will be renamed"
324
+
325
+
$SetADGroupParams=@{
326
+
Identity=$currentADGroup.objectguid
327
+
DisplayName=$groupName
328
+
Server=$pdc
329
+
}
330
+
$null=Set-AdGroup@SetADGroupParams
331
+
332
+
$RenameADGroupParams=@{
333
+
Identity=$currentADGroup.objectguid
334
+
NewName=$groupName
335
+
Server=$pdc
336
+
}
337
+
$null=Rename-ADObject@RenameADGroupParams
321
338
322
339
$outputContext.AuditLogs.Add([PSCustomObject]@{
323
-
Message="Skipped creating group $($correlationProperty)] = [$($correlationValue)] for resource [$($resource|ConvertTo-Json)]. (Already exists)"
340
+
Message="Renaming group [$($correlationProperty)] = [$($correlationValue)] for resource [$($resource|ConvertTo-Json)]."
324
341
Action="CreateResource"
325
342
IsError=$false
326
343
})
327
344
}
345
+
else {
346
+
Write-Warning"DryRun: Group [$($correlationProperty)] = [$($correlationValue)] for resource [$($resource|ConvertTo-Json)] already exists but will be renamed"
347
+
if ($actionContext.Configuration.isDebug-eq$true) { Write-Information"Debug: Group parameters: $($ADGroupParams|ConvertTo-Json)" }
348
+
}
328
349
}
329
-
else {
330
-
Write-Warning"DryRun: Group $($correlationProperty)] = [$($correlationValue)] for resource [$($resource|ConvertTo-Json)] already exists"
331
-
if ($actionContext.Configuration.isDebug-eq$true) { Write-Information"Debug: Group parameters: $($ADGroupParams|ConvertTo-Json)" }
350
+
else
351
+
{
352
+
# Create new group if group does not exist yet
353
+
if (-Not($actionContext.DryRun-eq$True)) {
354
+
if ($actionContext.Configuration.isDebug-eq$true) {
355
+
Write-Information"Debug: Group where [$($correlationProperty)] = [$($correlationValue)] already exists"
356
+
357
+
$outputContext.AuditLogs.Add([PSCustomObject]@{
358
+
Message="Skipped creating group [$($correlationProperty)] = [$($correlationValue)] for resource [$($resource|ConvertTo-Json)]. (Already exists)"
359
+
Action="CreateResource"
360
+
IsError=$false
361
+
})
362
+
}
363
+
}
364
+
else {
365
+
Write-Warning"DryRun: Group $($correlationProperty)] = [$($correlationValue)] for resource [$($resource|ConvertTo-Json)] already exists"
366
+
if ($actionContext.Configuration.isDebug-eq$true) { Write-Information"Debug: Group parameters: $($ADGroupParams|ConvertTo-Json)" }
0 commit comments