Posts

Showing posts with the label Export

Additions to the CPolydorou.Security Powershell Module

This post has been triggered by a project that I'm currently working on that involves nginx and containers. As part of the nginx configuration, I had to create a certificate key pair that was going to be used in order to secure traffic towards nginx. The challenge I faced was to convert the PFX certificate that was handed to me by the Certificate Authority team to the format nginx understood. Considering that this was a process that I'd followed many times in the past (and also blogged about), I decided to update a Powershell module of mine named CPolydorou.Security in order to make the use of OpenSSL friendlier to the Windows administrator.  The four new functions that are included in the latest version ( 1.2.0 ) are: Export-ServerCertificateFromPFX Export-CertificateChainFromPFX Export-PrivateKeyFromPFX Decrypt-PrivateKey Let's go through them one-by-one to see how they can help! For the examples demostrated below, I've created secure string objects for the passphras...

MySQL Export Table to CSV

I was recently assigned the task to export a MySQL table to a file in CSV format, so I was time to brush my Linux and MySQL skills.. After a little research I managed to get things done using the following command: mysql -uroot -ptoor -e "SELECT * from tablename" databasename | sed 's/\t/","/g;s/^/"/;s/$/"/' > filename.csv I am using the mysql tool to connect to the database "databasename" using root as username and toor as password. Pay attention here, the root is the MySQL root user, not the OS user! After executing the query to get all the records from the table "tablename" I pipe the output to the sed utility to add the delimiters. In the last step, the output is redirected to the file we want to contain the table.