Last active
April 21, 2023 05:53
-
-
Save MarcoGriep88/93bef29f6293a03c9ab320c22d2e94d5 to your computer and use it in GitHub Desktop.
Ascotel Contacts to Avaya System Diary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For more information visit: https://www.marcogriep.de/posts/telefonbuch-von-ascotel-zu-avaya-telefonanlage-migrieren/ | |
$InputFile = "Input.csv" | |
$OutputFile = "Export.csv" | |
class Entry { | |
[string]$Name | |
[string]$Number | |
[string]$SpeedDialCode | |
} | |
$entries = @() | |
$reader = [System.IO.StreamReader]::new($InputFile, [System.Text.Encoding]::UTF8) | |
$lineCount = 0; | |
while($reader.Peek() -ge 0) { | |
$ln = $reader.ReadLine(); | |
$lineCount += 1; | |
if ($lineCount -lt 10) { | |
continue; | |
} | |
if ($ln.StartsWith('//')) { | |
continue; | |
} | |
if ($ln -like "*;*") { | |
$splitted = $ln.Split(';') | |
$obj = [Entry]::new() | |
$obj.SpeedDialCode = "None" # Überschreiben | |
$number = $splitted[1] | |
$skipNumberCheck = $false; | |
if ($number.StartsWith('00')) { | |
$skipNumberCheck = $true; | |
} | |
elseif ($number.StartsWith('0')) { | |
if (-not $skipNumberCheck) { | |
$number = "0" + $number; | |
} | |
} | |
else { | |
if (-not $skipNumberCheck) { | |
$number = "00" + $number; | |
} | |
} | |
$obj.Number = $number | |
$name = $splitted[2]; | |
$sanitizedName = $name.Replace(',', '') | |
if ([String]::IsNullOrEmpty($sanitizedName)) { | |
continue; | |
} | |
$obj.Name = $sanitizedName.Trim() | |
$entries += $obj; | |
} | |
continue; | |
} | |
Write-Host "Alles ausgelesen". | |
$entries | Export-Csv -Path $OutputFile -Force -Encoding utf8 -Delimiter ',' -UseQuotes Never |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For more Information visit: Avaya contact import