Created
November 4, 2014 07:11
-
-
Save dfch/4d363ead70f3b371bfe9 to your computer and use it in GitHub Desktop.
vCAC: Dynamically execute Scripts in ExternalWFStubs Workflows with PowerShell - Set-DomainMembership.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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