Skip to content

Instantly share code, notes, and snippets.

@MarcoGriep88
Last active April 21, 2023 05:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcoGriep88/93bef29f6293a03c9ab320c22d2e94d5 to your computer and use it in GitHub Desktop.
Save MarcoGriep88/93bef29f6293a03c9ab320c22d2e94d5 to your computer and use it in GitHub Desktop.
Ascotel Contacts to Avaya System Diary
# 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
@MarcoGriep88
Copy link
Author

MarcoGriep88 commented Apr 21, 2023

For more Information visit: Avaya contact import

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment