{"id":123,"date":"2019-09-04T15:37:46","date_gmt":"2019-09-04T13:37:46","guid":{"rendered":"https:\/\/greg.klonis.gr\/?p=123"},"modified":"2025-03-13T15:27:07","modified_gmt":"2025-03-13T13:27:07","slug":"create-domain-controller-with-powershell-direct","status":"publish","type":"post","link":"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct","title":{"rendered":"Create Domain Controller using PowerShell Direct"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I have a new Hyper-V server for my labs and I need to create a new virtual environment as soon as possible.<\/p>\n\n<p class=\"wp-block-paragraph\">After I finished installing Windows patches and other software, I make an image using sysprep.<\/p>\n\n<p class=\"wp-block-paragraph\">Then, I created a new virtual machine using my new Windows 2019 image.<\/p>\n\n<p class=\"wp-block-paragraph\">I chose to use PowerShell Direct to create a new Domain Controller for my new virtual infrastructure.<\/p>\n\n<p><!--more--><\/p>\n\n<p class=\"wp-block-paragraph\">From PowerShell ISE, I ran the following commands:<\/p>\n\n<ol class=\"wp-block-list\">\n<li>To connect to the guest VM<\/li>\n<\/ol>\n\n<blockquote class=\"is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$vm = &#8216;DC01&#8217;<\/p>\n<\/blockquote>\n\n<blockquote class=\"is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$cred = Get-Credential -Credential &#8220;$vmAdministrator&#8221;<\/p>\n<\/blockquote>\n\n<blockquote class=\"is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$s = New-PSSession -VMName $vm -Credential $cred<\/p>\n<\/blockquote>\n\n<ol class=\"wp-block-list\">\n<li>2. To get Windows Features regarding the Active Directory &amp; DNS<\/li>\n<\/ol>\n\n<blockquote class=\"is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$sb = {Get-WindowsFeature -Name AD*, DNS }<\/p>\n<\/blockquote>\n\n<blockquote class=\"is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Invoke-Command -Session $s -ScriptBlock $sb |<\/p>\n<\/blockquote>\n\n<blockquote class=\"is-layout-flow wp-block-quote-is-layout-flow\">\n<p>select DisplayName, Name, InstallState<\/p>\n<\/blockquote>\n\n<ol class=\"wp-block-list\">\n<li>3. To install the Roles and Features for ADDS &amp; DNS<\/li>\n<\/ol>\n\n<p class=\"wp-block-paragraph\">$sb = {Install-WindowsFeature -Name AD-Domain-Services, DNS -IncludeAllSubFeature -IncludeManagementTools -Restart}<\/p>\n\n<p class=\"wp-block-paragraph\">Invoke-Command -Session $s -ScriptBlock $sb<\/p>\n\n<ol class=\"wp-block-list\">\n<li>4. To promote to Domain Controller<\/li>\n<\/ol>\n\n<p class=\"wp-block-paragraph\">$sb = {<\/p>\n\n<p class=\"wp-block-paragraph\">Install-ADDSForest\u00a0 -ForestMode 7 -DomainMode 7 `<\/p>\n\n<p class=\"wp-block-paragraph\">-DomainName &#8216;gklonislab.me&#8217;\u00a0 -DomainNetbiosName &#8216;gklonislab&#8217; `<\/p>\n\n<p class=\"wp-block-paragraph\">-InstallDns:$true -CreateDnsDelegation:$false `<\/p>\n\n<p class=\"wp-block-paragraph\">-DatabasePath &#8216;C:WindowsNTDS&#8217; -LogPath &#8216;C:WindowsNTDS&#8217; `<\/p>\n\n<p class=\"wp-block-paragraph\">-SysvolPath &#8216;C:WindowsSYSVOL&#8217; `<\/p>\n\n<p class=\"wp-block-paragraph\">-Force:$true<\/p>\n\n<p class=\"wp-block-paragraph\">}<\/p>\n\n<p class=\"wp-block-paragraph\">Invoke-Command -Session $s -ScriptBlock $sb<\/p>\n\n<p class=\"wp-block-paragraph\">You\u2019ll be prompted twice for the Safe Mode Administrator password.<\/p>\n\n<p class=\"wp-block-paragraph\">When the script finished you will get the result below and the server restarts automatically.<\/p>\n\n<p class=\"wp-block-paragraph\">PSComputerName : DC01<\/p>\n\n<p class=\"wp-block-paragraph\">\u00a0RunspaceId\u00a0\u00a0\u00a0\u00a0 : 5a3b647f-1aa0-4f58-8b13-67d00d7ddde4<\/p>\n\n<p class=\"wp-block-paragraph\">\u00a0Message\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : Operation completed successfully<\/p>\n\n<p class=\"wp-block-paragraph\">\u00a0Context\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : DCPromo.General.1<\/p>\n\n<p class=\"wp-block-paragraph\">\u00a0RebootRequired : False<\/p>\n\n<p class=\"wp-block-paragraph\">\u00a0Status\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : Success<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a new Hyper-V server for my labs and I need to create a new virtual environment as soon as possible. After I finished installing Windows patches and other software, I make an image using sysprep. Then, I created a new virtual machine using my new Windows 2019 image. I chose to use PowerShell &hellip; <a href=\"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Create Domain Controller using PowerShell Direct&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,4],"tags":[6,54,12,28],"class_list":["post-123","post","type-post","status-publish","format-standard","hentry","category-hyper-v","category-windows-server","tag-active-directory","tag-dsc","tag-powershell","tag-windows-server"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create Domain Controller using PowerShell Direct &#8226; Gregory Klonis IT Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create Domain Controller using PowerShell Direct &#8226; Gregory Klonis IT Blog\" \/>\n<meta property=\"og:description\" content=\"I have a new Hyper-V server for my labs and I need to create a new virtual environment as soon as possible. After I finished installing Windows patches and other software, I make an image using sysprep. Then, I created a new virtual machine using my new Windows 2019 image. I chose to use PowerShell &hellip; Continue reading &quot;Create Domain Controller using PowerShell Direct&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct\" \/>\n<meta property=\"og:site_name\" content=\"Gregory Klonis IT Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/gklonis\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/gklonis\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-04T13:37:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-13T13:27:07+00:00\" \/>\n<meta name=\"author\" content=\"gklonis\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@gklonis\" \/>\n<meta name=\"twitter:site\" content=\"@gklonis\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"gklonis\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct#article\",\"isPartOf\":{\"@id\":\"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct\"},\"author\":{\"name\":\"gklonis\",\"@id\":\"https:\/\/greg.klonis.gr\/#\/schema\/person\/94626c43ab702708882d359305b7fd04\"},\"headline\":\"Create Domain Controller using PowerShell Direct\",\"datePublished\":\"2019-09-04T13:37:46+00:00\",\"dateModified\":\"2025-03-13T13:27:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct\"},\"wordCount\":231,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/greg.klonis.gr\/#\/schema\/person\/94626c43ab702708882d359305b7fd04\"},\"keywords\":[\"Active Directory\",\"DSC\",\"Powershell\",\"Windows Server\"],\"articleSection\":[\"Hyper-V\",\"Windows Server\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct\",\"url\":\"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct\",\"name\":\"Create Domain Controller using PowerShell Direct &#8226; Gregory Klonis IT Blog\",\"isPartOf\":{\"@id\":\"https:\/\/greg.klonis.gr\/#website\"},\"datePublished\":\"2019-09-04T13:37:46+00:00\",\"dateModified\":\"2025-03-13T13:27:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/greg.klonis.gr\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create Domain Controller using PowerShell Direct\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/greg.klonis.gr\/#website\",\"url\":\"https:\/\/greg.klonis.gr\/\",\"name\":\"Gregory Klonis IT Blog\",\"description\":\"IT Infrastructure Blog\",\"publisher\":{\"@id\":\"https:\/\/greg.klonis.gr\/#\/schema\/person\/94626c43ab702708882d359305b7fd04\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/greg.klonis.gr\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/greg.klonis.gr\/#\/schema\/person\/94626c43ab702708882d359305b7fd04\",\"name\":\"gklonis\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/greg.klonis.gr\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/greg.klonis.gr\/wp-content\/uploads\/2025\/03\/cropped-Removal-489.png\",\"contentUrl\":\"https:\/\/greg.klonis.gr\/wp-content\/uploads\/2025\/03\/cropped-Removal-489.png\",\"width\":240,\"height\":136,\"caption\":\"gklonis\"},\"logo\":{\"@id\":\"https:\/\/greg.klonis.gr\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/greg.klonis.gr\",\"https:\/\/www.facebook.com\/gklonis\/\",\"https:\/\/www.linkedin.com\/in\/gklonis\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create Domain Controller using PowerShell Direct &#8226; Gregory Klonis IT Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct","og_locale":"en_US","og_type":"article","og_title":"Create Domain Controller using PowerShell Direct &#8226; Gregory Klonis IT Blog","og_description":"I have a new Hyper-V server for my labs and I need to create a new virtual environment as soon as possible. After I finished installing Windows patches and other software, I make an image using sysprep. Then, I created a new virtual machine using my new Windows 2019 image. I chose to use PowerShell &hellip; Continue reading \"Create Domain Controller using PowerShell Direct\"","og_url":"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct","og_site_name":"Gregory Klonis IT Blog","article_publisher":"https:\/\/www.facebook.com\/gklonis\/","article_author":"https:\/\/www.facebook.com\/gklonis\/","article_published_time":"2019-09-04T13:37:46+00:00","article_modified_time":"2025-03-13T13:27:07+00:00","author":"gklonis","twitter_card":"summary_large_image","twitter_creator":"@gklonis","twitter_site":"@gklonis","twitter_misc":{"Written by":"gklonis","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct#article","isPartOf":{"@id":"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct"},"author":{"name":"gklonis","@id":"https:\/\/greg.klonis.gr\/#\/schema\/person\/94626c43ab702708882d359305b7fd04"},"headline":"Create Domain Controller using PowerShell Direct","datePublished":"2019-09-04T13:37:46+00:00","dateModified":"2025-03-13T13:27:07+00:00","mainEntityOfPage":{"@id":"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct"},"wordCount":231,"commentCount":0,"publisher":{"@id":"https:\/\/greg.klonis.gr\/#\/schema\/person\/94626c43ab702708882d359305b7fd04"},"keywords":["Active Directory","DSC","Powershell","Windows Server"],"articleSection":["Hyper-V","Windows Server"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct#respond"]}]},{"@type":"WebPage","@id":"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct","url":"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct","name":"Create Domain Controller using PowerShell Direct &#8226; Gregory Klonis IT Blog","isPartOf":{"@id":"https:\/\/greg.klonis.gr\/#website"},"datePublished":"2019-09-04T13:37:46+00:00","dateModified":"2025-03-13T13:27:07+00:00","breadcrumb":{"@id":"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/greg.klonis.gr\/index.php\/create-domain-controller-with-powershell-direct#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/greg.klonis.gr\/"},{"@type":"ListItem","position":2,"name":"Create Domain Controller using PowerShell Direct"}]},{"@type":"WebSite","@id":"https:\/\/greg.klonis.gr\/#website","url":"https:\/\/greg.klonis.gr\/","name":"Gregory Klonis IT Blog","description":"IT Infrastructure Blog","publisher":{"@id":"https:\/\/greg.klonis.gr\/#\/schema\/person\/94626c43ab702708882d359305b7fd04"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/greg.klonis.gr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/greg.klonis.gr\/#\/schema\/person\/94626c43ab702708882d359305b7fd04","name":"gklonis","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/greg.klonis.gr\/#\/schema\/person\/image\/","url":"https:\/\/greg.klonis.gr\/wp-content\/uploads\/2025\/03\/cropped-Removal-489.png","contentUrl":"https:\/\/greg.klonis.gr\/wp-content\/uploads\/2025\/03\/cropped-Removal-489.png","width":240,"height":136,"caption":"gklonis"},"logo":{"@id":"https:\/\/greg.klonis.gr\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/greg.klonis.gr","https:\/\/www.facebook.com\/gklonis\/","https:\/\/www.linkedin.com\/in\/gklonis\/"]}]}},"_links":{"self":[{"href":"https:\/\/greg.klonis.gr\/index.php\/wp-json\/wp\/v2\/posts\/123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/greg.klonis.gr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greg.klonis.gr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greg.klonis.gr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/greg.klonis.gr\/index.php\/wp-json\/wp\/v2\/comments?post=123"}],"version-history":[{"count":19,"href":"https:\/\/greg.klonis.gr\/index.php\/wp-json\/wp\/v2\/posts\/123\/revisions"}],"predecessor-version":[{"id":842,"href":"https:\/\/greg.klonis.gr\/index.php\/wp-json\/wp\/v2\/posts\/123\/revisions\/842"}],"wp:attachment":[{"href":"https:\/\/greg.klonis.gr\/index.php\/wp-json\/wp\/v2\/media?parent=123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greg.klonis.gr\/index.php\/wp-json\/wp\/v2\/categories?post=123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greg.klonis.gr\/index.php\/wp-json\/wp\/v2\/tags?post=123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}