PoshCode Archive  Artifact [c6d78158f3]

Artifact c6d78158f3a3d93e61f04761040ae5c1516f0812604f2c85af7796e045ffb4b7:

  • File access-psu-edu.ps1 — part of check-in [73c3ef148d] at 2018-06-10 13:02:09 on branch trunk — A function to join a domain (user: Andy Schneider size: 920)

# encoding: ascii
# api: powershell
# title: access.psu.edu
# description: A function to join a domain
# version: 0.1
# type: function
# author: Andy Schneider
# license: CC0
# function: Set-Domain
# x-poshcode-id: 1863
# x-archived: 2010-05-24T16:40:48
#
# Andy Schneider
# Get-powershell.com
#
function Set-Domain {
	param(	[switch]$help,
			[string]$domain=$(read-host "Please specify the domain to join"),
			[System.Management.Automation.PSCredential]$credential = $(Get-Crdential) 
			)
			
	$usage = "`$cred = get-credential `n"
	$usage += "Set-AvaDomain -domain corp.avanade.org -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)
	
	}