PoshCode Archive  Artifact [df73e2363a]

Artifact df73e2363a890dcbba01a3796ba8c7603195db010459644b4e60bbf937f63e71:

  • File Set-Domain.ps1 — part of check-in [a2593ba13d] at 2018-06-10 13:35:52 on branch trunk — Modified the script to fix a few typos. (user: unknown size: 842)

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