Advertisement
Guest User

123abc PS

a guest
Sep 25th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. Stop-Service -DisplayName "Workstation" -force
  2. net use * /d
  3. Start-Service -Name "LanmanWorkstation"
  4. $dom = $env:userdomain
  5. $workgroupname = "WorkGroup"
  6. $domain = "$dom.local"
  7. $password = "Password1" | ConvertTo-SecureString -asPlainText -Force
  8. $username = "$domain\AddComp"
  9. $credential = New-Object System.Management.Automation.PSCredential($username,$password)
  10.  
  11. Add-computer -WorkgroupName $workgroupname -Credential $credential
  12.  
  13. Add-Computer -DomainName $domain -Credential $credential
  14. $Com1 = "---------------------------------------------------------"
  15. $Com2 = "| Attention! |"
  16. $Com3 = "| The server needs to restart to apply the last changes.|"
  17. $Com4 = "| Do NOT restart if the domain is incorrect! |"
  18. $Com5 = "---------------------------------------------------------"
  19. $Com6 = " "
  20.  
  21. clear
  22. Write-Host $Com1
  23. Write-Host $Com2
  24. Write-Host $Com3
  25. Write-Host $Com4
  26. Write-Host $Com5
  27. Write-Host $Com6
  28. Write-Host "Check if domain match:"
  29. Write-Host $Com5
  30. Write-Host "Should be" = $domain
  31. Write-Host "Currently" = (Get-WmiObject Win32_ComputerSystem).domain
  32. Write-Host $Com5
  33.  
  34. Restart-Computer -confirm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement