<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Weekend Scripter: Active Directory Account Unlock Shortcut for Help Desk</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/05/weekend-scripter-active-directory-account-unlock-shortcut-for-help-desk.aspx</link><description>Today&amp;rsquo;s post is a quick Windows PowerShell tip to save time for the Help Desk to unlock Active Directory accounts.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Weekend Scripter: Active Directory Account Unlock Shortcut for Help Desk</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/05/weekend-scripter-active-directory-account-unlock-shortcut-for-help-desk.aspx#3535786</link><pubDate>Fri, 30 Nov 2012 21:28:31 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3535786</guid><dc:creator>Gökalp İmamoğlu</dc:creator><description>&lt;p&gt;hi,&lt;/p&gt;
&lt;p&gt;users to search for all users within the domain is locked unlocked?&lt;/p&gt;
&lt;p&gt;accept &amp;gt;&amp;gt;&amp;gt;no&lt;/p&gt;
&lt;p&gt;example:&lt;/p&gt;
&lt;p&gt;@echo off &lt;/p&gt;
&lt;p&gt;powershell.exe -Command &amp;quot;&amp;amp; {Import-Module ActiveDirectory; Read-Host &amp;quot;Enter the user account to unlock&amp;quot; | Unlock-ADAccount -Credential $(Get-Credential)}&amp;quot;&lt;/p&gt;
&lt;p&gt;All users???&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3535786" width="1" height="1"&gt;</description></item><item><title>re: Weekend Scripter: Active Directory Account Unlock Shortcut for Help Desk</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/05/weekend-scripter-active-directory-account-unlock-shortcut-for-help-desk.aspx#3512513</link><pubDate>Fri, 03 Aug 2012 16:21:31 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3512513</guid><dc:creator>Ayehu</dc:creator><description>&lt;p&gt;Great post! nice scripting. I took it further and developed a workflow that can automate your own powershell scripts! aha! so you can schedule or trigger them any time you want, just take your scripts and put them inside the workflow and the results you can see for your self &lt;a rel="nofollow" target="_new" href="http://bit.ly/JdsP6H"&gt;http://bit.ly/JdsP6H&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Enjoy.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3512513" width="1" height="1"&gt;</description></item><item><title>re: Weekend Scripter: Active Directory Account Unlock Shortcut for Help Desk</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/05/weekend-scripter-active-directory-account-unlock-shortcut-for-help-desk.aspx#3512512</link><pubDate>Fri, 03 Aug 2012 16:20:37 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3512512</guid><dc:creator>Ayehu</dc:creator><description>&lt;p&gt;Great post! nice scripting. I took it further and developed a workflow that can automate your own powershell scripts! aha! so you can schedule or trigger them any time you want, just take your scripts and put them inside the workflow and the results you can see for your self &amp;lt;a href=&amp;quot;&lt;a rel="nofollow" target="_new" href="http://bit.ly/JdsP6H&amp;quot;&amp;gt;http://bit.ly/JdsP6H&amp;lt;/a&amp;gt;"&gt;bit.ly/.../a&amp;gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Enjoy.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3512512" width="1" height="1"&gt;</description></item><item><title>re: Weekend Scripter: Active Directory Account Unlock Shortcut for Help Desk</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/05/weekend-scripter-active-directory-account-unlock-shortcut-for-help-desk.aspx#3508122</link><pubDate>Mon, 09 Jul 2012 16:26:35 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3508122</guid><dc:creator>Virendra</dc:creator><description>&lt;p&gt;how a administrator can use the above script&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3508122" width="1" height="1"&gt;</description></item><item><title>re: Weekend Scripter: Active Directory Account Unlock Shortcut for Help Desk</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/05/weekend-scripter-active-directory-account-unlock-shortcut-for-help-desk.aspx#3500577</link><pubDate>Tue, 29 May 2012 03:01:01 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3500577</guid><dc:creator>C Reese</dc:creator><description>&lt;p&gt;Well you could actually make this a &amp;quot;One Liner&amp;quot; by writing it like this:&lt;/p&gt;
&lt;p&gt;@echo off &amp;amp; powershell.exe -Command &amp;quot;&amp;amp; {Import-Module ActiveDirectory; Read-Host &amp;quot;Enter the user account to unlock&amp;quot; | Unlock-ADAccount}&amp;quot;&lt;/p&gt;
&lt;p&gt;If you happen to copy and paste this on the command prompt directly, you will end up with a no prompt shell. Just type @Echo on to get the prompt back.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3500577" width="1" height="1"&gt;</description></item><item><title>re: Weekend Scripter: Active Directory Account Unlock Shortcut for Help Desk</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/05/weekend-scripter-active-directory-account-unlock-shortcut-for-help-desk.aspx#3497220</link><pubDate>Thu, 10 May 2012 14:53:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3497220</guid><dc:creator>Ashley McGlone</dc:creator><description>&lt;p&gt;Thanks for the great questions and feedback to this post. &amp;nbsp;I&amp;#39;ll answer each of your questions below with a new or modified batch file line.&lt;/p&gt;
&lt;p&gt;1. &amp;nbsp;Display an error if they don&amp;#39;t have permissions to unlock the account.&lt;/p&gt;
&lt;p&gt;A. &amp;nbsp;Add the &amp;quot;-NoExit&amp;quot; to the front of the command so that you can see any errors that occur.&lt;/p&gt;
&lt;p&gt;@echo off&lt;/p&gt;
&lt;p&gt;powershell.exe -NoExit -Command &amp;quot;&amp;amp; {Import-Module ActiveDirectory; Read-Host &amp;quot;Enter the user account to unlock&amp;quot; | Unlock-ADAccount}&amp;quot;&lt;/p&gt;
&lt;p&gt;2. &amp;nbsp;Specify the DC where to perform the unlock.&lt;/p&gt;
&lt;p&gt;A. &amp;nbsp;Add &amp;quot;-Server (Read-Host &amp;quot;Enter the DC to target for the unlock&amp;quot;)&amp;quot; to the Unlock-ADAccount cmdlet.&lt;/p&gt;
&lt;p&gt;@echo off&lt;/p&gt;
&lt;p&gt;powershell.exe -Command &amp;quot;&amp;amp; {Import-Module ActiveDirectory; Read-Host &amp;quot;Enter the user account to unlock&amp;quot; | Unlock-ADAccount -Server (Read-Host &amp;quot;Enter the DC to target for the unlock&amp;quot;)}&amp;quot;&lt;/p&gt;
&lt;p&gt;3. &amp;nbsp;Display lockout status.&lt;/p&gt;
&lt;p&gt;A. &amp;nbsp;Get-ADUser calculates the property LockedOut, so we can query that with a couple other properties of interest.&lt;/p&gt;
&lt;p&gt;@echo off&lt;/p&gt;
&lt;p&gt;powershell.exe -Command &amp;quot;&amp;amp; {Get-ADUser (Read-Host &amp;quot;Enter the user account name to check lockout status&amp;quot;) -Properties Name, LockedOut, AccountLockoutTime | Format-List Name, LockedOut, AccountLockoutTime}&amp;quot;&lt;/p&gt;
&lt;p&gt;4. &amp;nbsp;Only unlock users within your group.&lt;/p&gt;
&lt;p&gt;A. &amp;nbsp;This should be handled with AD delegation rather than in PowerShell code.&lt;/p&gt;
&lt;p&gt;5. &amp;nbsp;Password reset.&lt;/p&gt;
&lt;p&gt;A. &amp;nbsp;I knew this would be the next request. &amp;nbsp;It actually involves a few lines of code that would look like this:&lt;/p&gt;
&lt;p&gt;Import-Module ActiveDirectory&lt;/p&gt;
&lt;p&gt;$u = Read-Host &amp;quot;Enter username for password reset&amp;quot;&lt;/p&gt;
&lt;p&gt;# We must collect the new password strings as plain text,&lt;/p&gt;
&lt;p&gt;# because we cannot verify that they match if they are&lt;/p&gt;
&lt;p&gt;# secure strings.&lt;/p&gt;
&lt;p&gt;$p1 = Read-Host &amp;quot;Enter new password&amp;quot;&lt;/p&gt;
&lt;p&gt;$p2 = Read-Host &amp;quot;Confirm new password&amp;quot;&lt;/p&gt;
&lt;p&gt;If ($p1 -eq $p2) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Set-ADAccountPassword $u -NewPassword $(ConvertTo-SecureString $p1 -AsPlainText -Force)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;# The next line will error if the account is set to never expire.&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Set-ADUser $u -ChangePasswordAtLogon $true&lt;/p&gt;
&lt;p&gt;} Else {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;quot;Passwords did not match.&amp;quot;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;But then I massively shortened it to an aliased and compacted one-liner like this:&lt;/p&gt;
&lt;p&gt;@echo off&lt;/p&gt;
&lt;p&gt;powershell -NoE -C &amp;quot;&amp;amp;{ipmo ActiveDirectory;$u=Read-Host &amp;#39;User&amp;#39;;$p=Read-Host &amp;#39;New pw&amp;#39;;$q=Read-Host &amp;#39;Confirm pw&amp;#39;;If($p -eq $q){Set-ADAccountPassword $u -N $(ConvertTo-SecureString $p -A -F);Set-ADUser $u -Ch 1}Else{&amp;#39;Pw mismatch&amp;#39;}}&amp;quot;&lt;/p&gt;
&lt;p&gt;Now you have enough options to create three or four handy shortcuts for yourself or others to enjoy.&lt;/p&gt;
&lt;p&gt;Have fun!&lt;/p&gt;
&lt;p&gt;~Ashley&lt;/p&gt;
&lt;p&gt;@GoateePFE&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3497220" width="1" height="1"&gt;</description></item><item><title>re: Weekend Scripter: Active Directory Account Unlock Shortcut for Help Desk</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/05/weekend-scripter-active-directory-account-unlock-shortcut-for-help-desk.aspx#3497049</link><pubDate>Wed, 09 May 2012 19:02:31 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3497049</guid><dc:creator>User</dc:creator><description>&lt;p&gt;Great post. &amp;nbsp;Is there a way to set it so you could only unlock users within your group? &amp;nbsp;It would also be great if we could do a quick password reset within this. &amp;nbsp;Thanks for your tips&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3497049" width="1" height="1"&gt;</description></item><item><title>re: Weekend Scripter: Active Directory Account Unlock Shortcut for Help Desk</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/05/weekend-scripter-active-directory-account-unlock-shortcut-for-help-desk.aspx#3496644</link><pubDate>Tue, 08 May 2012 12:29:26 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3496644</guid><dc:creator>Account Properties</dc:creator><description>&lt;p&gt;I&amp;#39;ve started playing with activedirectory module recently and this has proven to be very useful! &amp;nbsp;Thanks! &amp;nbsp;Is it possible to display the status of the user account. &amp;nbsp;Example, my helpdesk peepz run this batch file, and maybe it shows them the status - if the account is unlocked. &amp;nbsp;I cannot find this properties information in &amp;quot;get-aduser username -properties *&amp;quot;. &amp;nbsp;Suggestions?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3496644" width="1" height="1"&gt;</description></item><item><title>re: Weekend Scripter: Active Directory Account Unlock Shortcut for Help Desk</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/05/weekend-scripter-active-directory-account-unlock-shortcut-for-help-desk.aspx#3496495</link><pubDate>Mon, 07 May 2012 17:42:58 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3496495</guid><dc:creator>Mike Neal</dc:creator><description>&lt;p&gt;Our HelpDesk only has certain user accounts they have permission to unlock, is there a way to display an error if their account does not have the correct rights in order to unlock an account? Also, is there a way to specify what DC it unlocks the account out at or do multiple DCs at once?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3496495" width="1" height="1"&gt;</description></item></channel></rss>