{"id":52763,"date":"2024-10-09T05:29:14","date_gmt":"2024-10-08T21:29:14","guid":{"rendered":"https:\/\/server.hk\/cnblog\/52763\/"},"modified":"2024-11-14T10:37:32","modified_gmt":"2024-11-14T02:37:32","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-ubuntu-18-04-lts-%e4%b8%8a%e5%ae%89%e8%a3%9d-microsoft-powershell-6-1-2","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/52763\/","title":{"rendered":"\u5982\u4f55\u5728 Ubuntu 18.04 LTS \u4e0a\u5b89\u88dd Microsoft PowerShell 6.1.2"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e5%9c%a8-ubuntu-18-04-lts-%e4%b8%8a%e5%ae%89%e8%a3%9d-microsoft-powershell-6-1-2-ALEsvSKWst\">\u5982\u4f55\u5728 Ubuntu 18.04 LTS \u4e0a\u5b89\u88dd Microsoft PowerShell 6.1.2<\/h1>\n<p>Microsoft PowerShell \u662f\u4e00\u500b\u5f37\u5927\u7684\u81ea\u52d5\u5316\u548c\u914d\u7f6e\u7ba1\u7406\u5de5\u5177\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u7cfb\u7d71\u7ba1\u7406\u548c\u96f2\u7aef\u670d\u52d9\u3002\u96a8\u8457 PowerShell Core \u7684\u63a8\u51fa\uff0cLinux \u7528\u6236\u4e5f\u80fd\u5920\u4eab\u53d7\u5230\u9019\u4e00\u5de5\u5177\u7684\u4fbf\u5229\u3002\u672c\u6587\u5c07\u6307\u5c0e\u60a8\u5982\u4f55\u5728 Ubuntu 18.04 LTS \u4e0a\u5b89\u88dd Microsoft PowerShell 6.1.2\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-ALEsvSKWst\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u5b89\u88dd\u4e4b\u524d\uff0c\u8acb\u78ba\u4fdd\u60a8\u7684\u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u60a8\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u4f86\u66f4\u65b0\u7cfb\u7d71\uff1a<\/p>\n<pre><code>sudo apt update\nsudo apt upgrade<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d%e5%bf%85%e8%a6%81%e7%9a%84%e4%be%9d%e8%b3%b4-ALEsvSKWst\">\u5b89\u88dd\u5fc5\u8981\u7684\u4f9d\u8cf4<\/h2>\n<p>\u5728\u5b89\u88dd PowerShell \u4e4b\u524d\uff0c\u60a8\u9700\u8981\u5b89\u88dd\u4e00\u4e9b\u5fc5\u8981\u7684\u4f9d\u8cf4\u5305\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5b89\u88dd\uff1a<\/p>\n<pre><code>sudo apt install -y wget apt-transport-https software-properties-common<\/code><\/pre>\n<h2 id=\"%e6%b7%bb%e5%8a%a0-microsoft-%e7%9a%84-gpg-%e5%af%86%e9%91%b0-ALEsvSKWst\">\u6dfb\u52a0 Microsoft \u7684 GPG \u5bc6\u9470<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u6dfb\u52a0 Microsoft \u7684 GPG \u5bc6\u9470\uff0c\u4ee5\u4fbf\u80fd\u5920\u9a57\u8b49\u4e0b\u8f09\u7684\u5305\u3002\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>wget -q \"https:\/\/packages.microsoft.com\/keys\/microsoft.asc\" -O- | sudo apt-key add -<\/code><\/pre>\n<h2 id=\"%e6%b7%bb%e5%8a%a0-powershell-%e7%9a%84-apt-%e5%ad%98%e5%84%b2%e5%ba%ab-ALEsvSKWst\">\u6dfb\u52a0 PowerShell \u7684 APT \u5b58\u5132\u5eab<\/h2>\n<p>\u7136\u5f8c\uff0c\u60a8\u9700\u8981\u5c07 PowerShell \u7684 APT \u5b58\u5132\u5eab\u6dfb\u52a0\u5230\u60a8\u7684\u7cfb\u7d71\u4e2d\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo add-apt-repository \"deb [arch=amd64] https:\/\/packages.microsoft.com\/repos\/ps\/ubuntu\/ bionic main\"<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-powershell-6-1-2-ALEsvSKWst\">\u5b89\u88dd PowerShell 6.1.2<\/h2>\n<p>\u73fe\u5728\uff0c\u60a8\u53ef\u4ee5\u66f4\u65b0 APT \u5b58\u5132\u5eab\u4e26\u5b89\u88dd PowerShell \u4e86\u3002\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo apt update\nsudo apt install -y powershell=6.1.2-1<\/code><\/pre>\n<p>\u9019\u5c07\u5b89\u88dd\u6307\u5b9a\u7248\u672c\u7684 PowerShell\u3002\u5982\u679c\u60a8\u5e0c\u671b\u5b89\u88dd\u6700\u65b0\u7248\u672c\uff0c\u53ef\u4ee5\u7701\u7565\u7248\u672c\u865f\uff1a<\/p>\n<pre><code>sudo apt install -y powershell<\/code><\/pre>\n<h2 id=\"%e5%95%9f%e5%8b%95-powershell-ALEsvSKWst\">\u555f\u52d5 PowerShell<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u5728\u7d42\u7aef\u4e2d\u8f38\u5165\u4ee5\u4e0b\u547d\u4ee4\u4f86\u555f\u52d5 PowerShell\uff1a<\/p>\n<pre><code>pwsh<\/code><\/pre>\n<p>\u9019\u5c07\u9032\u5165 PowerShell \u74b0\u5883\uff0c\u60a8\u53ef\u4ee5\u958b\u59cb\u4f7f\u7528\u5404\u7a2e\u547d\u4ee4\u548c\u8173\u672c\u3002<\/p>\n<h2 id=\"%e9%a9%97%e8%ad%89%e5%ae%89%e8%a3%9d-ALEsvSKWst\">\u9a57\u8b49\u5b89\u88dd<\/h2>\n<p>\u8981\u78ba\u8a8d PowerShell \u662f\u5426\u6b63\u78ba\u5b89\u88dd\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5\u7248\u672c\uff1a<\/p>\n<pre><code>$PSVersionTable.PSVersion<\/code><\/pre>\n<p>\u5982\u679c\u986f\u793a\u7684\u7248\u672c\u865f\u70ba 6.1.2\uff0c\u5247\u8868\u793a\u5b89\u88dd\u6210\u529f\u3002<\/p>\n<h2 id=\"%e5%b8%b8%e8%a6%8b%e5%95%8f%e9%a1%8c-ALEsvSKWst\">\u5e38\u898b\u554f\u984c<\/h2>\n<ul>\n<li><strong>\u5982\u4f55\u5378\u8f09 PowerShell\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5378\u8f09 PowerShell\uff1a\n<pre><code>sudo apt remove powershell<\/code><\/pre>\n<\/li>\n<li><strong>\u5982\u4f55\u66f4\u65b0 PowerShell\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0 PowerShell\uff1a\n<pre><code>sudo apt update\nsudo apt upgrade powershell<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-ALEsvSKWst\">\u7e3d\u7d50<\/h2>\n<p>\u5728 Ubuntu 18.04 LTS \u4e0a\u5b89\u88dd Microsoft PowerShell 6.1.2 \u662f\u4e00\u500b\u76f8\u5c0d\u7c21\u55ae\u7684\u904e\u7a0b\uff0c\u901a\u904e\u4e0a\u8ff0\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u5c07\u9019\u4e00\u5f37\u5927\u7684\u5de5\u5177\u6574\u5408\u5230\u60a8\u7684\u5de5\u4f5c\u6d41\u7a0b\u4e2d\u3002\u7121\u8ad6\u60a8\u662f\u7cfb\u7d71\u7ba1\u7406\u54e1\u9084\u662f\u958b\u767c\u8005\uff0cPowerShell \u90fd\u80fd\u5e6b\u52a9\u60a8\u63d0\u9ad8\u6548\u7387\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u670d\u52d9\uff0c\u8003\u616e\u4f7f\u7528\u6211\u5011\u7684<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u89e3\u6c7a\u65b9\u6848\uff0c\u70ba\u60a8\u7684\u61c9\u7528\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728 Ubuntu 18.04 LTS \u4e0a\u5b89\u88dd Microsoft PowerShell 6.1.2\uff0c\u7c21\u55ae\u6b65\u9a5f\u52a9\u4f60\u8f15\u9b06\u914d\u7f6e\u5f37\u5927\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-52763","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/52763","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=52763"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/52763\/revisions"}],"predecessor-version":[{"id":52764,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/52763\/revisions\/52764"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=52763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=52763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=52763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}