Automating OS X and Microsoft Remote Desktop
This is to help automate MS RDP in Sierra (should work in other versions)
Make a function in you shell for remote desktop client, in my case .zshrc
We pass two args in case they are in a cluster. If your cluster is > 2, modify accordingly. The URI format is defined here
Create an alias in your .zshrc (or other shell file) like so:
alias appnameprod=(rd server01 server02 &)
Be sure to use the fqdn of the server above for the next steps to work.
Get certs from your servers to put into the keychain
mkdir /tmp/certs ; for i in server02 server02;do openssl s_client -showcerts -connect $i:3389 </dev/null 2>/dev/null|openssl x509 -outform PEM >/tmp/certs/$i.pem;done\n
Import the certs into keychain
cd /tmp/certs/ ; for i in *; do sudo security add-trusted-cert -d -r trustRoot -k "$HOME/Library/Keychains/login.keychain" $i;done
Source your .zshrc and then type your alias appnameprod
and if everything is ok, it will bring up your cluster.