# encoding: ascii
# api: powershell
# title: connect-domain
# description: We have multiple domains. I added this function to my profile for each of our domains to easily connect to them using Quest ActiveRoles Management Shell for Active Directory. The function kicks you into a nested prompt to work in the domain that you connect to and lets you exit back out. It also modifies your foregroundcolor so you remember that you’re in a nested prompt.
# version: 0.1
# type: function
# license: CC0
# function: connect-domain_X
# x-poshcode-id: 622
# x-archived: 2008-10-05T17:16:03
#
#
function connect-domain_X {
BEGIN {$foregroundcolor= (get-host).ui.rawui.get_foregroundcolor()
Write-Host "";
"---------------------------------" ;
"Entering Nested Prompt for Quest connection to DOMAIN_X.";
"Type `"Exit`" when finished.";
"---------------------------------" ;
""
(get-host).ui.rawui.set_foregroundcolor("magenta")
$pw = Read-Host "Enter your DOMAIN_X password" -AsSecureString
}
PROCESS {connect-QADService -service 'domaincontroller' -ConnectionAccount 'domain_x\username' -ConnectionPassword $pw
$host.enternestedprompt()
}
END {
(get-host).ui.rawui.set_foregroundcolor($foregroundcolor)
}
}