title: PowerShell start-sleep cmdlet
body: <p>Hey I am very new to PowerShell and found one of Ed Wilson's helpful scripts on his blog: <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/12/force-a-domain-wide-update-of-group-policy-with-powershell.aspx" rel="nofollow">http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/12/force-a-domain-wide-update-of-group-policy-with-powershell.aspx</a>. </p>
  
  <p>I needed to customize it a little for my needs and just need some help getting the right code down. </p>
  
  <p>I will just use his code because all I did was replace it with my credentials and AD info:</p>
  
     
  
  <pre class="lang-powershell prettyprint-override"><code>$cn = Get-ADComputer -filt *
  $cred = Get-Credential iammred\administrator
  $session = New-PSSession -cn $cn.name -cred $cred
  icm -Session $session -ScriptBlock {gpupdate /force}
  </code></pre>
  
  <p>What I added was the next two lines to attempt to pause the script to allow the gpupdate to process then restart the computer(s):</p>
  
  <pre class="lang-powershell prettyprint-override"><code>Start-Sleep -s 120
  Restart-Computer -ComputerName $cn.name
  </code></pre>
  
  <p>When I run the script all together it seems to just hang after I enter my credentials. My guess would be it doesn't like the way I present the Start-Sleep cmdlet because I can run the Restart-Computer cmdlet with success without Start-Sleep. The problem is it doesn't wait for gpupdate to finish so the policy doesn't get pushed. I do not get any errors when I run the script, it just hangs. I have left it running for about 10 minutes with no success.</p>
  
  <p>I appreciate any help or suggestions to make this script work properly. Thanks in advance for any input.</p>