diff --git a/Process-ADObjects-Work-Y015.ps1 b/Process-ADObjects-Work-Y015.ps1 index a2553f9..d837b57 100644 --- a/Process-ADObjects-Work-Y015.ps1 +++ b/Process-ADObjects-Work-Y015.ps1 @@ -473,8 +473,8 @@ function ProcessADObjects # $Institut + ";" + $roleType + ";" + $item.OldName + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append $DAWGruppenverwaltungOutLine = $Institut + ";" + $roleType + ";" + $item.OldName + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + $roleType + ";" + $item.OldName + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" - $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungNeuOutLine) + # BUGFIX 2026-07-05 (ported from R125): removed a second Add of the (former) Neu + # line into the Out list, which duplicated every FileSystemAccess creation row. $NewFullName = $item.'GUIADGroup.Name' $ProfilNummer = 0 @@ -841,8 +841,6 @@ function ProcessADObjects $KURSSollProfileOutLine = ($ProfilNummer).ToString() + ";" + $NewFullName.Replace($SPKID + "GGX-", "").Replace("_1552_", "_AD_") + ";" + $ProfilName.Replace("-AZ_", "-AV_") + ";" + $dum + ";" + $item.OldName + ";" + "Verzeichnispfad: " + $FullPath + ";" + $VerzeichnisArt $KURSSollProfileOutList.Add($KURSSollProfileOutLine) - $allUsers = "" - $cntUsers = [int]0 foreach ($item1 in $ADObjectMemberships) { @@ -855,25 +853,6 @@ function ProcessADObjects $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $item1.MemberName + ";" + "" + ";" + "" + ";" + "user" + ";" + "" $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) - $cntUsers++ - #Write-Host $cntUsers - if ($cntUsers -lt 2) - { - $allUsers += $SPK.'RootDomainName' + "\" + $item1.MemberName - } - else - { - $allUsers += "`n" + $SPK.'RootDomainName' + "\" + $item1.MemberName - } - if ($cntUsers -gt 13) - { - #Write-Host "Schreibe 1" - # $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $item1.MemberName + ";" + "" + ";" + "" + ";" + "user" + ";" + "" - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } # Kurs Daten schreiben #Write-Host $u.MemberName $mitarbeiter_array.Item($u.MemberName) @@ -905,41 +884,10 @@ function ProcessADObjects # $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $u.MemberName + ";" + "" + ";" + "" + ";" + "group" + ";" + $item1.MemberName | Out-File $DAWGruppenverwaltungOutFilePath -Encoding "utf8NoBom" -Append $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $u.MemberName + ";" + "" + ";" + "" + ";" + "group" + ";" + $item1.MemberName $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) - $cntUsers++ - #Write-Host $cntUsers - if ($cntUsers -lt 2) - { - $allUsers += $SPK.'RootDomainName' + "\" + $u.MemberName - } - else - { - $allUsers += "`n" + $SPK.'RootDomainName' + "\" + $u.MemberName - } - if ($cntUsers -gt 13) - { - #Write-Host "Schreibe 2" - # $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } } } } } - #Neu Anfang - #Write-Host "Anzahl User: " $cntUsers - if ($cntUsers -ge 1) - { - #Write-Host "Schreibe 3" - # $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } - #Neu Ende $i++ } @@ -1085,8 +1033,6 @@ function ProcessADObjects # $Institut + ";" + $roleType + ";" + $item.OldName + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append $DAWGruppenverwaltungOutLine = $Institut + ";" + $roleType + ";" + $item.OldName + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + $roleType + ";" + $item.OldName + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) $ProfilNummer = "" @@ -1119,7 +1065,6 @@ function ProcessADObjects $dum = "0570000/0012" } - ### Neu Anfang if ($pkey_array.ContainsKey("PAZ_" + $AWNR)) { $pkey_array.Item("PAZ_" + $AWNR)++ @@ -1132,7 +1077,6 @@ function ProcessADObjects } #$PnrStr = ([string]$pkey_array.Item("PAZ_" + $AWNR)).PadLeft(3, '0') - ### Neu Ende #"50" + $AWNR + "9" + ($PnrStr).ToString() + ";" + $item.'GUIADGroup.Name' + ";" + $ProfilName + ";" + $dum + ";" + "" | out-file $KURSSollProfileOutFilePath -Encoding "utf8NoBom" -Append if ($AWNR -ieq "0000") @@ -1202,7 +1146,6 @@ function ProcessADObjects $kz = "XXXXX" } - ### Neu Anfang if ($pkey_array.ContainsKey("PAZ_" + $AWNR)) { $pkey_array.Item("PAZ_" + $AWNR)++ @@ -1216,7 +1159,6 @@ function ProcessADObjects } $PnrStr = ([string]$pkey_array.Item("PAZ_" + $AWNR)).PadLeft(3, '0') - ### Neu Ende #"50" + $AWNR + "9" + ($PnrStr).ToString() + ";" + $item.'GUIADGroup.Name' + ";" + $ProfilName + ";" + $dum + ";" + "" | out-file $KURSSollProfileOutFilePath -Encoding "utf8NoBom" -Append ##$NNNAME = $kz + "-" + $aname @@ -1244,8 +1186,6 @@ function ProcessADObjects } # foreach ($userMemberShip in $userMemberShips) { - $allUsers = "" - $cntUsers = [int]0 foreach ($item1 in $ADObjectMemberships) { @@ -1261,25 +1201,6 @@ function ProcessADObjects # $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $item1.MemberName + ";" + "" + ";" + "" + ";" + "user" + ";" + $item.OldName | Out-File $DAWGruppenverwaltungOutFilePath -Encoding "utf8NoBom" -Append $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $item1.MemberName + ";" + "" + ";" + "" + ";" + "user" + ";" + $item.OldName $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) - $cntUsers++ - #Write-Host $cntUsers - if ($cntUsers -lt 2) - { - $allUsers += $SPK.'RootDomainName' + "\" + $item1.MemberName - } - else - { - $allUsers += "`n" + $SPK.'RootDomainName' + "\" + $item1.MemberName - } - if ($cntUsers -gt 13) - { - #Write-Host "Schreibe 1" - # $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } # Kurs Daten schreiben $dum = $mitarbeiter_array.Item($item1.MemberName) @@ -1293,6 +1214,10 @@ function ProcessADObjects } elseif ($item1.MemberClass -ieq "group") { + # BUGFIX 2026-07-05 (ported from R125): without this assignment $users is + # empty/stale here and the foreach below never emits the indirect + # (group-inherited) AZ_* membership rows. + $users = getUsersByMemberGroup $item1.MemberName foreach ($u in $users) { # Write-Host "writing indirect membership entry #"$i.ToString() ", user" $u.MemberName "from group" $item1.MemberName @@ -1300,41 +1225,10 @@ function ProcessADObjects # $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $u.MemberName + ";" + "" + ";" + "" + ";" + "group" + ";" + $item.OldName | Out-File $DAWGruppenverwaltungOutFilePath -Encoding "utf8NoBom" -Append $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $u.MemberName + ";" + "" + ";" + "" + ";" + "group" + ";" + $item.OldName $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) - $cntUsers++ - #Write-Host $cntUsers - if ($cntUsers -lt 2) - { - $allUsers += $SPK.'RootDomainName' + "\" + $u.MemberName - } - else - { - $allUsers += "`n" + $SPK.'RootDomainName' + "\" + $u.MemberName - } - if ($cntUsers -gt 13) - { - #Write-Host "Schreibe 2" - # $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } } } } } - #Neu Anfang - #Write-Host "Anzahl User: " $cntUsers - if ($cntUsers -ge 1) - { - #Write-Host "Schreibe 3" - # $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } - #Neu Ende $i++ } @@ -1458,11 +1352,7 @@ function ProcessADObjects # $Institut + ";" + $roleType + ";" + $adObjectEntry.OldName + ";" + $NewFullName + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append $DAWGruppenverwaltungOutLine = $Institut + ";" + $roleType + ";" + $adObjectEntry.OldName + ";" + $NewFullName + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + $roleType + ";" + $adObjectEntry.OldName + ";" + $NewFullName + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) $userMemberShips = @(getAllUserMemberships $adObjectEntry) - $allUsers = "" - $cntUsers = [int]0 $NewFullName1 = $NewFullName #$StelleVerant = "9999999/9999" @@ -1492,25 +1382,6 @@ function ProcessADObjects #$Institut + ";" + "Role" + ";" + $NewFullName + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName + ";" + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungOutFilePath -Encoding "utf8NoBom" -Append $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $NewFullName + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName + ";" + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) - $cntUsers++ - #Write-Host "cnt: " $cntUsers - if ($cntUsers -lt 2) - { - $allUsers += $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName - } - else - { - $allUsers += "`n" + $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName - } - - if ($cntUsers -gt 13) - { - # $Institut + ";" + "Role" + ";" + $NewFullName + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $NewFullName + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } #Write-Host "## o: " $userMemberShip.Origin @@ -1544,16 +1415,6 @@ function ProcessADObjects } } - #Neu Anfang - if ($cntUsers -ge 1) - { - # $Institut + ";" + "Role" + ";" + $NewFullName + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $NewFullName + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } - #Neu Ende $i++ } } @@ -1594,8 +1455,6 @@ function ProcessADObjects $roleType = "Organisation" $DAWGruppenverwaltungOutLine = $Institut + ";" + $roleType + ";" + $adObjectEntry.OldName + ";" + $NewFullName1 + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + $roleType + ";" + $adObjectEntry.OldName + ";" + $NewFullName1 + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) $PnrStr = ([string]$ProfilNummer).PadLeft(2, '0') # $AWNR = ([string]$nummer_array.Item($item.OldName)).PadLeft(3, '0') $AWNR = "xxxx" @@ -1606,8 +1465,6 @@ function ProcessADObjects $KURSSollProfileOutList.Add($KURSSollProfileOutLine) $ProfilNummer++ $userMemberShips = @(getAllUserMemberships $adObjectEntry) - $allUsers = "" - $cntUsers = [int]0 foreach ($userMemberShip in $userMemberShips) { # Fehler laut Norbert @@ -1617,24 +1474,6 @@ function ProcessADObjects #Write-Host "TypeTagOrganisation: " $userMemberShip.MemberClass #$Institut + ";" + "Role" + ";" + $NewFullName + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName + ";" + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | out-file $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append #Write-Host "TypeTagOrganisation: " $userMemberShip.MemberClass - $cntUsers++ - #Write-Host $cntUsers - if ($cntUsers -lt 2) - { - $allUsers += $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName - } - else - { - $allUsers += "`n" + $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName - } - - if ($cntUsers -gt 13) - { - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } #$userMemberShip | Out-String @@ -1665,15 +1504,6 @@ function ProcessADObjects } $i++ - #Neu Anfang - if ($cntUsers -ge 1) - { - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } - #Neu Ende } } @@ -1739,8 +1569,6 @@ function ProcessADObjects $ProfilNummerSonstigesStartWert = 430000000 $PN = "" $StelleVerant = "0570000/0012" - $allUsers = "" - $cntUsers = [int]0 foreach ($adObjectEntry in $adObjectEntries) { @@ -1766,8 +1594,6 @@ function ProcessADObjects # $Institut + ";" + $roleType + ";" + $adObjectEntry.OldName + ";" + $NewFullName.Replace("-S_", "-SE_") + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append $DAWGruppenverwaltungOutLine = $Institut + ";" + $roleType + ";" + $adObjectEntry.OldName + ";" + $NewFullName.Replace("-S_", "-SE_") + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + $roleType + ";" + $adObjectEntry.OldName + ";" + $NewFullName.Replace("-S_", "-SE_") + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) $PN = $null foreach ($rule in $pnRules) @@ -1803,25 +1629,6 @@ function ProcessADObjects $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName + ";" + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) - $cntUsers++ - #Write-Host $cntUsers - if ($cntUsers -lt 2) - { - $allUsers += $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName - } - else - { - $allUsers += "`n" + $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName - } - - if ($cntUsers -gt 13) - { - # $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } $persnr = "0000000000" @@ -1849,16 +1656,6 @@ function ProcessADObjects $KURSIstMitarbeiterProfileOutList.Add($KURSIstMitarbeiterProfileOutLine) } } - #Neu Anfang - if ($cntUsers -ge 1) - { - # $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } - #Neu Ende } } @@ -1891,8 +1688,6 @@ function ProcessADObjects $iSonstiges = 0 $PN = "" $StelleVerant = "0570000/0012" - $allUsers = "" - $cntUsers = [int]0 foreach ($adObjectEntry in $adObjectEntries) { @@ -1953,25 +1748,6 @@ function ProcessADObjects #Write-Host "TypeTagSecurity: " $userMemberShip.MemberClass #$userMemberShip | Out-String - $cntUsers++ - #Write-Host $cntUsers - if ($cntUsers -lt 2) - { - $allUsers += $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName - } - else - { - $allUsers += "`n" + $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName - } - - if ($cntUsers -gt 13) - { - # $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } $persnr = "0000000000" @@ -2000,20 +1776,51 @@ function ProcessADObjects } } } - #Neu Anfang - if ($cntUsers -ge 1) - { - # $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append - $DAWGruppenverwaltungNeuOutLine = $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ';"' + $allUsers + '";' + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName - $DAWGruppenverwaltungNeuOutList.Add($DAWGruppenverwaltungNeuOutLine) - $allUsers = "" - $cntUsers = 0 - } - #Neu Ende } } + + # ===== Post-processing of output collections (2026-07-05) ===================== + # 1) All collections are sorted ONCE before writing (deterministic, culture- + # independent ordinal order). Inline writes stay unsorted and cheap. + # 2) The 'Neu' Gruppenverwaltung variant is no longer produced along the way; + # it is DERIVED from the sorted Out list: rows assigning an account to a + # target group (Accounts.Add non-empty) are grouped by GUIADGroup.LDAP. + # The first row of each group keeps all columns; subsequent rows carry only + # the Accounts.Add column. Rows without an account assignment (e.g. group + # creation rows) pass through unchanged. + $ordinalComparer = [System.StringComparer]::Ordinal + $DAWGruppenAnlegenOutList.Sort($ordinalComparer) + $DAWGruppenverwaltungOutList.Sort($ordinalComparer) + $KURSSollProfileOutList.Sort($ordinalComparer) + $KURSIstMitarbeiterProfileOutList.Sort($ordinalComparer) + + $DAWGruppenverwaltungNeuOutList.Clear() + $lastLdap = $null + foreach ($outLine in $DAWGruppenverwaltungOutList) + { + $cols = $outLine.Split(";") + if ([string]::IsNullOrEmpty($cols[5])) + { + # no account assignment -> pass through unchanged + $DAWGruppenverwaltungNeuOutList.Add($outLine) + $lastLdap = $null + continue + } + if ($cols[2] -cne $lastLdap) + { + # first row of a GUIADGroup.LDAP block -> all columns + $DAWGruppenverwaltungNeuOutList.Add($outLine) + $lastLdap = $cols[2] + } + else + { + # subsequent row of the same block -> only GUIADGroup.Accounts.Add.LDAPs + $DAWGruppenverwaltungNeuOutList.Add(";;;;;" + $cols[5] + ";;;;") + } + } + $DAWGruppenAnlegenOutList | Out-File $DAWGruppenAnlegenOutFilePath -Encoding "utf8NoBom" -Append $DAWGruppenverwaltungOutList | Out-File $DAWGruppenverwaltungOutFilePath -Encoding "utf8NoBom" -Append $DAWGruppenverwaltungNeuOutList | Out-File $DAWGruppenverwaltungNeuOutFilePath -Encoding "utf8NoBom" -Append