{"id":217332,"date":"2021-05-13T09:25:17","date_gmt":"2021-05-13T01:25:17","guid":{"rendered":"https:\/\/gulass.cn\/?p=217332"},"modified":"2021-04-26T10:27:07","modified_gmt":"2021-04-26T02:27:07","slug":"powershell-set-executionpolicy","status":"publish","type":"post","link":"https:\/\/gulass.cn\/powershell-set-executionpolicy.html","title":{"rendered":"Powershell \u5982\u4f55\u6279\u91cf\u83b7\u53d6\u6587\u4ef6\u5927\u5c0f\u7684\u5b9e\u73b0\u4ee3\u7801"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e86Powershell \u4e4b\u6279\u91cf\u83b7\u53d6\u6587\u4ef6\u5927\u5c0f\u7684\u5b9e\u73b0\u4ee3\u7801<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u6548\u679c\u56fe\uff1a<\/strong><\/span><\/div>\n

\"\"<\/p>\n

\u6838\u5fc3\u4ee3\u7801\uff1a<\/strong><\/span><\/div>\n
\r\n$startFolder = \"D:\\\"\r\n$colItems = (Get-ChildItem $startFolder | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object)\r\nforeach ($i in $colItems)\r\n{\r\n $subFolderItems = (Get-ChildItem $i.FullName -recurse | Measure-Object -property length -sum)\r\n $FileSize=\"{0:N2}\" -f ($subFolderItems.sum \/ 1GB)\r\n $Unit='GB'\r\n if($FileSize -lt 1)\r\n {\r\n  $FileSize=\"{0:N2}\" -f ($subFolderItems.sum \/ 1MB)\r\n  $Unit='MB'\r\n }\r\n write-host $i.FullName ' -- ' $FileSize $Unit -fore green\r\n}\r\n<\/pre>\n

\u6ce8\u610f\uff1a\u5982\u679c\u662f\u7b2c\u4e00\u6b21\u8fd0\u884c\u9700\u8981\u5f00\u542f\u6267\u884c\u811a\u672c\u6743\u9650\u3002<\/p>\n

\u5728powershell\u4e2d\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\uff0c\u7136\u540e Y \u786e\u8ba4\u5373\u53ef\u3002<\/p>\n

\u5f00\u542f\uff1a<\/p>\n

set-executionpolicy remotesigned<\/pre>\n

\u5173\u95ed\uff1a<\/p>\n

Set-ExecutionPolicy Restricted<\/pre>\n","protected":false},"excerpt":{"rendered":"

$startFolder = “D:\\” $colItems = (Get-ChildItem $startF […]<\/p>\n","protected":false},"author":1479,"featured_media":41354,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-217332","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/217332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1479"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=217332"}],"version-history":[{"count":1,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/217332\/revisions"}],"predecessor-version":[{"id":217334,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/217332\/revisions\/217334"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/41354"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=217332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=217332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=217332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}