Advertisement
Guest User

ITProConNYC2016-WinTrack-NanoServer-1

a guest
Mar 29th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. $Demo2ServerName = "NanoLab-Nano1"
  3. $DCVMName = "NanoLab-DC1"
  4.  
  5.  
  6. #############################################
  7. # PART 1 joining domain
  8. #############################################
  9.  
  10.  
  11. #####
  12. # retrieve VM IP address and add it to trusted Hosts - Powershell remoting
  13.  
  14. # $vm = Get-VM -Name $Demo2ServerName
  15. # $IPAddress = $vm.NetworkAdapters[0].IPAddresses | Where-Object {$_ -like "*.*.*.*"}
  16. # if( (Get-Service winrm).Status -ne "Running" ) {Start-Service winrm}
  17. # Set-Item WSMan:\localhost\Client\TrustedHosts "$($IPAddress.ToString())" -Force
  18. # Enter-PSSession -ComputerName $IPAddress -Credential $IPAddress\Administrator
  19.  
  20.  
  21. #####
  22. # Connect to DC to generate offline domain join blob - Powershell Direct
  23.  
  24. Enter-PSSession -VMName $DCVMName -Credential NANO\Administrator
  25.  
  26. djoin /provision /domain "nano.lab" /machine "NanoLab-Nano1" /savefile "c:\odjblob"
  27.  
  28.  
  29. Exit-PSSession
  30.  
  31. #####
  32. # Connect to Nano Server to perform domain join
  33.  
  34. Enter-PSSession -VMName $Demo2ServerName -Credential administrator
  35. $cred = Get-Credential
  36. New-PSDrive -Name Y -PSProvider FileSystem -Root \\nanolab-dc1\c$ -Credential $cred
  37.  
  38. copy-item Y:\odjblob c:\odjblob
  39.  
  40. djoin /requestodj /loadfile C:\odjblob /windowspath C:\Windows /localos
  41.  
  42. #####
  43. # Restart VM to finalize domain join
  44.  
  45. shutdown /r /t 15
  46. Exit-PSSession
  47.  
  48.  
  49. #####
  50. # connect to VM with domain credentials
  51.  
  52. Enter-PSSession -VMName $Demo2ServerName -Credential NANO\dsebban
  53.  
  54.  
  55. #####
  56. # Manage firewall remotely with powershell
  57.  
  58. netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yes
  59.  
  60.  
  61. Exit-PSSession
  62.  
  63. # CMD as admin
  64. # net use Z: \\nanolab-nano1.nano.lab\c$ /user:NANO\dsebban
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement