Hello everyone,
I am new to powershell and I was practicing some scripts found on the net.
I found this which converts .XML files to .CSV but it doesn't work for me.
Script:
$xmlFile = Get-Content -Path C:\Users\giannigini\Desktop\test\PowerShell_Books.xml
$xmlFile.catalog.ChildNodes | ConvertTo-Csv -NoTypeInformation -Delimiter:";" | Set-Content -Path C:\Users\giannigini\Desktop\test\PowerShell_Books_2.csv
Get-Content -Path C:\Users\giannigini\Desktop\test\PowerShell_Books_2.csv
Output Error:
ConvertTo-Csv : Impossibile associare l'argomento al parametro 'InputObject' perché è null.
In riga:2 car:31
+ ... .ChildNodes | ConvertTo-Csv -NoTypeInformation -Delimiter:";" | Set-C ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [ConvertTo-Csv], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertToCsvCommand
Get-Content : Impossibile trovare il percorso 'C:\Users\giannigini\Desktop\test\PowerShell_Books_2.csv' perché non esiste.
In riga:3 car:1
+ Get-Content -Path C:\Users\giannigini\Desktop\test\PowerSh ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\giann...ell_Books_2.csv:String) [Get-Content], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
Translation of the first row: Export-CSV Cannot bind argument to parameter because it's null
Can you explain to me what I'm doing wrong?
Thank you