{"id":2136,"date":"2016-03-20T03:43:07","date_gmt":"2016-03-19T18:43:07","guid":{"rendered":"http:\/\/1bed.allright.life\/?p=2136"},"modified":"2020-04-18T22:26:15","modified_gmt":"2020-04-18T13:26:15","slug":"post-2136","status":"publish","type":"post","link":"https:\/\/1bed.allright.life\/?p=2136","title":{"rendered":"PowerShell \u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u3068\u30dd\u30ea\u30b7\u30fc\u306e\u5909\u66f4"},"content":{"rendered":"<p>\u6700\u521d\u306b\u5c11\u3057\u8a2d\u5b9a\u3092\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u3053\u3067\u306f PowerShell \u3092\u7ba1\u7406\u8005\u30e2\u30fc\u30c9\u3067\u8d77\u52d5\u3057\u3066\u4f5c\u696d\u3092\u884c\u3044\u307e\u3059\u3002\u7ba1\u7406\u8005\u30e2\u30fc\u30c9\u3067\u306e\u8d77\u52d5\u306e\u4ed5\u65b9\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u30e1\u30cb\u30e5\u30fc\u304b\u3089 Windows PowerShell \u3092\u63a2\u3059<\/li>\n<li>Windows PowerShell \u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066 <em>\u7ba1\u7406\u8005\u3068\u3057\u3066\u5b9f\u884c<\/em> \u3092\u9078\u3076<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2014\/10\/powershell_run_admin.png\" alt=\"PowerShell \u3092\u7ba1\u7406\u8005\u3067\u5b9f\u884c\u3059\u308b\" \/><\/p>\n<h2>PowerShell \u306e\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u306b\u3064\u3044\u3066<\/h2>\n<p>PowerShell \u306e\u521d\u671f\u5024\u306f\u3001PowerShell \u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb(\u62e1\u5f35\u5b50\u304c .ps1)\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002\u3053\u308c\u306f Windows \u306e\u904e\u53bb\u306e\u6b74\u53f2\u306b\u3088\u308b\u3082\u306e\u306e\u3088\u3046\u3067\u3001<a href=\"http:\/\/technet.microsoft.com\/ja-jp\/magazine\/2008.01.powershell.aspx\">TechNet \u306e\u30b3\u30e9\u30e0<\/a>\u306b\u3082\u3042\u308a\u307e\u3057\u305f\u3002\u3053\u306e\u307e\u307e\u3067\u306f\u4fdd\u5b58\u3057\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb(\u30d7\u30ed\u30b0\u30e9\u30e0)\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u3068\u3057\u3066\u5229\u7528\u3059\u308b\u969b\u306b\u306f\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u3092\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/technet.microsoft.com\/ja-JP\/library\/dd347641.aspx\">TechNet: about_Execution_Policies<\/a> \u306b\u3082\u6b21\u306e\u8a18\u8f09\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<p>\u65e2\u5b9a\u306e\u30dd\u30ea\u30b7\u30fc\u306f &quot;Restricted&quot; \u3067\u3059\u3002<\/p>\n<p>Restricted &#8211; \u65e2\u5b9a\u306e\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u500b\u3005\u306e\u30b3\u30de\u30f3\u30c9\u306f\u8a31\u53ef\u3055\u308c\u307e\u3059\u304c\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u5b9f\u884c\u3055\u308c\u307e\u305b\u3093\u3002 &#8211; \u66f8\u5f0f\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3068\u69cb\u6210\u30d5\u30a1\u30a4\u30eb (.ps1xml)\u3001\u30e2\u30b8\u30e5\u30fc\u30eb \u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb (.psm1)\u3001\u304a\u3088\u3073 Windows PowerShell \u30d7\u30ed\u30d5\u30a1\u30a4\u30eb (.ps1) \u3092\u542b\u3080\u3001 \u3059\u3079\u3066\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u5b9f\u884c\u304c\u7981\u6b62\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/blockquote>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3001\u30b3\u30de\u30f3\u30c9\u306f OK \u3060\u3051\u3069\u3001\u30d5\u30a1\u30a4\u30eb\u306b\u3057\u3066\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306f NG \u3068\u3044\u3046\u3053\u3068\u3067\u3059\u306d\u3002<\/p>\n<h2>\u73fe\u5728\u306e\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u306e\u78ba\u8a8d<\/h2>\n<pre><code class=\"language-powershell\">PS&gt; Get-ExecutionPolicy\nRestricted<\/code><\/pre>\n<p>\u4e0a\u8a18\u4f8b\u3067\u306f\u898f\u5b9a\u306e\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u306e Restricted \u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u306e\u7a2e\u985e\u3068\u5909\u66f4\u306e\u30b3\u30de\u30f3\u30c9<\/h2>\n<p>PowerShell \u3092\u7ba1\u7406\u8005\u30e2\u30fc\u30c9\u3067\u8d77\u52d5\u3057\u3066\u4f5c\u696d\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-powershell\">#\u7f72\u540d\u306e\u3042\u308b\u30d5\u30a1\u30a4\u30eb\u306e\u307f\u5b9f\u884c\u53ef\u80fd\nSet-ExecutionPolicy AllSigned\n\n#\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306f\u7f72\u540d\u304c\u306a\u3044\u3068\u5b9f\u884c\u4e0d\u53ef\nSet-ExecutionPolicy RemoteSigned\n\n#\u7f72\u540d\u306a\u3057\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3082\u5b9f\u884c\u53ef\u80fd\u3060\u304c\u8b66\u544a\u304c\u3067\u308b\nSet-ExecutionPolicy Unrestricted\n\n#\u7f72\u540d\u306a\u3057\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3082\u5b9f\u884c\u53ef\u80fd\u3067\u8b66\u544a\u3082\u3067\u306a\u3044\nSet-ExecutionPolicy Bypass<\/code><\/pre>\n<h2>\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u306e\u5b9f\u884c\u3092\u8a31\u53ef\u3059\u308b(\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30dd\u30ea\u30b7\u30fc\u306e\u5909\u66f4)<\/h2>\n<p>PowerShell \u3092\u7ba1\u7406\u8005\u30e2\u30fc\u30c9\u3067\u8d77\u52d5\u3057\u3066\u4f5c\u696d\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-powershell\">PS&gt; Set-ExecutionPolicy remotesigned\n\n\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u306e\u5909\u66f4\n\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u306f\u3001\u4fe1\u983c\u3055\u308c\u3066\u3044\u306a\u3044\u30b9\u30af\u30ea\u30d7\u30c8\u304b\u3089\u306e\u4fdd\u8b77\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u3092\u5909\u66f4\u3059\u308b\u3068\u3001about_Execution_Policies\n\u306e\u30d8\u30eb\u30d7 \u30c8\u30d4\u30c3\u30af (http:\/\/go.microsoft.com\/fwlink\/?LinkID=135170)\n\u3067\u8aac\u660e\u3055\u308c\u3066\u3044\u308b\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u4e0a\u306e\u5371\u967a\u306b\u3055\u3089\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u3092\u5909\u66f4\u3057\u307e\u3059\u304b?\n[Y] \u306f\u3044(Y)  [N] \u3044\u3044\u3048(N)  [S] \u4e2d\u65ad(S)  [?] \u30d8\u30eb\u30d7 (\u65e2\u5b9a\u5024\u306f &quot;Y&quot;): y<\/code><\/pre>\n<h2>\u30dd\u30ea\u30b7\u30fc\u7d61\u307f\u306e\u30a8\u30e9\u30fc<\/h2>\n<h3>\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u306e\u5909\u66f4\u3092\u4e00\u822c\u30e6\u30fc\u30b6\u30fc\u3067\u884c\u3046\u3068\u51fa\u308b\u30a8\u30e9\u30fc<\/h3>\n<pre><code class=\"language-powershell\">PS&gt; Set-ExecutionPolicy AllSigned\nSet-ExecutionPolicy : \u30ec\u30b8\u30b9\u30c8\u30ea \u30ad\u30fc &#039;HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\Microsoft.PowerShell&#039; \u3078\u306e\u30a2\u30af\u30bb\u30b9\u304c\u62d2\u5426\u3055\u308c\u307e\u3057\u305f\u3002 \u65e2\u5b9a (LocalMachine) \u306e\u30b9\u30b3\u30fc\u30d7\u306e\u5b9f\u884c\u30dd\n\u30ea\u30b7\u30fc\u3092\u5909\u66f4\u3059\u308b\u306b\u306f\u3001[\u7ba1\u7406\u8005\u3068\u3057\u3066\u5b9f\u884c] \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066 Windows PowerShell \u3092\u8d77\u52d5\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u73fe\u5728\u306e\u30e6\u30fc\u30b6\u30fc\u306e\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u3092\u5909\u66f4\u3059\u308b\u306b\u306f\u3001&quot;Set-ExecutionPolicy -Scope CurrentUser&quot; \u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\u767a\u751f\u5834\u6240 \u884c:1 \u6587\u5b57:1\n+ Set-ExecutionPolicy AllSigned\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n    + CategoryInfo          : PermissionDenied: (:) [Set-ExecutionPolicy], UnauthorizedAccessException\n    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand<\/code><\/pre>\n<h3>\u5b9f\u884c\u30dd\u30ea\u30b7\u30fc\u3092\u5909\u66f4\u305b\u305a\u306b\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u5b9f\u884c\u3059\u308b\u3068\u51fa\u308b\u30a8\u30e9\u30fc<\/h3>\n<pre><code class=\"language-powershell\">\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5b9f\u884c\u304c\u30b7\u30b9\u30c6\u30e0\u3067\u7121\u52b9\u306b\u306a\u3063\u3066\u3044\u308b\u305f\u3081\u3001\u30d5\u30a1\u30a4\u30eb C:\\Users\\miyamiya\\Desktop\\VBS\\hoge.ps1 \u3092\u8aad\u307f\u8fbc\u3081\u307e\u305b\u3093\u3002\u8a73\u7d30\u306b\u3064\u3044\u3066\u306f\u3001\u300cget-help about_\nsigning\u300d\u3068\u5165\u529b\u3057\u3066\u30d8\u30eb\u30d7\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\u767a\u751f\u5834\u6240 \u884c:1 \u6587\u5b57:39\n+ C:\\Users\\miyamiya\\Desktop\\hoge.ps1 &lt;&lt;&lt;&lt;\n    + CategoryInfo          : NotSpecified: (:) []\u3001PSSecurityException\n    + FullyQualifiedErrorId : RuntimeException<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u521d\u306b\u5c11\u3057\u8a2d\u5b9a\u3092\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u3053\u3067\u306f PowerShell \u3092\u7ba1\u7406\u8005\u30e2\u30fc\u30c9\u3067\u8d77\u52d5\u3057\u3066\u4f5c\u696d\u3092\u884c\u3044\u307e\u3059\u3002\u7ba1\u7406\u8005\u30e2\u30fc\u30c9\u3067\u306e\u8d77\u52d5\u306e\u4ed5\u65b9\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002 \u30e1\u30cb\u30e5\u30fc\u304b\u3089 Windows PowerShell \u3092\u63a2\u3059 Wind [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[62],"class_list":["post-2136","post","type-post","status-publish","format-standard","hentry","category-program","tag-powershell"],"_links":{"self":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2136","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2136"}],"version-history":[{"count":2,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2136\/revisions"}],"predecessor-version":[{"id":3176,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2136\/revisions\/3176"}],"wp:attachment":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}