title: How to change admin name and logout threshold with powershell win2k12 R2
body: <p>I am trying to automate some regular tasks, and I need some help. Does powershell compile like C++ or is a simple batch file like the old .bat</p>
  
  <p><em>Is there an online lint/editor for powershell place like jsfiddle?</em></p>
  
  <p>Main question: I need help with <strong>automating</strong> some of these <strong>into a powershell script</strong> (both interactive and non-interactive modes) and <strong>looking at if they succeed</strong></p>
  
  <ol>
  <li>Change user/admin name <code>Get-WMIObject Win32_UserAccount -Filter "Name -like 'admin*'" | Foreach-Object {$_.Rename("Dingbats)")}</code></li>
  <li><p><a href="https://technet.microsoft.com/en-us/library/hh994574.aspx" rel="nofollow">Turn on lockout threshold</a> to 3 attempts and set it to 45 mins </p>
  
  <p><code>PS C:\&gt; Set-ADDefaultDomainPasswordPolicy -Identity SS64.com -LockoutDuration 00:40:00 -LockoutObservationWindow 00:20:00 -ComplexityEnabled $true -ReversibleEncryptionEnabled $false -MaxPasswordAge 10.00:00:00</code></p></li>
  </ol>
  
  <p>another example</p>
  
  <pre><code> # set lockout threshold value
   # how do I **change $mydomain to my server name** or local server automatically??
   PS C:\&gt; $mydomain.MaxBadPasswordsAllowed = 0 
  
   # set lockout duration value (in seconds)
   PS C:\&gt; $mydomain.AutoUnlockInterval = 1000
  </code></pre>
  
  <ol start="3">
  <li>Turn on/enabled windows update service to start/auto on window startup</li>
  </ol>
  
  <p>..</p>
  
  <p>Edit 1: I posted some code before, now I have added other snippets as requested, I am still working on figuring out the auto start of windows updates. The challenge seems to be that - there are many options to do the same thing in Powershell. There seems to be an incredible amount of power, and the danger of messing up your system. So, I am looking for help in consolidating so I can add and maint the scripts on my own.</p>