{"id":293,"date":"2014-01-17T15:47:03","date_gmt":"2014-01-17T15:47:03","guid":{"rendered":"http:\/\/www.nicovs.be\/?p=293"},"modified":"2014-04-09T13:47:30","modified_gmt":"2014-04-09T13:47:30","slug":"puppet-on-windows-set-administrator-password-to-never-expires","status":"publish","type":"post","link":"https:\/\/www.nicovs.be\/?p=293","title":{"rendered":"Puppet on Windows: set Administrator password to never expires"},"content":{"rendered":"<p>When maintaining windows server with puppet, it could be interesting to set your Administrator password to never expires.<br \/>\nSince you want to manage your passwords through puppet, and not manually by some hyper active sysadmin, this comes in handy.<\/p>\n<p>Note the fact that it is wise to change passwords now and then \ud83d\ude09<\/p>\n<p>On Windows you can only manage passwords through puppet&#8230; not any other expire settings.<br \/>\nYou can read <a title=\"user-attribute-password_max_age\" href=\"http:\/\/docs.puppetlabs.com\/references\/latest\/type.html#user-attribute-password_max_age\" target=\"_blank\">here <\/a>that puppet on Windows does not support manages_password_age.<\/p>\n<p>Therefor, after searching and testing a lot, I came with this class:<\/p>\n<pre class=\"lang:ruby decode:true\">class Admin_Paswd_Expires {\r\n  exec { 'Admin_Password_Expires':\r\n    command   =&gt; 'WMIC USERACCOUNT WHERE \"Name=\\'administrator\\'\" SET PasswordExpires=FALSE',\r\n    path      =&gt; $::path,\r\n    unless    =&gt; 'cmd.exe \/c net user administrator | find \"Password\" | find \"expires\" | findstr \"Never\"'\r\n  }\r\n}<\/pre>\n<p>You&#8217;d think that instead of using WMIC USERACCOUNT, you can use a simple &#8216;net user administrator \/expires:never, but that does not seem to be the case. Although your puppet agent reports that the setting has been modified, it did not&#8230; I only got it working with the WMIC command.<\/p>\n<p>Also, when using | in the unless, you need to put the cmd.exe \/c in your command. This is intended behaviour because of this:<\/p>\n<p><a title=\"Puppet exec type\" href=\"http:\/\/docs.puppetlabs.com\/references\/3.2.latest\/type.html#exec\" target=\"_blank\">Exec<\/a>: Execute external binaries on Windows systems. As with the posix provider, this provider directly calls the command with the arguments given, without passing it through a shell or performing any interpolation. To use shell built-ins \u2013 that is, to emulate the shell provider on Windows \u2014 a command must explicitly invoke the shell<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When maintaining windows server with puppet, it could be interesting to set your Administrator password to never expires. Since you want to manage your passwords through puppet, and not manually by some hyper active sysadmin, this comes in handy. Note the fact that it is wise to change passwords now and then \ud83d\ude09 On Windows [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[18,32],"tags":[77,14,21,23,75,78,74],"class_list":["post-293","post","type-post","status-publish","format-standard","hentry","category-puppet","category-windows","tag-expires","tag-password","tag-puppet-2","tag-puppet-agent","tag-user","tag-user-management","tag-windows-2"],"_links":{"self":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts\/293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=293"}],"version-history":[{"count":5,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts\/293\/revisions"}],"predecessor-version":[{"id":305,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts\/293\/revisions\/305"}],"wp:attachment":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}