回复 4# yt405043510
对powershell的版本有要求,具体哪个版本我还真忘记了。另外,你的用户权限也有要求
现在在用的:- @echo off
- %1 %2
- ver|find "5.">nul&&goto :go
- mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :go","","runas",1)(window.close)&goto :eof
- :go
- pushd "%~dp0%"
- for /f "delims=:" %%i in ('findstr /n "^:JoinDomain$" "%~f0"') do (
- more +%%i "%~f0" > "%temp%\test.ps1"
- )
- powershell -executionpolicy remotesigned -file "%temp%\test.ps1"
- pause
- shutdown -r -t 0
- goto :eof
-
- :JoinDomain
- $hostname = read-host 'Enter your New PC Name Please'
- $domain = "sc.cn.chenker"
- $password = "asd=1234" | ConvertTo-SecureString -asPlainText -Force
- $username = "schenker_sc\sszxw"
- $credential = New-Object System.Management.Automation.PSCredential($username,$password)
- Add-Computer -DomainName $domain -computername $env:COMPUTERNAME -NewName $hostname -Credential $credential -OUPath "OU=kk100-wsus,OU=KK100,OU=GSR,DC=SC,DC=CN,DC=CHENKER"
复制代码
|