$DAWGruppenAnlegenOutList = [System.Collections.Generic.List[string]]::new() $DAWGruppenverwaltungOutList = [System.Collections.Generic.List[string]]::new() $DAWGruppenverwaltungNeuOutList = [System.Collections.Generic.List[string]]::new() $KURSSollProfileOutList = [System.Collections.Generic.List[string]]::new() $KURSIstMitarbeiterProfileOutList = [System.Collections.Generic.List[string]]::new() function FinalizeADObjectsOutputs { $begin = Get-Date outLog "FinalizeADObjectsOutputs: sorting, deduplicating and writing output files" $ordinalComparer = [System.StringComparer]::Ordinal $DAWGruppenAnlegenOutList.Sort($ordinalComparer) $DAWGruppenverwaltungOutList.Sort($ordinalComparer) $KURSSollProfileOutList.Sort($ordinalComparer) $KURSIstMitarbeiterProfileOutList.Sort($ordinalComparer) removeDuplicatesFromSortedList $DAWGruppenAnlegenOutList "DAWGruppenAnlegenOutList" removeDuplicatesFromSortedList $DAWGruppenverwaltungOutList "DAWGruppenverwaltungOutList" removeDuplicatesFromSortedList $KURSSollProfileOutList "KURSSollProfileOutList" removeDuplicatesFromSortedList $KURSIstMitarbeiterProfileOutList "KURSIstMitarbeiterProfileOutList" $DAWGruppenverwaltungNeuOutList.Clear() $lastLdap = $null foreach ($outLine in $DAWGruppenverwaltungOutList) { $cols = $outLine.Split(";") if ([string]::IsNullOrEmpty($cols[5])) { $DAWGruppenverwaltungNeuOutList.Add($outLine) $lastLdap = $null continue } if ($cols[2] -cne $lastLdap) { $DAWGruppenverwaltungNeuOutList.Add($outLine) $lastLdap = $cols[2] } else { $DAWGruppenverwaltungNeuOutList.Add(";;;;;" + $cols[5] + ";;;;") } } $utf8NoBom = [System.Text.UTF8Encoding]::new($false) [System.IO.File]::AppendAllLines($DAWGruppenAnlegenOutFilePath, $DAWGruppenAnlegenOutList, $utf8NoBom) [System.IO.File]::AppendAllLines($DAWGruppenverwaltungOutFilePath, $DAWGruppenverwaltungOutList, $utf8NoBom) [System.IO.File]::AppendAllLines($DAWGruppenverwaltungNeuOutFilePath, $DAWGruppenverwaltungNeuOutList, $utf8NoBom) [System.IO.File]::AppendAllLines($KURSSollProfileOutFilePath, $KURSSollProfileOutList, $utf8NoBom) [System.IO.File]::AppendAllLines($KURSIstMitarbeiterProfileOutFilePath, $KURSIstMitarbeiterProfileOutList, $utf8NoBom) $end = Get-Date outLog ("finished: FinalizeADObjectsOutputs, used " + ($end - $begin)) } function ProcessADObjects { param ( [Parameter(Mandatory = $true, Position = 0)] $adObjectEntries, [Parameter(Mandatory = $true, Position = 1)] [String] $roletypeTag ) $begin = Get-Date outLog ("ProcessADObjects called at: " + $begin + $init) $adObjectEntries | Add-Member OldName "" $adObjectEntries | Add-Member GroupName "" $adObjectEntries | Add-Member GUIADGroupName "" $adObjectEntries | Add-Member GUIADGroupDisplayName "" $MitarbeiterEntries = Get-Content -Path $MitarbeiterInFilePath | ConvertFrom-Csv -Delimiter ";" $mitarbeiter_array = @{ "mitarbeiter" = "mitarbeiter" } $mitarbeiterStelle_array = @{ "mitarbeiter" = "stelle" } foreach ($item in $MitarbeiterEntries) { outLog ('foreach $item in $MitarbeiterEntries: ' + $item.'St.-Nr.') if ([System.String]::IsNullOrEmpty($item.Benutzerkennung)) { # outLogVerbose 'if ([System.String]::IsNullOrEmpty($item.Benutzerkennung)) -> true' continue } try { $mitarbeiter_array.Add($item.Benutzerkennung,([string]$item.Personalnummer).PadLeft(10, '0')) $oe = $item."OE-Schl$( [char]0x00fc )ssel" $stelle = ($item.'St.-Nr.').PadLeft(4, '0') $dum = $oe + "/" + $stelle $mitarbeiterStelle_array.Add($item.Benutzerkennung, $dum) } catch { writeExceptionInfo $_ -Rethrow } } $pkey_array = @{ "key" = 0 } $rbkey_array = @{ "key" = 0 } if ($roletypeTag -ieq $FI.TypeTagFilesystemAccess) { # outLogVerbose 'if ($roletypeTag -ieq $FI.TypeTagFilesystemAccess) -> true' try { $DirectoriesFilePath = $DirectoriesInFilePath $AnwendungenFilePath = $ApplicationsInFilePath $AnwendungenFilePathEntries = Import-Csv -Path $AnwendungenFilePath -Delimiter ";" $nummer_array = @{ "nummer" = "nummer" } foreach ($item in $AnwendungenFilePathEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagFilesystemAccess] foreach $item in $AnwendungenFilePathEntries: ' + $item.Verzeichnisname) if ([System.String]::IsNullOrEmpty($item.Verzeichnisname)) { # outLogVerbose 'if ([System.String]::IsNullOrEmpty($item.Verzeichnisname)) -> true' continue } try { $nummer_array[$item.Verzeichnisname] = $item.'Nr.' } catch { writeExceptionInfo $_ -Rethrow } } $header = "Verzeichnisname", "Normierter Pfad", "Verzeichnisart", "AWNR", "Anwendungskuerzel", "Gruppe Lesen", "Gruppe Aendern", "Verantwortlicher (Stelle oder Personalnummer)" $DirectoriesFilePathEntries = Get-Content -Path $DirectoriesFilePath | Select-Object -Skip 1 | ConvertFrom-Csv -Delimiter ";" -Header $header $art_array = @{ "art" = "art" } $path_array = @{ "path" = "path" } $endpunkt_array = @{ "endpunkt" = "endpunkt" } $verantwortlicher_array = @{ "verantwortlicher" = "verantwortlicher" } $dkz_array = @{ "kz" = "kz" } $dnummer_array = @{ "dnummer" = "dnummer" } $fullpath_array = @{ "fullpath" = "fullpath" } foreach ($item in $DirectoriesFilePathEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagFilesystemAccess] foreach $item in $DirectoriesFilePathEntries: ' + $item.Verzeichnisname) try { $art_array[$item.'Gruppe Lesen'] = $item.Verzeichnisart $path_array[$item.'Gruppe Lesen'] = $item.'Normierter Pfad' $verantwortlicher_array[$item.'Gruppe Lesen'] = $item.'Verantwortlicher (Stelle oder Personalnummer)' $dkz_array[$item.'Gruppe Lesen'] = $item.Anwendungskuerzel $dnummer_array[$item.'Gruppe Lesen'] = $item.AWNR $fullpath_array[$item.'Gruppe Lesen'] = $item.Verzeichnisname $verantwortlicher_array[$item.'Gruppe Aendern'] = $item.'Verantwortlicher (Stelle oder Personalnummer)' $dkz_array[$item.'Gruppe Aendern'] = $item.Anwendungskuerzel $dnummer_array[$item.'Gruppe Aendern'] = $item.AWNR $fullpath_array[$item.'Gruppe Aendern'] = $item.Verzeichnisname } catch { writeExceptionInfo $_ -Rethrow } try { $endpunkt_array[$item.'Gruppe Lesen'] = $item.Verzeichnisname } catch { writeExceptionInfo $_ -Rethrow } try { $art_array[$item.'Gruppe Aendern'] = $item.Verzeichnisart } catch { writeExceptionInfo $_ -Rethrow } try { $path_array[$item.'Gruppe Aendern'] = $item.'Normierter Pfad' $verantwortlicher_array[$item.'Gruppe Aendern'] = $item.'Verantwortlicher (Stelle oder Personalnummer)' } catch { writeExceptionInfo $_ -Rethrow } try { $endpunkt_array[$item.'Gruppe Aendern'] = $item.Verzeichnisname } catch { writeExceptionInfo $_ -Rethrow } } $FileSystemAccessEntries = Import-Csv -Path $FileSystemAccessTmpFilePath -Delimiter ";" $FileSystemAccessEntriesNew = [System.Collections.Generic.List[object]]::new() $key_array = @{ "key" = 0 } $avkey_array = @{ "key" = 0 } foreach ($item in $FileSystemAccessEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagFilesystemAccess] foreach $item in $FileSystemAccessEntries: ' + $item.Name) if ( $item.Name.Contains("GGF-VDA-")) { # outLogVerbose 'if ($item.Name.Contains("GGF-VDA-")) -> true' continue } $DisplayName = $item.ShortCut + $item.Name.Substring($item.Name.IndexOf('-') + 1) $TempString = $item.Name.Split('-') $EndString = "" if ( $item.Name.EndsWith("_L")) { # outLogVerbose 'if ($item.Name.EndsWith("_L")) -> true' $EndString = "_L" } elseif ($item.Name.EndsWith("_A")) { # outLogVerbose 'elseif ($item.Name.EndsWith("_A")) -> true' $EndString = "_A" } else { # outLogVerbose 'else -> true (if/elseif ($item.Name.EndsWith("_A")) -> false)' $EndString = "_X" } $NewShortName = "" $V = "" $V = $art_array.Item($item.Name) + "_" if ($art_array.Item($item.Name) -ieq "FAC123") { # outLogVerbose 'if ($art_array.Item($item.Name) -ieq "FAC123") -> true' $V = "FAC_" $V = "" } elseif ($art_array.Item($item.Name) -ieq "AUS123") { # outLogVerbose 'elseif ($art_array.Item($item.Name) -ieq "AUS123") -> true' $V = "AUS_" $V = "" } elseif ($art_array.Item($item.Name) -ieq "PKU123") { # outLogVerbose 'elseif ($art_array.Item($item.Name) -ieq "PKU123") -> true' $V = "PKU_" $V = "" } elseif ($art_array.Item($item.Name) -ieq "SON123") { # outLogVerbose 'elseif ($art_array.Item($item.Name) -ieq "SON123") -> true' $V = "SON_" $V = "" } elseif ($art_array.Item($item.Name) -ieq "UBE123") { # outLogVerbose 'elseif ($art_array.Item($item.Name) -ieq "UBE123") -> true' $V = "UBE_" $V = "" } elseif ($art_array.Item($item.Name) -ieq "UNT123") { # outLogVerbose 'elseif ($art_array.Item($item.Name) -ieq "UNT123") -> true' $V = "UNT_" $V = "" } elseif ($art_array.Item($item.Name) -ieq "VAW123") { # outLogVerbose 'elseif ($art_array.Item($item.Name) -ieq "VAW123") -> true' $V = "VAW_" $AWNRNEW = "9997" $DKZ = "XXXXX" try { $AWNRNEW = $dnummer_array.Item($item.Name).PadLeft(4, '0') if (-not $AWNRNEW) { # outLogVerbose 'if (-not $AWNRNEW) -> true' $AWNRNEW = "9997" } } catch { writeExceptionInfo $_ -Rethrow } try { $DKZ = $dkz_array.Item($item.Name) if (-not $DKZ) { # outLogVerbose 'if (-not $DKZ) -> true' $DKZ = "XXXXX" } } catch { writeExceptionInfo $_ -Rethrow } $V = "VAW_" + $AWNRNEW + "_" + $path_array.Item($item.Name) + $EndString $VDUM = $V.Replace("_VR_", "_") $V = $VDUM } if ( $art_array.Contains($item.Name)) { # outLogVerbose 'if ($art_array.Contains($item.Name)) -> true' if ($art_array.Item($item.Name) -ieq "Programm-Ablage") { # outLogVerbose 'if ($art_array.Item($item.Name) -ieq "Programm-Ablage") -> true' $NewShortName = $V } elseif ($art_array.Item($item.Name) -ieq "VAW") { # outLogVerbose 'elseif ($art_array.Item($item.Name) -ieq "VAW") -> true' $NewShortName = $V } elseif ($art_array.Item($item.Name) -ieq "PRG") { # outLogVerbose 'elseif ($art_array.Item($item.Name) -ieq "PRG") -> true' try { $AWNRNEW = $dnummer_array.Item($item.Name).PadLeft(4, '0') if (-not $AWNRNEW) { # outLogVerbose 'if (-not $AWNRNEW) -> true' $AWNRNEW = "9998" } } catch { $AWNRNEW = "9998" writeExceptionInfo $_ -Rethrow } $NewShortName = "PRG_" + ([string]$AWNRNEW).PadLeft(4, '0') + "_" + $path_array.Item($item.Name) + $EndString } else { # outLogVerbose 'else -> true (if/elseif ($art_array.Item($item.Name) -ieq "PRG") -> false)' $NewShortName = $V + $path_array.Item($item.Name) + $EndString } } else { # outLogVerbose 'else -> true (if/elseif ($art_array.Contains($item.Name)) -> false)' $test = $item.Name.Substring(0, $item.Name.Length - 2) if ( $key_array.ContainsKey($test)) { # outLogVerbose 'if ($key_array.ContainsKey($test)) -> true' } else { # outLogVerbose 'else -> true (if/elseif ($key_array.ContainsKey($test)) -> false)' $cntNichtGelistet++ $key_array.Add($test, $cntNichtGelistet) } $NewShortName = "VX_" + "nicht" + "_" + "gelistet" + "_" + $key_array.Item($test) + $EndString } $NewFullName = $Institut + "GGX-" + $NewShortName $Description = $item.Description if ( $Description.Contains("## keine Beschreibung ##")) { # outLogVerbose 'if ($Description.Contains("## keine Beschreibung ##")) -> true' $VA = $verantwortlicher_array.Item($item.Name) $Description = $Description + " Verantwortlicher: " + $VA } $FileSystemAccessEntriesNew.Add(@{ GUIMandator = $Institut; 'GUIADGroup.Name' = $NewFullName; 'GUIADGroup.Description' = $item.Description; GUIMandatorADGroupType = "Role"; 'GUIADGroup.DisplayName' = $NewShortName; GUIProcessingNote = ""; OldName = $item.Name }) $DAWGruppenAnlegenOutLine = $Institut + ";" + $NewFullName.Replace("-SE_", "-VSE_") + ";" + $Description + ";" + 'Role' + ";" + $NewShortName + ";;" + $item.Name $DAWGruppenAnlegenOutList.Add($DAWGruppenAnlegenOutLine) } $i = 1 $CntPRG = 0000000 $CntSON = 0100000 $CntSKL = 0200000 $CntSPK = 0300000 $CntVRZ = 0400000 $CntVOE = 0500000 $CntAKT = 0600000 $CntMSV = 0700000 $CntPRO = 0800000 foreach ($item in $FileSystemAccessEntriesNew) { outLog ('[$roletypeTag -ieq $FI.TypeTagFilesystemAccess] foreach $item in $FileSystemAccessEntriesNew: ' + $item.OldName) $roleType = "unknown" $relevantRoleTypes = $SPK.GroupManagementMappings | Where-Object { $_.OU -ieq $FI.TypeTagFilesystemAccess } | Sort-Object { [int]$_.Order } foreach ($relevantRoleType in $relevantRoleTypes) { # outLogVerbose 'foreach $relevantRoleType in $relevantRoleTypes:' $relevantRoleType.TypeName if ($item.OldName -cmatch $relevantRoleType.TagRegExp) { # outLogVerbose 'if ($item.OldName -cmatch $relevantRoleType.TagRegExp) -> true' $roleType = $relevantRoleType.TypeName break } } $DAWGruppenverwaltungOutLine = $Institut + ";" + $roleType + ";" + $item.OldName + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) $NewFullName = $item.'GUIADGroup.Name' $ProfilNummer = 0 $ProfilName = "" $VerzeichnisArt = $art_array.Item($item.OldName) try { $MYANR = $dnummer_array.Item($item.OldName) $DKZ = $dkz_array.Item($item.OldName) if (-not $DKZ) { # outLogVerbose 'if (-not $DKZ) -> true' $MYANR = "9997" } } catch { $MYANR = "9997" writeExceptionInfo $_ -Rethrow } $FullPath = $fullpath_array.Item($item.OldName) $AWNRNEW = "9997" $EndString = "" try { $AWNRNEW = $dnummer_array.Item($item.OldName).PadLeft(4, '0') if (-not $AWNRNEW) { # outLogVerbose 'if (-not $AWNRNEW) -> true' $AWNRNEW = "9998" } } catch { $AWNRNEW = "9998" writeExceptionInfo $_ -Rethrow } if ($VerzeichnisArt -ieq "SKL") { # outLogVerbose 'if ($VerzeichnisArt -ieq "SKL") -> true' $ProfilNummer = "42" + ([string]$CntSKL).PadLeft(7, '0') $CntSKL++ $ProfilName = "SKL " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf SKL aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf SKL lesen " + $NewFullName } } elseif ($VerzeichnisArt -ieq "SON") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "SON") -> true' $ProfilNummer = "42" + ([string]$CntSON).PadLeft(7, '0') $CntSON++ $ProfilName = "SON " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf SON aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf SON lesen " + $NewFullName } } elseif ($VerzeichnisArt -ieq "AKT") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "AKT") -> true' $ProfilNummer = "42" + ([string]$CntAKT).PadLeft(7, '0') $CntAKT++ $ProfilName = "AKT " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf AKT aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf AKT lesen " + $NewFullName } } elseif ($VerzeichnisArt -ieq "MSV") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "MSV") -> true' $ProfilNummer = "42" + ([string]$CntMSV).PadLeft(7, '0') $CntMSV++ $ProfilName = "MSV " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf MSV aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf MSV lesen " + $NewFullName } } elseif ($VerzeichnisArt -ieq "PRO") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "PRO") -> true' $ProfilNummer = "42" + ([string]$CntPRO).PadLeft(7, '0') $CntPRO++ $ProfilName = "PRO " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf PRO aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf PRO lesen " + $NewFullName } } elseif ($VerzeichnisArt -ieq "SPK") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "SPK") -> true' $ProfilNummer = "42" + ([string]$CntSPK).PadLeft(7, '0') $CntSPK++ $ProfilName = "SPK " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf SPK aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf SPK lesen " + $NewFullName } } elseif ($VerzeichnisArt -ieq "VRZ") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "VRZ") -> true' $ProfilNummer = "42" + ([string]$CntVRZ).PadLeft(7, '0') $CntVRZ++ $ProfilName = "VRZ " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf VRZ aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf VRZ lesen " + $NewFullName } } elseif ($VerzeichnisArt -ieq "VOE") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "VOE") -> true' $ProfilNummer = "42" + ([string]$CntVOE).PadLeft(7, '0') $CntVOE++ $ProfilName = "VOE " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf VOE aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf VOE lesen " + $NewFullName } } elseif ($VerzeichnisArt -ieq "PRG") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "PRG") -> true' if ($AWNRNEW -ieq "9997") { # outLogVerbose 'if ($AWNRNEW -ieq "9997") -> true' $ProfilNummer = "42" + ([string]$CntPRG).PadLeft(7, '0') $CntPRG++ } elseif ($AWNRNEW -ieq "0000") { # outLogVerbose 'elseif ($AWNRNEW -ieq "0000") -> true' $ProfilNummer = "42" + ([string]$CntPRG).PadLeft(7, '0') $CntPRG++ } else { # outLogVerbose 'else -> true (if/elseif ($AWNRNEW -ieq "0000") -> false)' if ( $rbkey_array.ContainsKey("PAN_" + $AWNRNEW)) { # outLogVerbose 'if ($rbkey_array.ContainsKey("PAN_" + $AWNRNEW)) -> true' $rbkey_array.Item("PAN_" + $AWNRNEW)++ } else { # outLogVerbose 'else -> true (if/elseif ($rbkey_array.ContainsKey("PAN_" + $AWNRNEW)) -> false)' $rbkey_array.Add("PAN_" + $AWNRNEW, 200) } $ProfilNummer = "40" + ([string]$AWNRNEW).PadLeft(4, '0') + $rbkey_array.Item("PAN_" + $AWNRNEW) } $NewFullName = $NewFullName.Replace("PRG_", "PRG_") $ProfilName = "SIA " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf SIA aendern " + $NewFullName.Replace($SPKID + "GGX-", "") } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf SIA lesen " + $NewFullName.Replace($SPKID + "GGX-", "") } } elseif ($VerzeichnisArt -ieq "PRG12") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "PRG12") -> true' $ProfilNummer = "42" + ([string]$CntPRG).PadLeft(7, '0') $CntPRG++ $ProfilName = "PROG " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf PRG aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf PRG lesen " + $NewFullName } } elseif ($VerzeichnisArt -ieq "VRZ") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "VRZ") -> true' $ProfilNummer = "42" + ([string]$CntVRZ).PadLeft(7, '0') $CntVRZ++ $ProfilName = "VRZ " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf VRZ aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf VRZ lesen " + $NewFullName } } elseif ($VerzeichnisArt -ieq "SPK") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "SPK") -> true' $ProfilNummer = "42" + ([string]$CntSPK).PadLeft(7, '0') $CntSPK++ $ProfilName = "SPK " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf SPK aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf SPK lesen " + $NewFullName } } elseif ($VerzeichnisArt -ieq "PROG1") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "PROG1") -> true' $ProfilNummer = $CntProgramm $CntProgramm++ $ProfilName = "Anwendungsverzeichnis " + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf Programm aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf Programm lesen " + $NewFullName } $AWNRNEW = "9997" $EndString = "" try { $AWNRNEW = $dnummer_array.Item($item.OldName).PadLeft(4, '0') if (-not $AWNRNEW) { # outLogVerbose 'if (-not $AWNRNEW) -> true' $AWNRNEW = "9997" } } catch { } try { $DKZ = $dkz_array.Item($item.OldName) if (-not $DKZ) { # outLogVerbose 'if (-not $DKZ) -> true' $DKZ = "XXXXX" } $bla = $NewFullName.Replace("-AV_", "-AZ_") $NewFullName = $bla.Substring(7) } catch { writeExceptionInfo $_ -Rethrow } if ( $pkey_array.ContainsKey("PAN_" + $AWNRNEW)) { # outLogVerbose 'if ($pkey_array.ContainsKey("PAN_" + $AWNRNEW)) -> true' $pkey_array.Item("PAN_" + $AWNRNEW)++ } else { # outLogVerbose 'else -> true (if/elseif ($pkey_array.ContainsKey("PAN_" + $AWNRNEW)) -> false)' $pkey_array.Add("PAN_" + $AWNRNEW, 1) } $ProfilNummer = "10" + $AWNRNEW + "" + ([string]$pkey_array.Item("PAN_" + $AWNRNEW)).PadLeft(3, '0') } elseif ($VerzeichnisArt -ieq "AW") { # outLogVerbose 'elseif ($VerzeichnisArt -ieq "AW") -> true' if ( $avkey_array.ContainsKey("AV_" + $MYANR)) { # outLogVerbose 'if ($avkey_array.ContainsKey("AV_" + $MYANR)) -> true' $avkey_array.Item("AV_" + $MYANR)++ } else { # outLogVerbose 'else -> true (if/elseif ($avkey_array.ContainsKey("AV_" + $MYANR)) -> false)' $avkey_array.Add("AV_" + $MYANR, 1) } $ProfilNummer = "40" + $MYANR.PadLeft(4, '0') + ([string]$avkey_array.Item("AV_" + $MYANR)).PadLeft(3, '0') $CntAv++ $ProfilName = "AW_" + $NewFullName if ( $NewFullName.EndsWith("_A")) { # outLogVerbose 'if ($NewFullName.EndsWith("_A")) -> true' $ProfilName = "Zugriff auf Anwendungsverzeichnisse aendern " + $NewFullName } elseif ($NewFullName.EndsWith("_L")) { # outLogVerbose 'elseif ($NewFullName.EndsWith("_L")) -> true' $ProfilName = "Zugriff auf Anwendungsverzeichnisse lesen " + $NewFullName } } else { # outLogVerbose 'else -> true (if/elseif ($VerzeichnisArt -ieq "AW") -> false)' try { $ProfilNummer = "97000" + ([string]$CntElse).PadLeft(4, '0') } catch { $ProfilNummer = "97000" + ([string]$CntElse).PadLeft(4, '0') writeExceptionInfo $_ -Rethrow } $CntElse++ $ProfilName = "Unbekannte-Ablage " + $NewFullName } $dum = $verantwortlicher_array.Item($item.OldName) if ($dum) { # outLogVerbose 'if ($dum) -> true' if ( $dum.StartsWith("S" + $SPKNO)) { # outLogVerbose 'if ($dum.StartsWith("S" + $SPKNO)) -> true' $dum = $mitarbeiterStelle_array.Item($verantwortlicher_array.Item($item.OldName)) } } else { # outLogVerbose 'else -> true (if/elseif ($dum) -> false)' $dum = "0570000/0012" } $KURSSollProfileOutLine = ($ProfilNummer).ToString() + ";" + $NewFullName.Replace($SPKID + "GGX-", "").Replace("_1552_", "_AD_") + ";" + $ProfilName.Replace("-AZ_", "-AV_") + ";" + $dum + ";" + $item.OldName + ";" + "Verzeichnispfad: " + $FullPath + ";" + $VerzeichnisArt $KURSSollProfileOutList.Add($KURSSollProfileOutLine) foreach ($item1 in $ADObjectMemberships) { # outLogVerbose 'foreach $item1 in $ADObjectMemberships:' $item1.GroupName if ($item1.GroupName -ieq $item.OldName) { # outLogVerbose 'if ($item1.GroupName -ieq $item.OldName) -> true' if ($item1.MemberClass -ieq "user") { # outLogVerbose 'if ($item1.MemberClass -ieq "user") -> true' $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $item1.MemberName + ";" + "" + ";" + "" + ";" + "user" + ";" + "" $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) $dum = $mitarbeiter_array.Item($item1.MemberName) if (-not $dum) { # outLogVerbose 'if (-not $dum) -> true' $dum = $item1.MemberName } $KURSIstMitarbeiterProfileOutLine = $dum + ";" + $item.OldName + ";" + ($ProfilNummer).ToString() + ";" + "FileSystemAccess" $KURSIstMitarbeiterProfileOutList.Add($KURSIstMitarbeiterProfileOutLine) } elseif ($item1.MemberClass -ieq "group") { # outLogVerbose 'elseif ($item1.MemberClass -ieq "group") -> true' $users = getUsersByMemberGroup $item1.MemberName foreach ($u in $users) { # outLogVerbose 'foreach $u in $users:' $u.MemberName $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("-SE_", "-VSE_") + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $u.MemberName + ";" + "" + ";" + "" + ";" + "group" + ";" + $item1.MemberName $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) } } } } $i++ } } catch { writeExceptionInfo $_ -Rethrow } } elseif ($roletypeTag -ieq $FI.TypeTagAppAccess) { # outLogVerbose 'elseif ($roletypeTag -ieq $FI.TypeTagAppAccess) -> true' try { $AnwendungenFilePath = $ApplicationsInFilePath $AnwendungenFilePathEntries = Import-Csv -Path $AnwendungenFilePath -Delimiter ";" $nummer_array = @{ "nummer" = "nummer" } $verantwortlicher_array = @{ "verantwortlicher" = "verantwortlicher" } $kz_array = @{ "kz" = "kz" } $beschreibung_array = @{ "beschreibung" = "beschreibung" } $Verantwortlicher $MyKey foreach ($item in $AnwendungenFilePathEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagAppAccess] foreach $item in $AnwendungenFilePathEntries: ' + $item.'Nr.') $Verantwortlicher = $item.'Verantwortlicher (FPV)' if (-not $Verantwortlicher) { # outLogVerbose 'if (-not $Verantwortlicher) -> true' $Verantwortlicher = "0570000/0012" } else { # outLogVerbose 'else -> true (if/elseif (-not $Verantwortlicher) -> false)' if ( $Verantwortlicher.StartsWith("S" + $SPKNO)) { # outLogVerbose 'if ($Verantwortlicher.StartsWith("S" + $SPKNO)) -> true' $dum = $mitarbeiterStelle_array.Item($Verantwortlicher) $Verantwortlicher = $dum } } if ([string]::IsNullOrWhiteSpace($item.FullAccount)) { outLog ("WARNING: skipping malformed Anwendungen row (empty FullAccount), Nr.='" + $item.'Nr.' + "', Name='" + $item.Name + "'") continue } $MyKey = $item.FullAccount.Split('\') if ($MyKey[1]) { # outLogVerbose 'if ($MyKey[1]) -> true' if (-not $nummer_array.ContainsKey($MyKey[1])) { # outLogVerbose 'if (-not $nummer_array.ContainsKey($MyKey[1])) -> true' $nummer_array[$MyKey[1]] = $item.'Nr.' $verantwortlicher_array[$MyKey[1]] = $Verantwortlicher $kz_array[$MyKey[1]] = $item.'AWK' $beschreibung_array[$MyKey[1]] = $item.'Beschreibung (256 Zeichen)' } } } $AppAccessEntries = Import-Csv -Path $AppAccessTmpFilePath -Delimiter ";" $AppAccessEntriesNew = [System.Collections.Generic.List[object]]::new() foreach ($item in $AppAccessEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagAppAccess] foreach $item in $AppAccessEntries: ' + $item.Name) $AWNR = $nummer_array.Item($item.Name) if (-not $AWNR) { # outLogVerbose 'if (-not $AWNR) -> true' $AWNR = 9000 } $AWNR = ([string]$AWNR).PadLeft(4, '0') $ShortCut = "AZ_" if ( $item.Name.Contains("GGF-")) { # outLogVerbose 'if ($item.Name.Contains("GGF-")) -> true' $ShortCut = "AZ_" } $NewShortName = $ShortCut + $AWNR + "_" + $item.Name.Substring($item.Name.IndexOf('-') + 1) $NewFullName = $Institut + "GGX-" + $NewShortName.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") $AppAccessEntriesNew.Add(@{ GUIMandator = $Institut; 'GUIADGroup.Name' = $NewFullName; 'GUIADGroup.Description' = $item.Description; GUIMandatorADGroupType = "Role"; 'GUIADGroup.DisplayName' = $NewShortName.Replace("Serviceportal", "SVP"); GUIProcessingNote = ""; OldName = $item.Name }) $DAWGruppenAnlegenOutLine = $Institut + ";" + $NewFullName.Replace("-SE_", "-VSE_") + ";" + $item.Description + ";" + 'Role' + ";" + $NewShortName + ";;" + $item.Name $DAWGruppenAnlegenOutList.Add($DAWGruppenAnlegenOutLine) } $i = 1 $ProfilNummerAZ = 1 $ProfilNummerAV = 1 foreach ($item in $AppAccessEntriesNew) { outLog ('[$roletypeTag -ieq $FI.TypeTagAppAccess] foreach $item in $AppAccessEntriesNew: ' + $item.OldName) $roleType = "unknown" $relevantRoleTypes = $SPK.GroupManagementMappings | Where-Object { $_.OU -ieq $FI.TypeTagAppAccess } | Sort-Object { [int]$_.Order } foreach ($relevantRoleType in $relevantRoleTypes) { # outLogVerbose 'foreach $relevantRoleType in $relevantRoleTypes:' $relevantRoleType.TypeName if ($item.OldName -cmatch $relevantRoleType.TagRegExp) { # outLogVerbose 'if ($item.OldName -cmatch $relevantRoleType.TagRegExp) -> true' $roleType = $relevantRoleType.TypeName break } } if ($item.OldName -like "*GGT-0-*") { # outLogVerbose 'if ($item.OldName -like "*GGT-0-*") -> true' $roleType = "ApplicationSIA" } $DAWGruppenverwaltungOutLine = $Institut + ";" + $roleType + ";" + $item.OldName + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) $ProfilNummer = "" $NeueBeschreibung = "" if ($item.'GUIADGroup.Name' -like "*GGX-A_*") { # outLogVerbose 'if ($item.''GUIADGroup.Name'' -like "*GGX-A_*") -> true' $PnrStr = ([string]$ProfilNummerAZ).PadLeft(3, '0') $AWNR = ([string]$nummer_array.Item($item.OldName)).PadLeft(4, '0') $ProfilName = "Anwendungszugriff " + $item.'GUIADGroup.Name' $dum = $verantwortlicher_array.Item($item.OldName) $kz = $kz_array.Item($item.OldName) $NeueBeschreibung = $beschreibung_array.Item($item.OldName) $aname = $item.'GUIADGroup.Name'.Substring(15) if ($dum) { # outLogVerbose 'if ($dum) -> true' if ($dum.StartsWith("S" + $SPKNO)) { # outLogVerbose 'if ($dum.StartsWith("S" + $SPKNO)) -> true' $dum = $mitarbeiterStelle_array.Item($verantwortlicher_array.Item($item.OldName)) } } else { # outLogVerbose 'else -> true (if/elseif ($dum) -> false)' $dum = "0570000/0012" } if ( $pkey_array.ContainsKey("PAZ_" + $AWNR)) { # outLogVerbose 'if ($pkey_array.ContainsKey("PAZ_" + $AWNR)) -> true' $pkey_array.Item("PAZ_" + $AWNR)++ } else { # outLogVerbose 'else -> true (if/elseif ($pkey_array.ContainsKey("PAZ_" + $AWNR)) -> false)' $pkey_array.Add("PAZ_" + $AWNR, 1000) } if ($AWNR -ieq "0000") { # outLogVerbose 'if ($AWNR -ieq "0000") -> true' $AWNR = "9000" } $ProfilNummerAZ++ $KURSSollProfileOutLine = "40" + $AWNR + "" + ($PnrStr).ToString() + ";" + "AZ_" + $AWNR + "_" + $aname + ";" + $ProfilName.Replace($SPKID + "GGX-", "").Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + $dum + ";" + $item.OldName + ";" + $item.'GUIADGroup.Description' + ";Mist" $KURSSollProfileOutList.Add($KURSSollProfileOutLine) $ProfilNummer = "10" + $AWNR + "" + ($PnrStr).ToString() $ProfilNummerAZ++ } else { # outLogVerbose 'else -> true (if/elseif ($item.''GUIADGroup.Name'' -like "*GGX-A_*") -> false)' $AWK = "1" $PnrStr = ([string]$ProfilNummerAV).PadLeft(3, '0') $AWNR = ([string]$nummer_array.Item($item.OldName)).PadLeft(4, '0') $AWK = ([string]$kz_array.Item($item.OldName)).PadLeft(5, '0') $dum = $verantwortlicher_array.Item($item.OldName) $kz = $kz_array.Item($item.OldName) $NeueBeschreibung = $beschreibung_array.Item($item.OldName) $aname = $item.'GUIADGroup.Name'.Substring(15) if (-not $NeueBeschreibung) { # outLogVerbose 'if (-not $NeueBeschreibung) -> true' $ProfilName = "Anwendungszugriff " + $item.'GUIADGroup.Name' } else { # outLogVerbose 'else -> true (if/elseif (-not $NeueBeschreibung) -> false)' $ProfilName = $NeueBeschreibung } if ($dum) { # outLogVerbose 'if ($dum) -> true' if ($dum.StartsWith("S" + $SPKNO)) { # outLogVerbose 'if ($dum.StartsWith("S" + $SPKNO)) -> true' $dum = $mitarbeiterStelle_array.Item($verantwortlicher_array.Item($item.OldName)) } } else { # outLogVerbose 'else -> true (if/elseif ($dum) -> false)' $dum = "0570000/0012" } if (-not $kz) { # outLogVerbose 'if (-not $kz) -> true' $kz = "XXXXX" } if ( $pkey_array.ContainsKey("PAZ_" + $AWNR)) { # outLogVerbose 'if ($pkey_array.ContainsKey("PAZ_" + $AWNR)) -> true' $pkey_array.Item("PAZ_" + $AWNR)++ } else { # outLogVerbose 'else -> true (if/elseif ($pkey_array.ContainsKey("PAZ_" + $AWNR)) -> false)' $pkey_array.Add("PAZ_" + $AWNR, 100) } $PnrStr = ([string]$pkey_array.Item("PAZ_" + $AWNR)).PadLeft(3, '0') $NNNAME = "AZ_" + $AWNR + $aname if ($AWNR -ieq "0000") { # outLogVerbose 'if ($AWNR -ieq "0000") -> true' $AWNR = "9998" } $MYDESC007 = $ProfilName.Replace($SPKID + "GGX-", "").Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") $KURSSollProfileOutLine = "40" + $AWNR + "" + ($PnrStr).ToString() + ";" + $NNNAME.Replace("-_", "-") + ";" + $MYDESC007 + ";" + $dum + ";" + $item.OldName + ";" + $MYDESC007 + ". AD Beschreibung:" + $item.'GUIADGroup.Description' + ";AppAccess" $KURSSollProfileOutList.Add($KURSSollProfileOutLine) $ProfilNummer = "10" + $AWNR + "" + ($PnrStr).ToString() $ProfilNummerAV++ } foreach ($item1 in $ADObjectMemberships) { # outLogVerbose 'foreach $item1 in $ADObjectMemberships:' $item1.GroupName if ($item1.GroupName -ieq $item.OldName) { # outLogVerbose 'if ($item1.GroupName -ieq $item.OldName) -> true' if ($item1.MemberClass -ieq "user") { # outLogVerbose 'if ($item1.MemberClass -ieq "user") -> true' $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $item1.MemberName + ";" + "" + ";" + "" + ";" + "user" + ";" + $item.OldName $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) $dum = $mitarbeiter_array.Item($item1.MemberName) if (-not $dum) { # outLogVerbose 'if (-not $dum) -> true' $dum = $item1.MemberName } $KURSIstMitarbeiterProfileOutLine = $dum + ";" + $item.OldName + ";" + ($ProfilNummer).ToString() + ";" + "AppAccess" $KURSIstMitarbeiterProfileOutList.Add($KURSIstMitarbeiterProfileOutLine) } elseif ($item1.MemberClass -ieq "group") { # outLogVerbose 'elseif ($item1.MemberClass -ieq "group") -> true' $users = getUsersByMemberGroup $item1.MemberName foreach ($u in $users) { # outLogVerbose 'foreach $u in $users:' $u.MemberName $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $item.'GUIADGroup.Name'.Replace("Serviceportal", "SVP").Replace("Anforderungsmanagementberichte", "Anforderungsmgtberichte") + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $u.MemberName + ";" + "" + ";" + "" + ";" + "group" + ";" + $item.OldName $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) } } } } $i++ } } catch { writeExceptionInfo $_ -Rethrow } } elseif ($roletypeTag -ieq $FI.TypeTagAppConfiguration) { # outLogVerbose 'elseif ($roletypeTag -ieq $FI.TypeTagAppConfiguration) -> true' foreach ($adObjectEntry in $adObjectEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagAppConfiguration] foreach $adObjectEntry in $adObjectEntries: ' + $adObjectEntry.ObjectName) $DisplayName = $adObjectEntry.ShortCut + $adObjectEntry.ObjectName.Substring($adObjectEntry.ObjectName.IndexOf('-') + 1) $TempString = $adObjectEntry.ObjectName.Split('-') $adObjectEntry.GroupName = $TempString[0] + '-' + $DisplayName $NewFullName = $Institut + "GGX-" + $DisplayName.Replace("OFK", "OFFK").Replace("IEK", "IntExK").Replace("WEB_EDGE", "WEB_MEDGE") if ( $NewFullName.Contains("IntExK")) { # outLogVerbose 'if ($NewFullName.Contains("IntExK")) -> true' continue } if ($DisplayName -eq "AK_WEB_SSKMG-STD") { # outLogVerbose 'if ($DisplayName -eq "AK_WEB_SSKMG-STD") -> true' $NewFullName = $Institut + "GGX-AKW_WEB_SSKMG-STD" } if ($DisplayName -eq "AK_IEK_Admins") { # outLogVerbose 'if ($DisplayName -eq "AK_IEK_Admins") -> true' $NewFullName = $Institut + "GGX-AKE_IntExK_Admins" } if ($DisplayName -eq "AK_OFK_Office_Default") { # outLogVerbose 'if ($DisplayName -eq "AK_OFK_Office_Default") -> true' $NewFullName = $Institut + "GGX-AKO_OFFK_Office_Default" } if ($DisplayName -eq "AK_WEB_IE_ALT_Videoueberwachung") { # outLogVerbose 'if ($DisplayName -eq "AK_WEB_IE_ALT_Videoueberwachung") -> true' $NewFullName = $Institut + "GGX-AKW_WEB_IE_ALT_Videoueberwachung" } if ($DisplayName -eq "AK_WEB_OhneIntranet") { # outLogVerbose 'if ($DisplayName -eq "AK_WEB_OhneIntranet") -> true' $NewFullName = $Institut + "GGX-AKW_WEB_OhneIntranet" } $adObjectEntry.OldName = $adObjectEntry.ObjectName $adObjectEntry.GUIADGroupName = $adObjectEntry.ObjectName $adObjectEntry.GUIADGroupDisplayName = $DisplayName $DAWGruppenAnlegenOutLine = $Institut + ";" + $NewFullName + ";" + $adObjectEntry.Description + ";" + 'Role' + ";" + $DisplayName.Replace("OFK", "OFFK").Replace("IEK", "IntExK").Replace("WEB_EDGE", "WEB_MEDGE") + ";" + "" + ";" + $adObjectEntry.ObjectName $DAWGruppenAnlegenOutList.Add($DAWGruppenAnlegenOutLine) } $i = 1 $PNR = 1000000 $DUMPNR = 410000000 $MPNR = 0 foreach ($adObjectEntry in $adObjectEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagAppConfiguration] foreach $adObjectEntry in $adObjectEntries: ' + $adObjectEntry.ObjectName) $DisplayName = $adObjectEntry.ShortCut + $adObjectEntry.ObjectName.Substring($adObjectEntry.ObjectName.IndexOf('-') + 1) $TempString = $adObjectEntry.ObjectName.Split('-') $adObjectEntry.GroupName = $TempString[0] + '-' + $DisplayName $NewFullName = $Institut + $DisplayName if ($DisplayName -eq "AK_WEB_SSKMG-STD") { # outLogVerbose 'if ($DisplayName -eq "AK_WEB_SSKMG-STD") -> true' $NewFullName = $Institut + "GGX-AKW_WEB_SSKMG-STD" $MPNR = 500000001 } elseif ($DisplayName -eq "AK_IEK_Admins") { # outLogVerbose 'elseif ($DisplayName -eq "AK_IEK_Admins") -> true' $NewFullName = $Institut + "GGX-AKE_IntExK_Admins" $MPNR = 500000002 } elseif ($DisplayName -eq "AK_OFK_Office_Default") { # outLogVerbose 'elseif ($DisplayName -eq "AK_OFK_Office_Default") -> true' $NewFullName = $Institut + "GGX-AKO_OFFK_Office_Default" $MPNR = 500000003 } elseif ($DisplayName -eq "AK_WEB_IE_ALT_Videoueberwachung") { # outLogVerbose 'elseif ($DisplayName -eq "AK_WEB_IE_ALT_Videoueberwachung") -> true' $NewFullName = $Institut + "GGX-AKW_WEB_IE_ALT_Videoueberwachung" $MPNR = 500000004 } elseif ($DisplayName -eq "AK_WEB_OhneIntranet") { # outLogVerbose 'elseif ($DisplayName -eq "AK_WEB_OhneIntranet") -> true' $NewFullName = $Institut + "GGX-AKW_WEB_OhneIntranet" $MPNR = 500000005 } else { # outLogVerbose 'else -> true (if/elseif ($DisplayName -eq "AK_WEB_OhneIntranet") -> false)' $NewFullName = $DisplayName $MPNR = $DUMPNR } $roleType = getRoleType $adObjectEntry $roletypeTag $DAWGruppenverwaltungOutLine = $Institut + ";" + $roleType + ";" + $adObjectEntry.OldName + ";" + $NewFullName + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) $userMemberShips = @(getAllUserMemberships $adObjectEntry) $NewFullName1 = $NewFullName $StelleVerant = "0570000/0012" $KURSSollProfileOutLine = "" + $MPNR + ";" + $NewFullName1.Replace($SPKID + "GGX-", "") + ";" + "Anwendungskonfiguration " + $NewFullName1 + ";" + $StelleVerant + ";" + $adObjectEntry.OldName + ";" + $item.'GUIADGroup.Description' + ";AK" $KURSSollProfileOutList.Add($KURSSollProfileOutLine) $PNR++ $DUMPNR++ foreach ($userMemberShip in $userMemberShips) { # outLogVerbose 'foreach $userMemberShip in $userMemberShips:' $userMemberShip.MemberName $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $NewFullName + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName + ";" + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) $persnr = "0000000000" $ProfilNR = "" + $DUMPNR if ($userMemberShip.Origin -ieq "user") { # outLogVerbose 'if ($userMemberShip.Origin -ieq "user") -> true' try { $persnr = $mitarbeiter_array.Item($userMemberShip.MemberName) $dum = $mitarbeiter_array.Item($userMemberShip.MemberName) if (-not $dum) { # outLogVerbose 'if (-not $dum) -> true' $dum = $userMemberShip.MemberName } $persnr = $dum } catch { outLog "User nicht gefunden: " $u.MemberName writeExceptionInfo $_ -Rethrow } $KURSIstMitarbeiterProfileOutLine = $persnr + ";" + $adObjectEntry.OldName + ";" + $ProfilNR + ";" + "AppConfiguration" $KURSIstMitarbeiterProfileOutList.Add($KURSIstMitarbeiterProfileOutLine) } } $i++ } } elseif ($roletypeTag -ieq $FI.TypeTagOrganisation) { # outLogVerbose 'elseif ($roletypeTag -ieq $FI.TypeTagOrganisation) -> true' $i = 1 $ProfilNummer = 1 $ProfilNR = 440000000 foreach ($adObjectEntry in $adObjectEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagOrganisation] foreach $adObjectEntry in $adObjectEntries: ' + $adObjectEntry.ObjectName) $DisplayName = $adObjectEntry.ShortCut + $adObjectEntry.ObjectName.Substring($adObjectEntry.ObjectName.IndexOf('-') + 1) $TempString = $adObjectEntry.ObjectName.Split('-') $adObjectEntry.GroupName = $TempString[0] + '-' + $DisplayName $NewFullName = $Institut + "GGX-" + $DisplayName $NewFullName1 = $NewFullName.Replace($SPKID + "GGX-O", $SPKID + "GGX-OG") $DisplayName1 = $DisplayName.Replace("O_", "OG_") $adObjectEntry.OldName = $adObjectEntry.ObjectName $adObjectEntry.GUIADGroupName = $adObjectEntry.ObjectName $adObjectEntry.GUIADGroupDisplayName = $DisplayName $DAWGruppenAnlegenOutLine = $Institut + ";" + $NewFullName1 + ";" + $adObjectEntry.Description + ";" + 'Role' + ";" + $DisplayName1 + ";" + "" + ";" + $adObjectEntry.ObjectName $DAWGruppenAnlegenOutList.Add($DAWGruppenAnlegenOutLine) $roleType = "Organisation" $DAWGruppenverwaltungOutLine = $Institut + ";" + $roleType + ";" + $adObjectEntry.OldName + ";" + $NewFullName1 + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) $PnrStr = ([string]$ProfilNummer).PadLeft(2, '0') $AWNR = "xxxx" $ProfilName = "Organisatorische Gruppe " + $NewFullName1 $ProfilNR++ $KURSSollProfileOutLine = [string]$ProfilNR + ";" + $NewFullName1.Replace($SPKID + "GGX-", "") + ";" + $ProfilName.Replace($SPKID + "GGX-OG_", "") + ";" + "0570000/0012" + ";" + $adObjectEntry.OldName + ";" + $item.'GUIADGroup.Description' + ";OG" $KURSSollProfileOutList.Add($KURSSollProfileOutLine) $ProfilNummer++ $userMemberShips = @(getAllUserMemberships $adObjectEntry) foreach ($userMemberShip in $userMemberShips) { # outLogVerbose 'foreach $userMemberShip in $userMemberShips:' $userMemberShip.MemberName $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName + ";" + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) $persnr = "0000000000" if ($userMemberShip.Origin -ieq "user") { # outLogVerbose 'if ($userMemberShip.Origin -ieq "user") -> true' try { $persnr = $mitarbeiter_array.Item($userMemberShip.MemberName) $dum = $mitarbeiter_array.Item($userMemberShip.MemberName) if (-not $dum) { # outLogVerbose 'if (-not $dum) -> true' $dum = $userMemberShip.MemberName } $persnr = $dum } catch { writeExceptionInfo $_ -Rethrow } $KURSIstMitarbeiterProfileOutLine = $persnr + ";" + $adObjectEntry.OldName + ";" + $ProfilNR + ";" + "Organisation" $KURSIstMitarbeiterProfileOutList.Add($KURSIstMitarbeiterProfileOutLine) } } $i++ } } elseif ($roletypeTag -ieq $FI.TypeTagSecurity) { # outLogVerbose 'elseif ($roletypeTag -ieq $FI.TypeTagSecurity) -> true' $SicherheitseinstellungenFilePath = $SecurityInFilePath $SicherheitseinstellungenFilePathEntries = Get-Content -Path $SicherheitseinstellungenFilePath | ConvertFrom-Csv -Delimiter ";" $sec_array = @{ "nummer" = "nummer" } foreach ($item in $SicherheitseinstellungenFilePathEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagSecurity] foreach $item in $SicherheitseinstellungenFilePathEntries: ' + $item.Name) $sec_array[$item.Name] = $item.Verantwortlicher } foreach ($adObjectEntry in $adObjectEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagSecurity] foreach $adObjectEntry in $adObjectEntries: ' + $adObjectEntry.OldName) $adObjectEntry.OldName = $adObjectEntry.ObjectName if ( $adObjectEntry.OldName.Contains($SPKID + "GDT")) { # outLogVerbose 'if ($adObjectEntry.OldName.Contains($SPKID + "GDT")) -> true' continue } $DisplayName = $adObjectEntry.ShortCut + $adObjectEntry.ObjectName.Substring($adObjectEntry.ObjectName.IndexOf('-') + 1) $TempString = $adObjectEntry.ObjectName.Split('-') $adObjectEntry.GroupName = $TempString[0] + '-' + $DisplayName $NewFullName = $Institut + "GGX-" + $DisplayName $adObjectEntry.OldName = $adObjectEntry.ObjectName $adObjectEntry.GUIADGroupName = $adObjectEntry.ObjectName $adObjectEntry.GUIADGroupDisplayName = $DisplayName $DAWGruppenAnlegenOutLine = $Institut + ";" + $NewFullName.Replace("-S_", "-SE_") + ";" + $adObjectEntry.Description + ";" + 'Role' + ";" + $NewFullName.Replace($SPKID + "GGX-S_", "SE_") + ";;" + $adObjectEntry.ObjectName $DAWGruppenAnlegenOutList.Add($DAWGruppenAnlegenOutLine) } $pnPrefix1 = "43" $pnPrefix2 = "9000" $pnRules = [System.Collections.Generic.List[object]]::new() foreach ($row in $SPK.ProfileNumberMappings) { outLog ('[$roletypeTag -ieq $FI.TypeTagSecurity] foreach $row in $SPK.ProfileNumberMappings: ' + $row) $pnRules.Add([pscustomobject]@{ Pattern = $row.Pattern PN = $pnPrefix1 + $pnPrefix2 + $row.Suffix }) } $iSonstiges = 0 $ProfilNummerSonstigesStartWert = 430000000 $PN = "" $StelleVerant = "0570000/0012" foreach ($adObjectEntry in $adObjectEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagSecurity] foreach $adObjectEntry in $adObjectEntries: ' + $adObjectEntry.OldName) if ( $adObjectEntry.OldName.Contains($SPKID + "GDT")) { # outLogVerbose 'if ($adObjectEntry.OldName.Contains($SPKID + "GDT")) -> true' continue } $DisplayName = $adObjectEntry.ShortCut + $adObjectEntry.ObjectName.Substring($adObjectEntry.ObjectName.IndexOf('-') + 1) $TempString = $adObjectEntry.ObjectName.Split('-') $adObjectEntry.GroupName = $TempString[0] + '-' + $DisplayName $NewFullName = $Institut + "GGX-" + $DisplayName $roleType = getRoleType $adObjectEntry $roletypeTag $DAWGruppenverwaltungOutLine = $Institut + ";" + $roleType + ";" + $adObjectEntry.OldName + ";" + $NewFullName.Replace("-S_", "-SE_") + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" + ";" + "" $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) $PN = $null foreach ($rule in $pnRules) { # outLogVerbose 'foreach $rule in $pnRules:' $rule if ($DisplayName.Contains($rule.Pattern)) { # outLogVerbose 'if ($DisplayName.Contains($rule.Pattern)) -> true' $PN = $rule.PN break } } if ($null -eq $PN) { # outLogVerbose 'if ($null -eq $PN) -> true' $PN = ($ProfilNummerSonstigesStartWert + $iSonstiges).ToString() $iSonstiges++ } $NewFullName1 = $NewFullName.Replace($SPKID + "GGX-S_", $SPKID + "GGX-SE_") $StelleVerant = $sec_array.Item($adObjectEntry.OldName) $KURSSollProfileOutLine = $PN + ";" + $NewFullName1.Replace($SPKID + "GGX-", "") + ";" + "Sicherheitseinstellung " + $NewFullName1 + ";" + $StelleVerant + ";" + $adObjectEntry.OldName + ";" + $item.'GUIADGroup.Description' + ";SE" $KURSSollProfileOutList.Add($KURSSollProfileOutLine) $userMemberShips = @(getAllUserMemberships $adObjectEntry) foreach ($userMemberShip in $userMemberShips) { # outLogVerbose 'foreach $userMemberShip in $userMemberShips:' $userMemberShip.MemberName $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName + ";" + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) $persnr = "0000000000" if ($userMemberShip.Origin -ieq "user") { # outLogVerbose 'if ($userMemberShip.Origin -ieq "user") -> true' try { $persnr = $mitarbeiter_array.Item($userMemberShip.MemberName) $dum = $mitarbeiter_array.Item($userMemberShip.MemberName) if (-not $dum) { # outLogVerbose 'if (-not $dum) -> true' $dum = $userMemberShip.MemberName } $persnr = $dum } catch { writeExceptionInfo $_ -Rethrow } $KURSIstMitarbeiterProfileOutLine = $persnr + ";" + $adObjectEntry.OldName + ";" + $PN + ";" + "Security" $KURSIstMitarbeiterProfileOutList.Add($KURSIstMitarbeiterProfileOutLine) } } } } elseif ($roletypeTag -ieq $FI.TypeTagRole) { # outLogVerbose 'elseif ($roletypeTag -ieq $FI.TypeTagRole) -> true' foreach ($adObjectEntry in $adObjectEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagRole] foreach $adObjectEntry in $adObjectEntries: ' + $adObjectEntry.ObjectName) $DisplayName = $adObjectEntry.ShortCut + $adObjectEntry.ObjectName.Substring($adObjectEntry.ObjectName.IndexOf('-') + 1) $TempString = $adObjectEntry.ObjectName.Split('-') $adObjectEntry.GroupName = $TempString[0] + '-' + $DisplayName $NewFullName = $SPKID + "GGX-" + $DisplayName $adObjectEntry.OldName = $adObjectEntry.ObjectName $adObjectEntry.GUIADGroupName = $adObjectEntry.ObjectName $adObjectEntry.GUIADGroupDisplayName = $DisplayName } $prefixMatcher = buildPrefixMatcher $ProfilNummer = 470000000 $ProfilNummerLM = 471000000 $iSonstiges = 0 $PN = "" $StelleVerant = "0570000/0012" foreach ($adObjectEntry in $adObjectEntries) { outLog ('[$roletypeTag -ieq $FI.TypeTagRole] foreach $adObjectEntry in $adObjectEntries: ' + $adObjectEntry.ObjectName) $DisplayName = $adObjectEntry.ShortCut + $adObjectEntry.ObjectName.Substring($adObjectEntry.ObjectName.IndexOf('-') + 1) $TempString = $adObjectEntry.ObjectName.Split('-') $adObjectEntry.GroupName = $TempString[0] + '-' + $DisplayName $NewFullName = $Institut + "GGX-" + $DisplayName if (-not ($adObjectEntry.OldName.StartsWith($SPKID + "GUX")) -and -not (testKnownPrefixes $adObjectEntry.OldName $prefixMatcher)) { # outLogVerbose 'if (-not ($adObjectEntry.OldName.StartsWith($SPKID + "GUX")) -and -not (testKnownPrefixes $adObjectEntry.OldName $ ...) -> true' continue } $roleType = getRoleType $adObjectEntry $roletypeTag if ( $NewFullName.Contains("R_LM_")) { # outLogVerbose 'if ($NewFullName.Contains("R_LM_")) -> true' $PN = ($ProfilNummerLM).ToString() $ProfilNummerLM++ $NewFullName = $NewFullName.Replace("AR_LM_", "LM_") } else { # outLogVerbose 'else -> true (if/elseif ($NewFullName.Contains("R_LM_")) -> false)' $PN = ($ProfilNummer + $iSonstiges).ToString() $iSonstiges++ } $NewFullName1 = $NewFullName.Replace($SPKID + "GGX-S_", $SPKID + "GGX-SE_") $KURSSollProfileOutLine = $PN + ";" + $NewFullName1.Replace($SPKID + "GGX-", "") + ";" + "Anwenderrolle " + $NewFullName1 + ";" + $StelleVerant + ";" + $adObjectEntry.OldName + ";" + $item.'GUIADGroup.Description' + ";AR" $KURSSollProfileOutList.Add($KURSSollProfileOutLine) $userMemberShips = @(getAllUserMemberships $adObjectEntry) if (1 -lt 2) { # outLogVerbose 'if (1 -lt 2) -> true' foreach ($userMemberShip in $userMemberShips) { # outLogVerbose 'foreach $userMemberShip in $userMemberShips:' $userMemberShip.MemberName $DAWGruppenverwaltungOutLine = $Institut + ";" + "Role" + ";" + $NewFullName1 + ";" + "" + ";" + "" + ";" + $SPK.'RootDomainName' + "\" + $userMemberShip.MemberName + ";" + "" + ";" + "" + ";" + $userMemberShip.Origin + ";" + $userMemberShip.OriginName $DAWGruppenverwaltungOutList.Add($DAWGruppenverwaltungOutLine) $persnr = "0000000000" if ($userMemberShip.Origin -ieq "user") { # outLogVerbose 'if ($userMemberShip.Origin -ieq "user") -> true' try { $persnr = $mitarbeiter_array.Item($userMemberShip.MemberName) $dum = $mitarbeiter_array.Item($userMemberShip.MemberName) if (-not $dum) { # outLogVerbose 'if (-not $dum) -> true' $dum = $userMemberShip.MemberName } $persnr = $dum } catch { writeExceptionInfo $_ -Rethrow } $KURSIstMitarbeiterProfileOutLine = $persnr + ";" + $adObjectEntry.OldName + ";" + $PN + ";" + "AW" $KURSIstMitarbeiterProfileOutList.Add($KURSIstMitarbeiterProfileOutLine) } } } } } $end = Get-Date outLog ("finished: " + $MyInvocation.MyCommand + " on type " + $roletypeTag.PadRight(30, " ") + ", used " + ($end - $begin)) }