Added ability to pass arguments to script

Added the ability to pass arguments like username, password, domain, port to the script which was hard-coded.
This required re-structuring the script to included a main()