3 ms·
Coming from a bash background, PowerShell is consistently annoying. Here's an example, passing an XML file to a cmdlet: Some-Command -Param1 -FileData .\fo
by bluedino 7y ago
Coming from a bash background, PowerShell is consistently annoying. Here's an example, passing an XML file to a cmdlet:
Some-Command -Param1 -FileData .\foobar.xml
Cannot process argument transformation on parameter 'FileData'. Cannot convert value ".\foo.xml" to type "System.Byte[]". Error: "Cannot convert value ".\foo.xml" to type "System.Byte". Error: "Input string was not in a correct format.""
In bash you would just do:
somecommand < foobar.xml
Instead you have to create an object and, do a conversion:
[Byte[]]$Data = Get-Content -Path ".\foobar.xml" -Encoding Byte -ReadCount 0
Then, run the same command using that object instead of the file:
Some-Command -Param1 -FileData $Data