{"id":12945,"date":"2017-02-21T09:04:18","date_gmt":"2017-02-21T17:04:18","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/?p=12945"},"modified":"2019-02-18T12:38:03","modified_gmt":"2019-02-18T19:38:03","slug":"managing-security-settings-on-nano-server-with-dsc","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/managing-security-settings-on-nano-server-with-dsc\/","title":{"rendered":"Managing Security Settings on Nano Server with DSC"},"content":{"rendered":"<p>We have released DSC resources building upon the previously released security and registry cmdlets for applying security settings. You can now implement Microsoft-defined security baselines using DSC.<\/p>\n<p><a href=\"https:\/\/www.powershellgallery.com\/packages\/AuditPolicyDsc\/1.1.0.0\">AuditPolicyDsc<\/a><br>\n<a href=\"https:\/\/www.powershellgallery.com\/packages\/SecurityPolicyDsc\/1.0.0.0\">SecurityPolicyDsc<\/a><br>\n<a href=\"https:\/\/www.powershellgallery.com\/packages\/GPRegistryPolicy\/0.2\">GPRegistryPolicy<\/a><br>\nInstall all 3 from the Gallery with the command:<\/p>\n<div class=\"highlight highlight-source-powershell\">\n<pre><span class=\"pl-c1\">install-module<\/span> SecurityPolicyDsc<span class=\"pl-k\">,<\/span> AuditPolicyDsc<span class=\"pl-k\">,<\/span> GpRegistryPolicy <\/pre>\n<\/div>\n<p>A sample configuration, below, takes the <a href=\"https:\/\/blogs.technet.microsoft.com\/secguide\/2016\/10\/17\/security-baseline-for-windows-10-v1607-anniversary-edition-and-windows-server-2016\/\">Security Baselines for Windows Server 2016<\/a> and extracts the .inf, .csv and .pol containing the desired security settings from the exported Group Policy Objects. (You can find information on <a href=\"https:\/\/devblogs.microsoft.com\/powershell\/new-group-policy-cmdlets-for-nano-server\/\">extracting the necessary files in the Registry cmdlets blogpost<\/a>.) Simply pass the files into the new DSC resources, and you have successfully implemented security baselines using DSC!<br>\nThis is most useful for Nano Server, since<a href=\"https:\/\/blogs.technet.microsoft.com\/grouppolicy\/2016\/05\/09\/configuration-management-on-servers\/\"> Nano Server doesn\u2019t support Group Policy<\/a>. However, this approach will work for all installation options. It\u2019s not a good idea to manage the same server using both Group Policy and DSC since the two engines will constantly attempt to overwrite each other if they are both managing the same setting.<\/p>\n<p><strong>WARNING<\/strong>: As with all security settings, you can easily lock yourself out of remote access to your machine if you are not careful. Be sure to carefully review security settings before applying them to Nano Server, and stage test deployments before using security baselines in production!<\/p>\n<div class=\"highlight highlight-source-powershell\">\n<pre><span class=\"pl-k\">Configuration<\/span> <span class=\"pl-en\">SecurityBaseline<\/span>\n{\n    <span class=\"pl-c1\">Import-DscResource<\/span> <span class=\"pl-k\">-<\/span>ModuleName AuditPolicyDsc<span class=\"pl-k\">,<\/span> SecurityPolicyDSC<span class=\"pl-k\">,<\/span> GpRegistryPolicy\n    node localhost\n    {\n        SecurityTemplate baselineInf\n        {\n            Path <span class=\"pl-k\">=<\/span> <span class=\"pl-s\">\"C:\\Users\\Administrator\\Documents\\GptTmpl.inf\"<\/span>\n            <span class=\"pl-c\"># https:\/\/msdn.microsoft.com\/powershell\/dsc\/singleinstance<\/span>\n            IsSingleInstance <span class=\"pl-k\">=<\/span> <span class=\"pl-s\">\"Yes\"<\/span>\n        }\n        AuditPolicyCsv baselineCsv\n        {\n            IsSingleInstance <span class=\"pl-k\">=<\/span> <span class=\"pl-s\">\"Yes\"<\/span>\n            CsvPath <span class=\"pl-k\">=<\/span> <span class=\"pl-s\">\"C:\\Users\\Administrator\\Documents\\audit.csv\"<\/span>\n        }\n        RegistryPolicy baselineGpo\n        {\n            Path <span class=\"pl-k\">=<\/span> <span class=\"pl-s\">\"C:\\Users\\Administrator\\Documents\\registry.pol\"<\/span>\n        }\n    }\n}\n<span class=\"pl-c\">#Compile the MOF file<\/span>\nSecurityBaseline \n<span class=\"pl-c1\">Start-DscConfiguration<\/span> <span class=\"pl-k\">-<\/span>Path .<span class=\"pl-k\">\/<\/span>SecurityBaseline <\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>We have released DSC resources building upon the previously released security and registry cmdlets for applying security settings. You can now implement Microsoft-defined security baselines using DSC. AuditPolicyDsc SecurityPolicyDsc GPRegistryPolicy Install all 3 from the Gallery with the command: install-module SecurityPolicyDsc, AuditPolicyDsc, GpRegistryPolicy A sample configuration, below, takes the Security Baselines for Windows Server 2016 [&hellip;]<\/p>\n","protected":false},"author":617,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12945","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>We have released DSC resources building upon the previously released security and registry cmdlets for applying security settings. You can now implement Microsoft-defined security baselines using DSC. AuditPolicyDsc SecurityPolicyDsc GPRegistryPolicy Install all 3 from the Gallery with the command: install-module SecurityPolicyDsc, AuditPolicyDsc, GpRegistryPolicy A sample configuration, below, takes the Security Baselines for Windows Server 2016 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/12945","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/617"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=12945"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/12945\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=12945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=12945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=12945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}