Advertisement
BlackGuard26

Opdracht Logging

Dec 10th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Import-Module "C:\Powershell Files\functies.psm1"
  2.  
  3. $data = [Xml](Get-Content("C:\Powershell Files\14 CSWINPS XML Wijzigingen v1.0.xml"))
  4. $tempData = $null
  5. $currentDate = Get-Date -format HHmm_yyyyMMdd
  6.  
  7. Start-Transcript -Path "C:\BackUp\$currentDate _log.txt"
  8. try
  9. {
  10.     foreach($item in $data.klantadministratie.wijzigen.klant)
  11.     {
  12.         foreach($i in $item.ChildNodes)
  13.         {
  14.             $attribuut = $i.Name
  15.             #if($attribuut -eq "provincieVoluit") { $attribuut = "provincie-voluit" }
  16.  
  17.             if(!$tempData)
  18.             {
  19.                 $tempData = Wijzig-KolomVoorKlantnummers -Kolom $attribuut -Inhoud $i.'#text' -KlantnummerArray @($item.nummer)
  20.             }
  21.             else
  22.             {
  23.                 $tempData = Wijzig-KolomVoorKlantnummers -Kolom $attribuut -Inhoud $i.'#text' -KlantnummerArray @($item.nummer) -KlantAdm $tempData
  24.             }
  25.         }
  26.     }
  27.  
  28.     foreach($item in $data.klantadministratie.verwijderen.klant)
  29.     {
  30.         if(!$tempData)
  31.         {
  32.             $tempData = Verwijder-Klanten -KlantnummerArray @($item.nummer)
  33.         }
  34.         else
  35.         {
  36.             $tempData = Verwijder-Klanten -KlantAdm $tempData -KlantnummerArray @($item.nummer)
  37.         }
  38.     }
  39.  
  40.     foreach($item in $data.klantadministratie.toevoegen.klant)
  41.     {
  42.         if(!$tempData)
  43.         {
  44.             $tempData = Toevoegen-Klant -Klantnummer $item.nummer -Kolom "Klantnummer" -Inhoud $item.nummer
  45.         }
  46.         else
  47.         {
  48.             $tempData = Toevoegen-Klant -KlantAdm $tempData -Klantnummer $item.nummer -Kolom "Klantnummer" -Inhoud $item.nummer
  49.         }
  50.  
  51.         foreach($i in $item.ChildNodes)
  52.         {
  53.             $tempData = Toevoegen-Klant -KlantAdm $tempData -Klantnummer $item.nummer -Kolom $i.Name -Inhoud $i.'#text'
  54.         }
  55.     }
  56.  
  57.     $tempData | Export-Csv -Path ("C:\BackUp\"+ $currentDate +"_Data.csv") -Delimiter ";" -NoTypeInformation
  58. }
  59. Catch
  60. {
  61.     Write-Error "Error"
  62. }
  63. finally
  64. {
  65.     Stop-Transcript
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement