Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. configuration configureServer
  2. {
  3. Import-DscResource -ModuleName xComputerManagement, xNetworking
  4. Node localhost
  5. {
  6.  
  7. LocalConfigurationManager {
  8. ActionAfterReboot = 'ContinueConfiguration'
  9. ConfigurationMode = 'ApplyOnly'
  10. RebootNodeIfNeeded = $true
  11. }
  12.  
  13. xIPAddress NewIPAddress {
  14. IPAddress = $node.IPAddress
  15. InterfaceAlias = "Ethernet0"
  16. PrefixLength = 24
  17. AddressFamily = "IPV4"
  18. }
  19.  
  20. xDefaultGatewayAddress NewIPGateway {
  21. Address = $node.GatewayAddress
  22. InterfaceAlias = "Ethernet0"
  23. AddressFamily = "IPV4"
  24. DependsOn = '[xIPAddress]NewIPAddress'
  25. }
  26.  
  27. xDnsServerAddress PrimaryDNSClient {
  28. Address = $node.DNSIPAddress
  29. InterfaceAlias = "Ethernet0"
  30. AddressFamily = "IPV4"
  31. DependsOn = '[xDefaultGatewayAddress]NewIPGateway'
  32. }
  33.  
  34. User Administrator {
  35. Ensure = "Present"
  36. UserName = "Administrator"
  37. Password = $Cred
  38. DependsOn = '[xDnsServerAddress]PrimaryDNSClient'
  39. }
  40.  
  41. xComputer ChangeNameAndJoinDomain {
  42. Name = $node.ThisComputerName
  43. DomainName = $node.DomainName
  44. Credential = $domainCred
  45. DependsOn = '[User]Administrator'
  46. }
  47. }
  48. }
  49.  
  50. $ConfigData = @{
  51. AllNodes = @(
  52. @{
  53. Nodename = "localhost"
  54. ThisComputerName = "server1"
  55. IPAddress = "10.0.2.15"
  56. GatewayAddress = "10.0.2.2"
  57. DNSIPAddress = "8.8.8.8"
  58. DomainName = "company.pri"
  59. PSDscAllowPlainTextPassword = $true
  60. PSDscAllowDomainUser = $true
  61. }
  62. )
  63. }
  64.  
  65. $domainCred = Get-Credential -UserName company\Administrator -Message "Please enter a new password for Domain Administrator."
  66. $Cred = Get-Credential -UserName Administrator -Message "Please enter a new password for Local Administrator and other accounts."
  67.  
  68. configureServer -ConfigurationData $ConfigData
  69.  
  70. Set-DSCLocalConfigurationManager -Path .\configureServer -Verbose
  71. Start-DscConfiguration -Wait -Force -Path .\configureServer -Verbose
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement