windows.domainjoin/CLIENT_DATA/join.ins

40 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

[INITIAL]
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", " ")
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.
; Add-Computer -domainname DOMAIN -OUPath "OU=OU1,OU=OU2,OU=Domainname,DC=company,DC=com" -cred DOMAIN\AuthorizedUser -passthru verbose
[PatchTextFile_Create_powershell]
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]
2014-08-19 17:53:04 +02:00
powershell set-executionpolicy RemoteSigned
powershell -File c:\joinpatched.ps1
del c:\joinpatched.ps1