Skip to content

Instantly share code, notes, and snippets.

@dfch
Created November 4, 2014 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dfch/4d363ead70f3b371bfe9 to your computer and use it in GitHub Desktop.
Save dfch/4d363ead70f3b371bfe9 to your computer and use it in GitHub Desktop.
vCAC: Dynamically execute Scripts in ExternalWFStubs Workflows with PowerShell - Set-DomainMembership.ps1
# http://d-fens.ch/2013/12/05/vcac-dynamically-execute-scripts-in-externalwfstubs-workflows-with-powershell/
PARAM (
[ValidateSet('EXAMPLE', 'SHAREDOP')]
[Parameter(Mandatory = $true, Position = 0)]
[string] $Domain
,
[Parameter(Mandatory = $true, Position = 1)]
[string] $Username
,
[Parameter(Mandatory = $true, Position = 2)]
[string] $Password
,
[Parameter(Mandatory = $false, Position = 3)]
[string] $OUPath = "OU=Computers,DC=example,DC=com"
) #
$SecurePassword = $Password | ConvertTo-SecureString -asPlainText -Force;
$Credential = New-Object System.Management.Automation.PSCredential($Username, $SecurePassword);
if($OUPath) {
Add-Computer -DomainName $Domain -OUPath $OUPath -Credential $Credential -Restart -Force;
} else {
Add-Computer -DomainName $Domain -Credential $Credential -Restart -Force;
} # if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment