Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $username = get-content "C:\Temp\username.txt"
- $password = get-content "C:\Temp\password.txt"
- $password = convertto-securestring $password -asplaintext -force
- Write-Host "Importing credentials"
- $creds = New-Object System.Management.Automation.PSCredential($username,$password)
- Write-Host "Joining computer to domain"
- add-computer -domainname "contoso.com" -cred $creds -oupath "OU=Computers,DC=contoso,dc=com"
- #Check activation once more
- Write-Host "Checking activation"
- slmgr /ato
- Write-Host "Resetting execution policy"
- Set-ExecutionPolicy -ExecutionPolicy Restricted
- Write-Host "Cleaning up copied files"
- Remove-Item -LiteralPath "C:\Temp\join.ps1" -Force
- Remove-Item -LiteralPath "C:\Temp\username.txt" -Force
- Remove-Item -LiteralPath "C:\Temp\password.txt" -Force
- Write-Host "Restarting in 15 seconds"
- Start-Sleep -seconds 15
- restart-computer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement