Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Demo2ServerName = "NanoLab-Nano1"
- $DCVMName = "NanoLab-DC1"
- #############################################
- # PART 1 joining domain
- #############################################
- #####
- # retrieve VM IP address and add it to trusted Hosts - Powershell remoting
- # $vm = Get-VM -Name $Demo2ServerName
- # $IPAddress = $vm.NetworkAdapters[0].IPAddresses | Where-Object {$_ -like "*.*.*.*"}
- # if( (Get-Service winrm).Status -ne "Running" ) {Start-Service winrm}
- # Set-Item WSMan:\localhost\Client\TrustedHosts "$($IPAddress.ToString())" -Force
- # Enter-PSSession -ComputerName $IPAddress -Credential $IPAddress\Administrator
- #####
- # Connect to DC to generate offline domain join blob - Powershell Direct
- Enter-PSSession -VMName $DCVMName -Credential NANO\Administrator
- djoin /provision /domain "nano.lab" /machine "NanoLab-Nano1" /savefile "c:\odjblob"
- Exit-PSSession
- #####
- # Connect to Nano Server to perform domain join
- Enter-PSSession -VMName $Demo2ServerName -Credential administrator
- $cred = Get-Credential
- New-PSDrive -Name Y -PSProvider FileSystem -Root \\nanolab-dc1\c$ -Credential $cred
- copy-item Y:\odjblob c:\odjblob
- djoin /requestodj /loadfile C:\odjblob /windowspath C:\Windows /localos
- #####
- # Restart VM to finalize domain join
- shutdown /r /t 15
- Exit-PSSession
- #####
- # connect to VM with domain credentials
- Enter-PSSession -VMName $Demo2ServerName -Credential NANO\dsebban
- #####
- # Manage firewall remotely with powershell
- netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yes
- Exit-PSSession
- # CMD as admin
- # net use Z: \\nanolab-nano1.nano.lab\c$ /user:NANO\dsebban
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement