Guest User

Untitled

a guest
Feb 14th, 2017
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. Param(
  2. $LabIPAddressPattern = "192.168.33.*",
  3. $VagrantIPPattern = "10.0.*",
  4. $ParentDNSServer = "192.168.33.10",
  5. $parentname = "source.lab"
  6. )
  7. Set-StrictMode -Version Latest
  8. $ErrorActionPreference = "Stop"
  9.  
  10. # Set local administrator password
  11. $user = [adsi]"WinNT://localhost/Administrator,user"
  12. $user.SetPassword("1234_Abcd")
  13. $user.SetInfo()
  14.  
  15. # Rename the LAB interface
  16. write-host "Setting DNS client and renaming non-vagrant NIC"
  17. Get-NetAdapter -InterfaceIndex (Get-NetIPAddress -IPAddress $LabIPAddressPattern).InterfaceIndex | Rename-NetAdapter -NewName Lab
  18. Get-NetAdapter -InterfaceIndex (Get-NetIPAddress -IPAddress $LabIPAddressPattern).InterfaceIndex | Set-DnsClientServerAddress -ServerAddresses $ParentDNSServer
  19.  
  20. write-host "Ensure the primary IP address setup by vagrant is not registered"
  21. Get-NetIPConfiguration -InterfaceIndex (Get-NetIPAddress -IPAddress $VagrantIPPattern).InterfaceIndex |
  22. Get-NetConnectionProfile |
  23. Where IPv4Connectivity -ne "NoTraffic" |
  24. Set-DnsClient -RegisterThisConnectionsAddress:$false -Verbose
  25.  
  26. write-host "Joining to domain"
  27. $user_su="vagrant"
  28. $MyAdminUser=$parentname+'\'+$user_su
  29. $user_su_pass="vagrant"
  30.  
  31. $SecurePassword = ConvertTo-SecureString -String $user_su_pass -AsPlainText -Force
  32. $MyAdminCredentials = New-Object System.Management.Automation.PSCredential $MyAdminUser,$SecurePassword
  33.  
  34.  
  35. Add-Computer -DomainName $parentname -Credential $MyAdminCredentials
Add Comment
Please, Sign In to add comment