Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Param(
- $LabIPAddressPattern = "192.168.33.*",
- $VagrantIPPattern = "10.0.*",
- $ParentDNSServer = "192.168.33.10",
- $parentname = "source.lab"
- )
- Set-StrictMode -Version Latest
- $ErrorActionPreference = "Stop"
- # Set local administrator password
- $user = [adsi]"WinNT://localhost/Administrator,user"
- $user.SetPassword("1234_Abcd")
- $user.SetInfo()
- # Rename the LAB interface
- write-host "Setting DNS client and renaming non-vagrant NIC"
- Get-NetAdapter -InterfaceIndex (Get-NetIPAddress -IPAddress $LabIPAddressPattern).InterfaceIndex | Rename-NetAdapter -NewName Lab
- Get-NetAdapter -InterfaceIndex (Get-NetIPAddress -IPAddress $LabIPAddressPattern).InterfaceIndex | Set-DnsClientServerAddress -ServerAddresses $ParentDNSServer
- write-host "Ensure the primary IP address setup by vagrant is not registered"
- Get-NetIPConfiguration -InterfaceIndex (Get-NetIPAddress -IPAddress $VagrantIPPattern).InterfaceIndex |
- Get-NetConnectionProfile |
- Where IPv4Connectivity -ne "NoTraffic" |
- Set-DnsClient -RegisterThisConnectionsAddress:$false -Verbose
- write-host "Joining to domain"
- $user_su="vagrant"
- $MyAdminUser=$parentname+'\'+$user_su
- $user_su_pass="vagrant"
- $SecurePassword = ConvertTo-SecureString -String $user_su_pass -AsPlainText -Force
- $MyAdminCredentials = New-Object System.Management.Automation.PSCredential $MyAdminUser,$SecurePassword
- Add-Computer -DomainName $parentname -Credential $MyAdminCredentials
Add Comment
Please, Sign In to add comment