I have a server generating reports automatically. The reports are in CSV format. I need to be able to encrypt the file directly, without third party compression (no WinZIP or WinRAR).
I thought the best idea would be to convert the CSV to XLS and then password protect the XLS file, all through Powershell. Unfortunately, I do not have Office installed on the server and all the examples I have found for converting a file this way require that Excel be installed.
Does anyone know of a way to convert CSV to XLS in Powershell without having Excel installed? Or if not, can you think of a better way to password protect the CSV file without compressing it to ZIP or RAR?
.net 4.5 now includes complete zip compression with passwords. So once you install 4.5 you should be able to access this library from powershell without any other dependencies.
You can try to (if you really need use PowerShell):
Note! That this approach is hard one. You should expect strange behavior and plenty of security issues depending on assembly you choose to create excel files.
As for me, the best option for you is to create a simple console application in c#, which will use the assemblies above. Then launch it on a target machine every time you need.
P.S. I've tried to create PowerShell script for your issue with no success. Unfortunatelly, PowerShell works unpredictably with external libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With