This commit is contained in:
Edmond Gebara 2026-07-07 12:27:41 +02:00
parent 9e18f320cd
commit 99c1510a34
36 changed files with 57279 additions and 2052 deletions

View file

@ -1,3 +1,4 @@
function convertUTF8ToASCII
{
param ([Parameter(Mandatory = $true, Position = 0)] [String]$utf8Text)
@ -116,6 +117,29 @@ function removeDuplicatesFromSortedList
outLog ($ListName + ": removed " + $removedCount + " duplicate lines, " + $List.Count + " remaining")
}
function clearWorkDirectories
{
param
(
[Parameter(Mandatory = $true)]
[string[]] $Directories
)
foreach ($directory in $Directories)
{
if (Test-Path $directory)
{
$items = @(Get-ChildItem -Path $directory -ErrorAction SilentlyContinue)
$items | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
outLog ("cleared work directory " + $directory + " (" + $items.Count + " items removed)")
}
else
{
New-Item -ItemType Directory -Path $directory -Force | Out-Null
outLog ("created work directory " + $directory)
}
}
}
function outScreen
{
$timestamp = Get-Date
@ -138,32 +162,33 @@ function checkInput
$spk = $spk.ToUpperInvariant()
if ([string]::IsNullOrEmpty($spk))
{
outLogVerbose 'if ([string]::IsNullOrEmpty($spk)) -> true'
# outLogVerbose 'if ([string]::IsNullOrEmpty($spk)) -> true'
if (isProbablyDevelopmentUser)
{
outLogVerbose 'if (isProbablyDevelopmentUser) -> true'
$spk = $Config.DefaultInstitute.ToUpperInvariant()
# outLogVerbose 'if (isProbablyDevelopmentUser) -> true'
$spk = $Config.DefaultInstitute.ToUpperInvariant()
outLog ("no institute parameter provided - development fallback to " + $spk)
}
else
{
outLogVerbose 'else -> true (if/elseif (isProbablyDevelopmentUser) -> false)'
# outLogVerbose 'else -> true (if/elseif (isProbablyDevelopmentUser) -> false)'
while ($true)
{
outLogVerbose 'while ($true) -> true'
# outLogVerbose 'while ($true) -> true'
$spk = $(Read-Host "please enter Institute Parameter (parameter '-sparkasse'), 'Ctrl-C for exit'" ).ToUpperInvariant()
if ([string]::IsNullOrEmpty($spk))
{
outLogVerbose 'if ([string]::IsNullOrEmpty($spk)) -> true'
# outLogVerbose 'if ([string]::IsNullOrEmpty($spk)) -> true'
continue
}
elseif (checkInstitute($spk))
{
outLogVerbose 'elseif (checkInstitute($spk)) -> true'
# outLogVerbose 'elseif (checkInstitute($spk)) -> true'
break
}
else
{
outLogVerbose 'else -> true (if/elseif (checkInstitute($spk)) -> false)'
# outLogVerbose 'else -> true (if/elseif (checkInstitute($spk)) -> false)'
continue
}
}
@ -171,7 +196,7 @@ function checkInput
}
elseif (-not (checkInstitute($spk)))
{
outLogVerbose 'elseif (-not (checkInstitute($spk))) -> true'
# outLogVerbose 'elseif (-not (checkInstitute($spk))) -> true'
exit
}
return $spk
@ -181,12 +206,12 @@ function checkInputSourceFiles
{
if (-not $InstitutsSourcePath)
{
outLogVerbose 'if (-not $InstitutsSourcePath) -> true'
# outLogVerbose 'if (-not $InstitutsSourcePath) -> true'
return $false
}
if (-not $InstitutsSourcePathKURS)
{
outLogVerbose 'if (-not $InstitutsSourcePathKURS) -> true'
# outLogVerbose 'if (-not $InstitutsSourcePathKURS) -> true'
return $false
}
return $true
@ -197,43 +222,43 @@ function checkInputDataFiles
$ok = $true
if (-not $ADObjectsFilePath)
{
outLogVerbose 'if (-not $ADObjectsFilePath) -> true'
# outLogVerbose 'if (-not $ADObjectsFilePath) -> true'
outLog "no ADObjectsFile found !"
$ok = $false
}
if (-not $ADObjectMembershipsFilePath)
{
outLogVerbose 'if (-not $ADObjectMembershipsFilePath) -> true'
# outLogVerbose 'if (-not $ADObjectMembershipsFilePath) -> true'
outLog "no ADObjectsFile found !"
$ok = $false
}
if (-not $ADApplicationsInFilePath)
{
outLogVerbose 'if (-not $ADApplicationsInFilePath) -> true'
# outLogVerbose 'if (-not $ADApplicationsInFilePath) -> true'
outLog "no ADApplicationsInFile found !"
$ok = $false
}
if (-not $ADDirectoriesInFilePath)
{
outLogVerbose 'if (-not $ADDirectoriesInFilePath) -> true'
# outLogVerbose 'if (-not $ADDirectoriesInFilePath) -> true'
outLog "no ADDirectoriesInFile found !"
$ok = $false
}
if (-not $SecurityInFilePath)
{
outLogVerbose 'if (-not $SecurityInFilePath) -> true'
# outLogVerbose 'if (-not $SecurityInFilePath) -> true'
outLog "no SecurityInFile found !"
$ok = $false
}
if (-not $KURSPositionsInFilePath)
{
outLogVerbose 'if (-not $KURSPositionsInFilePath) -> true'
# outLogVerbose 'if (-not $KURSPositionsInFilePath) -> true'
outLog "no KURSPositionsInFile found !"
$ok = $false
}
if (-not $KURSEmployeesInFilePath)
{
outLogVerbose 'if (-not $KURSEmployeesInFilePath) -> true'
# outLogVerbose 'if (-not $KURSEmployeesInFilePath) -> true'
outLog "no KURSEmployeesInFile found !"
$ok = $false
}
@ -241,7 +266,7 @@ function checkInputDataFiles
$ADObjectMembershipsFileTimeStamp = (Get-ChildItem $ADObjectMembershipsFilePath).BaseName.Split("_")[2]
if ($ADObjectsFileTimeStamp -ne $ADObjectMembershipsFileTimeStamp)
{
outLogVerbose 'if ($ADObjectsFileTimeStamp -ne $ADObjectMembershipsFileTimeStamp) -> true'
# outLogVerbose 'if ($ADObjectsFileTimeStamp -ne $ADObjectMembershipsFileTimeStamp) -> true'
outLog "TimeStamps of latest input files found are not equal: ADObjectsFileTimeStamp:" $ADObjectsFileTimeStamp "ADObjectMembershipsFileTimeStamp: " $ADObjectMembershipsFileTimeStamp ", stopping process !"
$ok = $false
}
@ -252,7 +277,7 @@ function checkTestMode
{
if ($Config.TestMode -gt 0)
{
outLogVerbose 'if ($Config.TestMode -gt 0) -> true'
# outLogVerbose 'if ($Config.TestMode -gt 0) -> true'
outLog "entering TestMode, reading the first" $Config.TestMode "ADObject-entries for every roletype"
return $true
}
@ -265,12 +290,12 @@ function isProbablyDevelopmentUser
$userName = [Environment]::UserName
if ($userName -ieq "edmond")
{
outLogVerbose 'if ($userName -ieq "edmond") -> true'
# outLogVerbose 'if ($userName -ieq "edmond") -> true'
return $true
}
elseif ($userName -ieq "burgwink")
{
outLogVerbose 'elseif ($userName -ieq "burgwink") -> true'
# outLogVerbose 'elseif ($userName -ieq "burgwink") -> true'
return $true
}
return $false
@ -337,7 +362,7 @@ function moveToInstituteTmpPath
$tmpFilePath = $InstituteRootPathTmp + "/" + $fileName
if ($force)
{
outLogVerbose 'if ($force) -> true'
# outLogVerbose 'if ($force) -> true'
Remove-Item -Path $tmpFilePath -ErrorAction Ignore
}
Move-Item -Path $filePath -Destination $InstituteRootPathTmp
@ -374,7 +399,7 @@ function writeExceptionInfo
if ($Rethrow)
{
outLogVerbose 'if ($Rethrow) -> true'
# outLogVerbose 'if ($Rethrow) -> true'
throw $ErrorRecord
}
}