@echo off
call check-for-admin
if %ERRORLEVEL% neq 0 exit /b

set TOOLS=c:\tools
set SCRIPT_SETTINGS=%TOOLS%\scripts\settings.cmd
set CUSTOM_SETTINGS=%TOOLS%\custom\settings.cmd

echo ####### %0 #######

if NOT EXIST %SCRIPT_SETTINGS% (
  echo INFO: config file %SCRIPT_SETTINGS% NOT FOUND
) else (
  call %SCRIPT_SETTINGS%
)

if NOT EXIST %CUSTOM_SETTINGS% (
  echo INFO: config file %CUSTOM_SETTINGS% NOT FOUND
) else (
  call %CUSTOM_SETTINGS%
)

echo JOINING domain ...
echo domain=%domain%
powershell -Command "Add-Computer -DomainName %domain% -Restart -Credential $env:UserName"

echo ####### %0 #######

