Friday 20 June 2014

Adding VDI to specific OU using SetupComplete.cmd

    Adding VDIs to specific OUs can be accomplished by running a batch file which invokes a powershell script to do so. Create a file c:\windows\Setup\Scripts\SetupComplete.cmd and put in the content below.

***********SetupComplete.cmd*************

powershell Set-ExecutionPolicy bypass
powershell C:\Windows\Temp\JoinDomain.ps1
del C:\Windows\Temp\JoinDomain.ps1
timeout 30 
shutdown -t 0 -r -f


Create another file C:\Temp\JoinDomain.ps1 with the below content:

$credential = New-Object System.Management.Automation.PsCredential -ArgumentList @("domainname\domainaccount", (ConvertTo-SecureString "password" -AsPlainText -Force))

Add-Computer -DomainName "you.domain.com" -Credential $credential -OUPath ("OU=Your,OU=OU,OU=path,DC=at,DC=your,DC=domain")




the Account used needs to have sufficient priviliges to add computers to domain.

No comments:

Post a Comment

Detect autopilot session

  Ensuring that some apps only install during autopilot is not easily accomplished, you can use the below powershell script as a requiremen...