Wednesday, October 28, 2015

How to create a self-elevating PowerShell script that will run as administrator every time

Often there are various build processes or other automated tasks that run via PowerShell and need to be run as administrator.  If you forget to run it as administrator, it won't work, and you don't always know.

I came across a great blog post by Ben Armstrong that I have to share, where he's created a block of code you just prefix to the beginning of your PowerShell script that will re-launch it as administrator if it is not.  Check his post out here:

Here's a screenshot of the PowerShell code in case his blog goes down:


  1. I really have no words to thank you because i was having this assignment and was worried where to start. But you really have helped me.

  2. Thanks for your sharing. Hope you can contribute more quality posts to
    this page. Thank you! Nonton Drama Korea

  3. Sadece bir kumarhane oyun sitesinde yapılabilecek harika şeyleri her zaman yapmaya başlayabilirsiniz. Herkes mükemmel online casino oyunları oynayabilir. Kumarhanelerde sadece tipobet365 indir gerçek adamlar kazanabilir ve şimdi size harika kumarhanelerden bahsedebilirim.