diff --git a/CLIENT_DATA/join.ins b/CLIENT_DATA/join.ins index 4f76b7c..4597580 100644 --- a/CLIENT_DATA/join.ins +++ b/CLIENT_DATA/join.ins @@ -1,15 +1,21 @@ [INITIAL] -Message = "Rechner wird zur Domäne hinzugefügt!" +Message = "Rechner wird zur Domäne hinzugefügt!" ;Message = "Join computer to the domain!" - + [Actions] DefVar $dom$ DefVar $user$ DefVar $password$ +DefVar $orgunit$ set $dom$ = GetProductProperty("domainname", " ") set $user$ = GetProductProperty("joinadmin", " ") set $password$ = GetProductProperty("joinadminpw", " ") -PatchTextFile_Create_powershell %scriptpath%\join.ps1 +Set $orgunit$ = GetProductProperty ("machineobjectou","values") +if not ($orgunit$ = "") + PatchTextFile_Create_powershell_OU c:\joinpatched.ps1 +else + PatchTextFile_Create_powershell c:\joinpatched.ps1 +endif ShellBatch_JoinDom ; mit wahl des ou pfades also abhängig ob ou-pfad leer den aufrunf ändern. @@ -20,7 +26,13 @@ AddLine "$secpasswd = ConvertTo-SecureString '$password$' -AsPlainText -Force" AddLine '$mycreds = New-Object System.Management.Automation.PSCredential ("$user$", $secpasswd)' AddLine 'Add-Computer -DomainName "$dom$" -credential $mycreds' SaveToFile "c:\joinpatched.ps1" - + +[PatchTextFile_Create_powershell_OU] +AddLine "$secpasswd = ConvertTo-SecureString '$password$' -AsPlainText -Force" +AddLine '$mycreds = New-Object System.Management.Automation.PSCredential ("$user$", $secpasswd)' +AddLine 'Add-Computer -DomainName "$dom$" -OUPath "$orgunit$" -credential $mycreds' +SaveToFile "c:\joinpatched.ps1" + [ShellBatch_JoinDom] powershell set-executionpolicy RemoteSigned powershell -File c:\joinpatched.ps1