PoshCode Archive  Artifact Content

Artifact 81c24cc5347c1195b57ea2b20f3a3b030054c1b88ed4e4a20465f994aedc5d9f:

  • File medical.ps1 — part of check-in [745d693756] at 2018-06-10 13:03:31 on branch trunk — A function to join a domain (user: Andy Schneider size: 913)

# encoding: ascii
# api: powershell
# title: medical
# description: A function to join a domain
# version: 0.1
# type: function
# author: Andy Schneider
# license: CC0
# function: Set-Domain
# x-poshcode-id: 1975
# x-archived: 2010-07-20T20:42:28
#
# 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)
	
	}