{"id":78066,"date":"2016-04-25T11:59:23","date_gmt":"2016-04-25T18:59:23","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=78066"},"modified":"2019-02-18T09:10:47","modified_gmt":"2019-02-18T16:10:47","slug":"powertip-specify-that-a-script-requires-admin-privileges-to-run","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-specify-that-a-script-requires-admin-privileges-to-run\/","title":{"rendered":"PowerTip: Specify that a script requires admin privileges to run"},"content":{"rendered":"<p><strong>Summary<\/strong>: Learn how to require admin privileges to run a Windows PowerShell script.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>\u00a0How can I make sure that my Windows PowerShell script has administrator privileges to run?<\/p>\n<p style=\"padding-left: 30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>\u00a0Use the <strong>#Requires<\/strong> directive and specify <strong>RunAsAdministrator<\/strong>. Here is an example:<\/p>\n<p style=\"padding-left: 90px\"><code>#Requires -RunAsAdministrator<\/code><\/p>\n<p style=\"padding-left: 30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" alt=\"The Doctor\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Learn how to require admin privileges to run a Windows PowerShell script. \u00a0How can I make sure that my Windows PowerShell script has administrator privileges to run? \u00a0Use the #Requires directive and specify RunAsAdministrator. Here is an example: #Requires -RunAsAdministrator<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[568,639,685,641],"tags":[],"class_list":["post-78066","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hey-scripting-guy","category-powertip","category-scripting-techniques","category-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Learn how to require admin privileges to run a Windows PowerShell script. \u00a0How can I make sure that my Windows PowerShell script has administrator privileges to run? \u00a0Use the #Requires directive and specify RunAsAdministrator. Here is an example: #Requires -RunAsAdministrator<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/78066","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=78066"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/78066\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=78066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=78066"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=78066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}