PoshCode Archive  Artifact [d03b22f3e5]

Artifact d03b22f3e5931fac59d91357acbf732b2fea52cb145153ad9b346a2a8bd65d5e:

  • File connect-domain.ps1 — part of check-in [a4093c7f0f] at 2018-06-10 14:10:44 on branch trunk — 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. (user: unknown size: 1296)

# 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)
		}
	}