# encoding: ascii
# api: powershell
# title: 
# description: Modified the script to fix a few typos.
# version: 0.1
# type: function
# license: CC0
# function: Set-Domain
# x-poshcode-id: 4072
# x-archived: 2013-04-07T05:20:38
#
#
function Set-Domain {
	param(	[switch]$help,
			[string]$domain=$(read-host "Please specify the domain to join"),
			[System.Management.Automation.PSCredential]$credential = $(Get-Credential) 
			)
			
	$usage = "`$cred = get-credential `n"
	$usage += "Set-Domain -domain MyDomain -credential `$cred`n"
	if ($help) {Write-Host $usage;exit}
	
	$username = $credential.GetNetworkCredential().UserName
	$password = $credential.GetNetworkCredential().Password
	$computer = Get-WmiObject Win32_ComputerSystem
	$computer.JoinDomainOrWorkGroup($domain ,$password, $username, $null, 3)
	
	}
