1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#!/bin/bash mypass='Password' # one password for each PFX file pfx=( 'domain1.pfx' 'domain2.pfx' 'domain3.pfx' ) for ((x = 0; x < ${#pfx[@]}; x++)) do echo "Exporting ${pfx[$x]}..." openssl pkcs12 -in ${pfx[$x]} -clcerts -nokeys -out ${pfx[$x]}.cer -passin pass:$mypass openssl pkcs12 -in ${pfx[$x]} -nocerts -nodes -out ${pfx[$x]}.enc.key -passin pass:$mypass openssl rsa -in ${pfx[$x]}.enc.key -out ${pfx[$x]}.key rm -f ${pfx[$x]}.enc.key echo "Done!" done |
Most useful function
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function timestamp { case "$1" in 1) timestamp=`/bin/date '+%Y.%m.%d %k:%M:%S:%N'`;; 2) timestamp=`/bin/date '+%Y-%m-%d'`;; 3) timestamp=`/bin/date '+%Y-%m-%d'`;; 4) timestamp=`/bin/date '+%Y'`;; 5) timestamp=`/bin/date '+%k:%M'`;; *) timestamp=`/bin/date '+%Y.%m.%d %k:%M:%S'`;; esac echo $timestamp } echo "now is `timestamp 5`" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
function Get-Timestamp() { param ( [Parameter(Mandatory=$false)][string]$type="1" ) $Now = [System.DateTime]::Now switch($type) { 1 {[string]$ret = $Now.ToString("yyyy.MM.dd HH:mm:ss")} 2 {[string]$ret = $Now.ToString("yyyy.MM.dd")} 3 {[string]$ret = $Now.ToString("yyyy-MM-dd__HH-mm")} 4 {[string]$ret = $Now.ToString("yyyy-MM-dd")} 5 {[string]$ret = $Now.ToString("dddd")} 6 {[string]$ret = $Now.ToString("yyyyMMddHHmmss")} 7 {[string]$ret = $Now.ToString("yyyy.MM.dd HH:mm:ss.ff")} 8 {[string]$ret = $Now.ToString("yyyyMMddHHmmssff")} } return $ret } Write-Host "today is $(Get-Timestamp -type 5)" |