PoshCode Archive  Artifact [316e06bc33]

Artifact 316e06bc33cd3b43677582e941a4b620eb172e77d68eff1bc2fd1b7e0db355ff:

  • File ozforex.ps1 — part of check-in [260a4d454c] at 2018-06-10 12:56:50 on branch trunk — A function to join a domain (user: Andy Schneider size: 940)

# encoding: ascii
# api: powershell
# title: ozforex
# description: A function to join a domain
# version: 0.1
# type: function
# author: Andy Schneider
# license: CC0
# function: Set-Domain
# x-poshcode-id: 1310
# x-derived-from-id: 1311
# x-archived: 2009-11-17T21:26:07
#
# 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)
	
	}