test.bat- @echo off
- for /f "delims=:" %%i in ('findstr /n "^:JoinDomain$" "%~f0"') do (
- more +%%i "%~f0" > "%temp%\new.ps1"
- )
- powershell -f "%temp%\new.ps1"
- goto :eof
-
- :JoinDomain
- $domain = "chenker"
- $password = "asd=1234" | ConvertTo-SecureString -asPlainText -Force
- $username = "chenker\sszxw"
- $credential = New-Object System.Management.Automation.PSCredential($username,$password)
- Add-Computer -DomainName $domain -computername $env:hostname -NewName $env:newhostname -Credential $credential
- Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy Restricted -Force
复制代码
|