{"id":313,"date":"2026-04-08T22:51:08","date_gmt":"2026-04-08T14:51:08","guid":{"rendered":"https:\/\/www.resilence.cn\/?p=313"},"modified":"2026-04-08T22:51:08","modified_gmt":"2026-04-08T14:51:08","slug":"day-1-powershell%e7%ae%80%e4%bb%8b%e4%b8%8e%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/www.resilence.cn\/?p=313","title":{"rendered":"Day-1-PowerShell\u7b80\u4ecb\u4e0e\u73af\u5883\u642d\u5efa"},"content":{"rendered":"<h1>Day 1: PowerShell \u7b80\u4ecb\u4e0e\u73af\u5883\u642d\u5efa<\/h1>\n<blockquote>\n<p><strong>\u6b22\u8fce\u6765\u5230 PowerShell \u81ea\u52a8\u5316\u6559\u7a0b\u7684\u7b2c\u4e00\u5929\uff01<\/strong><br \/>\n\u672c\u6559\u7a0b\u4e13\u4e3a\u975e\u8ba1\u7b97\u673a\u4e13\u4e1a\u7684\u529e\u516c\u4eba\u5458\u8bbe\u8ba1\uff0c\u6211\u4eec\u5c06\u4ece\u96f6\u5f00\u59cb\uff0c\u4e00\u6b65\u6b65\u5e26\u4f60\u638c\u63e1 PowerShell \u81ea\u52a8\u5316\u6280\u80fd\u3002<\/p>\n<\/blockquote>\n<hr>\n<h2>\ud83d\udcda \u4eca\u65e5\u5b66\u4e60\u76ee\u6807<\/h2>\n<p>\u5b8c\u6210\u4eca\u5929\u7684\u5b66\u4e60\u540e\uff0c\u4f60\u5c06\u80fd\u591f\uff1a<\/p>\n<ul>\n<li>\u2705 \u7406\u89e3\u4ec0\u4e48\u662f PowerShell \u4ee5\u53ca\u5b83\u80fd\u4e3a\u4f60\u505a\u4ec0\u4e48<\/li>\n<li>\u2705 \u5728\u4f60\u7684\u7535\u8111\u4e0a\u5b89\u88c5\u548c\u914d\u7f6e PowerShell<\/li>\n<li>\u2705 \u638c\u63e1 PowerShell \u7684\u57fa\u672c\u64cd\u4f5c\u754c\u9762<\/li>\n<li>\u2705 \u8fd0\u884c\u4f60\u7684\u7b2c\u4e00\u4e2a PowerShell \u547d\u4ee4<\/li>\n<li>\u2705 \u7406\u89e3 PowerShell \u7684\u6838\u5fc3\u6982\u5ff5\uff08\u547d\u4ee4\u3001\u53c2\u6570\u3001\u5bf9\u8c61\uff09<\/li>\n<li>\u2705 \u914d\u7f6e PowerShell \u4f7f\u5176\u66f4\u6613\u7528<\/li>\n<\/ul>\n<p><strong>\u9884\u8ba1\u5b66\u4e60\u65f6\u95f4<\/strong>: 60-90 \u5206\u949f<\/p>\n<hr>\n<h2>\ud83c\udfaf \u4ec0\u4e48\u662f PowerShell\uff1f<\/h2>\n<h3>\u7b80\u5355\u6765\u8bf4<\/h3>\n<p>PowerShell \u662f\u5fae\u8f6f\u5f00\u53d1\u7684\u4e00\u4e2a<strong>\u547d\u4ee4\u884c\u5de5\u5177\u548c\u811a\u672c\u8bed\u8a00<\/strong>\u3002\u60f3\u8c61\u4e00\u4e0b\uff0c\u4f60\u5e73\u65f6\u7528\u9f20\u6807\u70b9\u51fb\u56fe\u6807\u3001\u62d6\u62fd\u6587\u4ef6\u6765\u64cd\u4f5c\u7535\u8111\uff0c\u800c PowerShell \u5c31\u662f\u7528<strong>\u6587\u5b57\u547d\u4ee4<\/strong>\u6765\u5b8c\u6210\u540c\u6837\u7684\u64cd\u4f5c\u3002<\/p>\n<h3>\u4e3a\u4ec0\u4e48\u9700\u8981\u5b66\u4e60 PowerShell\uff1f<\/h3>\n<p>\u4f5c\u4e3a\u4e00\u540d\u529e\u516c\u4eba\u5458\uff0c\u4f60\u53ef\u80fd\u4f1a\u9047\u5230\u8fd9\u4e9b\u573a\u666f\uff1a<\/p>\n<h4>\u573a\u666f 1\uff1a\u6279\u91cf\u91cd\u547d\u540d\u6587\u4ef6<\/h4>\n<blockquote>\n<p><strong>\u95ee\u9898<\/strong>: \u6587\u4ef6\u5939\u91cc\u6709 100 \u4e2a\u7167\u7247\u6587\u4ef6\uff0c\u9700\u8981\u6309\u65e5\u671f\u91cd\u547d\u540d\u3002<br \/>\n<strong>\u4e0d\u7528 PowerShell<\/strong>: \u624b\u52a8\u91cd\u547d\u540d 100 \u6b21\uff0c\u8017\u65f6 30 \u5206\u949f\u3002<br \/>\n<strong>\u7528 PowerShell<\/strong>: \u4e00\u884c\u547d\u4ee4\uff0c3 \u79d2\u641e\u5b9a\u3002<\/p>\n<\/blockquote>\n<h4>\u573a\u666f 2\uff1a\u5b9a\u671f\u751f\u6210\u62a5\u8868<\/h4>\n<blockquote>\n<p><strong>\u95ee\u9898<\/strong>: \u6bcf\u5468\u8981\u4ece\u591a\u4e2a Excel \u6587\u4ef6\u63d0\u53d6\u6570\u636e\u751f\u6210\u6c47\u603b\u8868\u3002<br \/>\n<strong>\u4e0d\u7528 PowerShell<\/strong>: \u624b\u52a8\u590d\u5236\u7c98\u8d34\uff0c\u5bb9\u6613\u51fa\u9519\uff0c\u8017\u65f6 1 \u5c0f\u65f6\u3002<br \/>\n<strong>\u7528 PowerShell<\/strong>: \u8fd0\u884c\u811a\u672c\uff0c1 \u5206\u949f\u5b8c\u6210\u3002<\/p>\n<\/blockquote>\n<h4>\u573a\u666f 3\uff1a\u67e5\u627e\u7279\u5b9a\u6587\u4ef6<\/h4>\n<blockquote>\n<p><strong>\u95ee\u9898<\/strong>: \u5728 D \u76d8\u51e0\u5343\u4e2a\u6587\u4ef6\u4e2d\u627e\u51fa\u6628\u5929\u4fee\u6539\u8fc7\u7684\u6240\u6709 PDF \u6587\u4ef6\u3002<br \/>\n<strong>\u4e0d\u7528 PowerShell<\/strong>: \u9010\u4e2a\u6587\u4ef6\u5939\u67e5\u627e\uff0c\u8017\u65f6 20 \u5206\u949f\u3002<br \/>\n<strong>\u7528 PowerShell<\/strong>: \u4e00\u884c\u547d\u4ee4\uff0c5 \u79d2\u5b9a\u4f4d\u3002<\/p>\n<\/blockquote>\n<h3>PowerShell \u7684\u6838\u5fc3\u4f18\u52bf<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u4f18\u52bf<\/th>\n<th>\u8bf4\u660e<\/th>\n<th>\u5b9e\u9645\u5e94\u7528<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>\u81ea\u52a8\u5316<\/strong><\/td>\n<td>\u81ea\u52a8\u91cd\u590d\u6027\u4efb\u52a1<\/td>\n<td>\u6279\u91cf\u5904\u7406\u6587\u4ef6\u3001\u5b9a\u65f6\u4efb\u52a1<\/td>\n<\/tr>\n<tr>\n<td><strong>\u6279\u91cf\u64cd\u4f5c<\/strong><\/td>\n<td>\u4e00\u6b21\u64cd\u4f5c\u591a\u4e2a\u5bf9\u8c61<\/td>\n<td>\u91cd\u547d\u540d 1000 \u4e2a\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td><strong>\u7cfb\u7edf\u96c6\u6210<\/strong><\/td>\n<td>\u6df1\u5ea6\u8bbf\u95ee Windows \u7cfb\u7edf<\/td>\n<td>\u7ba1\u7406\u670d\u52a1\u3001\u6ce8\u518c\u8868\u3001\u8fdb\u7a0b<\/td>\n<\/tr>\n<tr>\n<td><strong>\u6613\u5b66\u6613\u7528<\/strong><\/td>\n<td>\u8bed\u6cd5\u63a5\u8fd1\u81ea\u7136\u8bed\u8a00<\/td>\n<td><code>Get-Process<\/code> \u83b7\u53d6\u8fdb\u7a0b<\/td>\n<\/tr>\n<tr>\n<td><strong>\u514d\u8d39\u5185\u7f6e<\/strong><\/td>\n<td>Windows \u81ea\u5e26\uff0c\u65e0\u9700\u5b89\u88c5<\/td>\n<td>\u6253\u5f00\u5373\u7528<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr>\n<h2>\ud83d\udca1 PowerShell vs \u4f20\u7edf\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09<\/h2>\n<p>\u4f60\u53ef\u80fd\u542c\u8bf4\u8fc7\u6216\u7528\u8fc7 Windows \u7684&quot;\u547d\u4ee4\u63d0\u793a\u7b26&quot;\uff08\u9ed1\u6846\u6846\uff09\u3002PowerShell \u548c\u5b83\u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/p>\n<table>\n<thead>\n<tr>\n<th>\u7279\u6027<\/th>\n<th>CMD\uff08\u547d\u4ee4\u63d0\u793a\u7b26\uff09<\/th>\n<th>PowerShell<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>\u8bde\u751f\u5e74\u4ee3<\/strong><\/td>\n<td>1980 \u5e74\u4ee3<\/td>\n<td>2006 \u5e74<\/td>\n<\/tr>\n<tr>\n<td><strong>\u5904\u7406\u5bf9\u8c61<\/strong><\/td>\n<td>\u6587\u672c\u5b57\u7b26\u4e32<\/td>\n<td>\u5bf9\u8c61\uff08\u7ed3\u6784\u5316\u6570\u636e\uff09<\/td>\n<\/tr>\n<tr>\n<td><strong>\u547d\u4ee4\u547d\u540d<\/strong><\/td>\n<td>\u7b80\u5199\uff08dir, copy\uff09<\/td>\n<td>\u52a8\u8bcd-\u540d\u8bcd\uff08Get-ChildItem, Copy-Item\uff09<\/td>\n<\/tr>\n<tr>\n<td><strong>\u811a\u672c\u80fd\u529b<\/strong><\/td>\n<td>\u6709\u9650<\/td>\n<td>\u5f3a\u5927\uff08\u7c7b\u4f3c\u7f16\u7a0b\u8bed\u8a00\uff09<\/td>\n<\/tr>\n<tr>\n<td><strong>\u53ef\u6269\u5c55\u6027<\/strong><\/td>\n<td>\u5dee<\/td>\n<td>\u4f18\u79c0\uff08\u53ef\u52a0\u8f7d\u6a21\u5757\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u7c7b\u6bd4<\/strong>\uff1a<\/p>\n<ul>\n<li>CMD \u50cf<strong>\u6253\u5b57\u673a<\/strong>\uff1a\u53ea\u80fd\u5904\u7406\u6587\u5b57\uff0c\u8f93\u51fa\u7eaf\u6587\u672c<\/li>\n<li>PowerShell \u50cf<strong>Excel<\/strong>\uff1a\u5904\u7406\u7684\u662f\u6709\u7ed3\u6784\u7684\u6570\u636e\uff08\u5bf9\u8c61\uff09\uff0c\u53ef\u4ee5\u7b5b\u9009\u3001\u6392\u5e8f\u3001\u8ba1\u7b97<\/li>\n<\/ul>\n<hr>\n<h2>\ud83d\udd27 \u73af\u5883\u642d\u5efa<\/h2>\n<h3>\u7b2c\u4e00\u6b65\uff1a\u68c0\u67e5\u4f60\u7684\u7cfb\u7edf<\/h3>\n<p>PowerShell \u5df2\u7ecf\u5185\u7f6e\u5728 Windows 7 \u53ca\u4ee5\u540e\u7684\u7cfb\u7edf\u4e2d\u3002\u8ba9\u6211\u4eec\u5148\u68c0\u67e5\u4f60\u7535\u8111\u4e0a\u7684 PowerShell \u7248\u672c\u3002<\/p>\n<h4>\u6253\u5f00 PowerShell<\/h4>\n<p><strong>\u65b9\u6cd5 1\uff1a\u901a\u8fc7\u5f00\u59cb\u83dc\u5355<\/strong>\uff08\u63a8\u8350\uff09<\/p>\n<ol>\n<li>\u70b9\u51fb&quot;\u5f00\u59cb&quot;\u6309\u94ae<\/li>\n<li>\u8f93\u5165 <code>PowerShell<\/code><\/li>\n<li>\u5728\u641c\u7d22\u7ed3\u679c\u4e2d\u627e\u5230&quot;Windows PowerShell&quot;<\/li>\n<li>\u53f3\u952e\u70b9\u51fb\uff0c\u9009\u62e9&quot;\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c&quot;<\/li>\n<\/ol>\n<p><strong>\u65b9\u6cd5 2\uff1a\u901a\u8fc7\u8fd0\u884c\u5bf9\u8bdd\u6846<\/strong><\/p>\n<ol>\n<li>\u6309 <code>Win + R<\/code> \u952e<\/li>\n<li>\u8f93\u5165 <code>powershell<\/code><\/li>\n<li>\u6309 <code>Ctrl + Shift + Enter<\/code>\uff08\u7ba1\u7406\u5458\u8fd0\u884c\uff09<\/li>\n<\/ol>\n<p><strong>\u4e3a\u4ec0\u4e48\u8981&quot;\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c&quot;\uff1f<\/strong><br \/>\n\u67d0\u4e9b\u64cd\u4f5c\u9700\u8981\u7ba1\u7406\u5458\u6743\u9650\uff08\u5982\u4fee\u6539\u7cfb\u7edf\u8bbe\u7f6e\u3001\u5b89\u88c5\u8f6f\u4ef6\uff09\u3002\u5efa\u8bae\u517b\u6210\u7ba1\u7406\u5458\u8fd0\u884c PowerShell \u7684\u4e60\u60ef\u3002<\/p>\n<h4>\u68c0\u67e5 PowerShell \u7248\u672c<\/h4>\n<p>\u6253\u5f00 PowerShell \u540e\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u56de\u8f66\uff1a<\/p>\n<pre><code class=\"language-powershell\">$PSVersionTable.PSVersion\n<\/code><\/pre>\n<p>\u4f60\u4f1a\u770b\u5230\u7c7b\u4f3c\u8fd9\u6837\u7684\u8f93\u51fa\uff1a<\/p>\n<pre><code>Major  Minor  Build  Revision\n-----  -----  -----  --------\n5      1      19041  1\n<\/code><\/pre>\n<p><strong>\u7248\u672c\u89e3\u8bfb<\/strong>\uff1a<\/p>\n<ul>\n<li><strong>PowerShell 5.x<\/strong>: Windows 10\/11 \u81ea\u5e26\u7248\u672c\uff0c\u672c\u6559\u7a0b\u57fa\u4e8e\u6b64\u7248\u672c<\/li>\n<li><strong>PowerShell 7+<\/strong>: \u6700\u65b0\u7248\u672c\uff08\u8de8\u5e73\u53f0\uff09\uff0c\u9700\u8981\u5355\u72ec\u5b89\u88c5\uff08\u53ef\u9009\uff09<\/li>\n<\/ul>\n<p>\u5982\u679c\u4f60\u7684\u7248\u672c\u662f 5.0 \u6216\u4ee5\u4e0a\uff0c\u606d\u559c\uff01\u4f60\u53ef\u4ee5\u76f4\u63a5\u5f00\u59cb\u5b66\u4e60\u4e86\u3002<\/p>\n<h3>\u7b2c\u4e8c\u6b65\uff1a\u5b89\u88c5 PowerShell 7\uff08\u53ef\u9009\u4f46\u63a8\u8350\uff09<\/h3>\n<p>PowerShell 7\uff08\u539f\u540d PowerShell Core\uff09\u662f\u6700\u65b0\u7248\u672c\uff0c\u6027\u80fd\u66f4\u597d\uff0c\u529f\u80fd\u66f4\u5f3a\u3002<\/p>\n<h4>\u5b89\u88c5\u6b65\u9aa4<\/h4>\n<ol>\n<li>\n<p><strong>\u8bbf\u95ee\u5b98\u65b9\u7f51\u7ad9<\/strong><br \/>\n\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u8bbf\u95ee\uff1ahttps:\/\/github.com\/PowerShell\/PowerShell\/releases<\/p>\n<\/li>\n<li>\n<p><strong>\u4e0b\u8f7d\u5b89\u88c5\u5305<\/strong><br \/>\n\u627e\u5230\u6700\u65b0\u7a33\u5b9a\u7248\uff08\u5982 PowerShell 7.4.x\uff09\uff0c\u4e0b\u8f7d <code>PowerShell-7.4.x-win-x64.msi<\/code><\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f<\/strong><br \/>\n\u53cc\u51fb\u4e0b\u8f7d\u7684 MSI \u6587\u4ef6\uff0c\u6309\u63d0\u793a\u5b89\u88c5\uff1a<\/p>\n<ul>\n<li>\u52fe\u9009&quot;Add PowerShell to Path Environment Variable&quot;\uff08\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\uff09<\/li>\n<li>\u52fe\u9009&quot;Register Windows Event Logging&quot;\uff08\u6ce8\u518c\u4e8b\u4ef6\u65e5\u5fd7\uff09<\/li>\n<li>\u5176\u4ed6\u9009\u9879\u4fdd\u6301\u9ed8\u8ba4<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><br \/>\n\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u65b0\u7684 PowerShell \u7a97\u53e3\uff0c\u8f93\u5165\uff1a<\/p>\n<pre><code class=\"language-powershell\">pwsh --version\n<\/code><\/pre>\n<p>\u5e94\u663e\u793a\uff1a<code>7.4.x<\/code><\/p>\n<\/li>\n<\/ol>\n<p><strong>\u6ce8\u610f<\/strong>\uff1a\u5b89\u88c5 PowerShell 7 \u4e0d\u4f1a\u8986\u76d6\u539f\u6709\u7684 PowerShell 5.x\uff0c\u4e24\u8005\u53ef\u4ee5\u5171\u5b58\u3002<\/p>\n<h3>\u7b2c\u4e09\u6b65\uff1a\u5b89\u88c5 VS Code\uff08\u63a8\u8350\u4f46\u975e\u5fc5\u9700\uff09<\/h3>\n<p>\u867d\u7136 PowerShell \u81ea\u5e26\u7684\u811a\u672c\u7f16\u8f91\u5668\uff08ISE\uff09\u53ef\u7528\uff0c\u4f46 <strong>Visual Studio Code\uff08VS Code\uff09<\/strong> \u662f\u66f4\u73b0\u4ee3\u3001\u66f4\u5f3a\u5927\u7684\u9009\u62e9\u3002<\/p>\n<h4>\u5b89\u88c5 VS Code<\/h4>\n<ol>\n<li>\u8bbf\u95ee\uff1ahttps:\/\/code.visualstudio.com\/<\/li>\n<li>\u4e0b\u8f7d Windows \u7248\u672c<\/li>\n<li>\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\uff0c\u6309\u63d0\u793a\u5b8c\u6210\u5b89\u88c5<\/li>\n<\/ol>\n<h4>\u5b89\u88c5 PowerShell \u6269\u5c55<\/h4>\n<ol>\n<li>\u6253\u5f00 VS Code<\/li>\n<li>\u70b9\u51fb\u5de6\u4fa7\u7684\u6269\u5c55\u56fe\u6807\uff08\u6216\u6309 <code>Ctrl + Shift + X<\/code>\uff09<\/li>\n<li>\u641c\u7d22 &quot;PowerShell&quot;<\/li>\n<li>\u5b89\u88c5 Microsoft \u5b98\u65b9\u7684 PowerShell \u6269\u5c55<\/li>\n<\/ol>\n<p><strong>VS Code \u7684\u4f18\u52bf<\/strong>\uff1a<\/p>\n<ul>\n<li>\u8bed\u6cd5\u9ad8\u4eae<\/li>\n<li>\u667a\u80fd\u63d0\u793a<\/li>\n<li>\u4ee3\u7801\u8c03\u8bd5<\/li>\n<li>Git \u96c6\u6210<\/li>\n<li>\u4e30\u5bcc\u7684\u63d2\u4ef6\u751f\u6001<\/li>\n<\/ul>\n<hr>\n<h2>\ud83d\ude80 \u4f60\u7684\u7b2c\u4e00\u4e2a PowerShell \u547d\u4ee4<\/h2>\n<p>\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u8fd0\u884c\u4f60\u7684\u7b2c\u4e00\u4e2a PowerShell \u547d\u4ee4\uff01<\/p>\n<h3>\u793a\u4f8b 1\uff1a\u95ee\u5019\u4e16\u754c<\/h3>\n<p>\u5728 PowerShell \u7a97\u53e3\u4e2d\u8f93\u5165\uff1a<\/p>\n<pre><code class=\"language-powershell\">Write-Host &quot;Hello, PowerShell!&quot;\n<\/code><\/pre>\n<p>\u7136\u540e\u6309 <code>Enter<\/code> \u952e\u3002<\/p>\n<p><strong>\u8f93\u51fa<\/strong>\uff1a<\/p>\n<pre><code>Hello, PowerShell!\n<\/code><\/pre>\n<p><strong>\u53d1\u751f\u4e86\u4ec0\u4e48\uff1f<\/strong><\/p>\n<ul>\n<li><code>Write-Host<\/code>: \u547d\u4ee4\uff08\u663e\u793a\u6587\u672c\uff09<\/li>\n<li><code>&quot;Hello, PowerShell!&quot;<\/code>: \u53c2\u6570\uff08\u8981\u663e\u793a\u7684\u5185\u5bb9\uff09<\/li>\n<li>\u547d\u4ee4\u548c\u53c2\u6570\u4e4b\u95f4\u7528\u7a7a\u683c\u5206\u9694<\/li>\n<\/ul>\n<h3>\u793a\u4f8b 2\uff1a\u83b7\u53d6\u5f53\u524d\u65e5\u671f<\/h3>\n<pre><code class=\"language-powershell\">Get-Date\n<\/code><\/pre>\n<p><strong>\u8f93\u51fa<\/strong>\uff1a<\/p>\n<pre><code>2026\u5e743\u670829\u65e5 \u661f\u671f\u65e5 14:27:35\n<\/code><\/pre>\n<h3>\u793a\u4f8b 3\uff1a\u67e5\u770b\u5f53\u524d\u76ee\u5f55\u5185\u5bb9<\/h3>\n<pre><code class=\"language-powershell\">Get-ChildItem\n<\/code><\/pre>\n<p>\u6216\u4f7f\u7528\u7b80\u5199\u522b\u540d\uff1a<\/p>\n<pre><code class=\"language-powershell\">dir\n<\/code><\/pre>\n<p>\u6216\uff1a<\/p>\n<pre><code class=\"language-powershell\">ls\n<\/code><\/pre>\n<p><strong>\u8f93\u51fa\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code>    \u76ee\u5f55: C:\\Users\\YourName\n\nMode                 LastWriteTime         Length Name\n----                 -------------         ------ ----\nd----          2026\/3\/28     10:30                Documents\nd----          2026\/3\/29      9:15                Downloads\n-a---          2026\/3\/29     14:20           1024 report.xlsx\n<\/code><\/pre>\n<p><strong>\u91cd\u8981\u6982\u5ff5<\/strong>\uff1a<\/p>\n<ul>\n<li>PowerShell \u7684\u547d\u4ee4\u9075\u5faa<strong>\u52a8\u8bcd-\u540d\u8bcd<\/strong>\u547d\u540d\u89c4\u8303<\/li>\n<li><code>Get<\/code>\uff08\u83b7\u53d6\uff09\u3001<code>Set<\/code>\uff08\u8bbe\u7f6e\uff09\u3001<code>New<\/code>\uff08\u65b0\u5efa\uff09\u3001<code>Remove<\/code>\uff08\u5220\u9664\uff09\u662f\u5e38\u89c1\u52a8\u8bcd<\/li>\n<li>\u5927\u5c0f\u5199\u4e0d\u654f\u611f\uff08<code>get-date<\/code> \u548c <code>Get-Date<\/code> \u4e00\u6837\uff09<\/li>\n<li>\u652f\u6301\u522b\u540d\uff08\u7b80\u5199\uff09\uff0c\u5982 <code>dir<\/code> \u662f <code>Get-ChildItem<\/code> \u7684\u522b\u540d<\/li>\n<\/ul>\n<hr>\n<h2>\ud83e\udde0 PowerShell \u6838\u5fc3\u6982\u5ff5<\/h2>\n<h3>\u6982\u5ff5 1\uff1aCmdlet\uff08\u547d\u4ee4\uff09<\/h3>\n<p>Cmdlet\uff08\u8bfb\u4f5c&quot;command-let&quot;\uff09\u662f PowerShell \u7684\u57fa\u672c\u547d\u4ee4\u5355\u5143\u3002<\/p>\n<p><strong>\u7279\u70b9<\/strong>\uff1a<\/p>\n<ul>\n<li>\u683c\u5f0f\uff1a<code>\u52a8\u8bcd-\u540d\u8bcd<\/code>\uff08\u5982 <code>Get-Process<\/code>\uff09<\/li>\n<li>\u53d1\u97f3\uff1a&quot;command-let&quot;\uff08\u53d1\u97f3\u4e3a &quot;commandlet&quot;\uff09<\/li>\n<li>\u529f\u80fd\u5355\u4e00\uff0c\u804c\u8d23\u660e\u786e<\/li>\n<\/ul>\n<p><strong>\u5e38\u7528 Cmdlet \u793a\u4f8b<\/strong>\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>Cmdlet<\/th>\n<th>\u529f\u80fd<\/th>\n<th>\u522b\u540d<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>Get-ChildItem<\/code><\/td>\n<td>\u5217\u51fa\u76ee\u5f55\u5185\u5bb9<\/td>\n<td><code>dir<\/code>, <code>ls<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Get-Location<\/code><\/td>\n<td>\u83b7\u53d6\u5f53\u524d\u8def\u5f84<\/td>\n<td><code>pwd<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Set-Location<\/code><\/td>\n<td>\u5207\u6362\u76ee\u5f55<\/td>\n<td><code>cd<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Get-Process<\/code><\/td>\n<td>\u83b7\u53d6\u8fd0\u884c\u8fdb\u7a0b<\/td>\n<td><code>ps<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Get-Service<\/code><\/td>\n<td>\u83b7\u53d6\u7cfb\u7edf\u670d\u52a1<\/td>\n<td>&#8211;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u6982\u5ff5 2\uff1a\u53c2\u6570<\/h3>\n<p>\u53c2\u6570\u662f\u4f20\u9012\u7ed9\u547d\u4ee4\u7684\u989d\u5916\u4fe1\u606f\u3002<\/p>\n<p><strong>\u8bed\u6cd5<\/strong>\uff1a<code>\u547d\u4ee4 -\u53c2\u6570\u540d \u53c2\u6570\u503c<\/code><\/p>\n<p><strong>\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u83b7\u53d6\u7279\u5b9a\u8fdb\u7a0b\nGet-Process -Name &quot;notepad&quot;\n\n# \u5207\u6362\u5230\u6307\u5b9a\u76ee\u5f55\nSet-Location -Path &quot;C:\\Windows&quot;\n\n# \u53c2\u6570\u53ef\u4ee5\u7b80\u5199\uff08-Path \u53ef\u4ee5\u5199\u6210 -p \u6216\u7701\u7565\uff09\nSet-Location &quot;C:\\Windows&quot;\n<\/code><\/pre>\n<p><strong>\u5e38\u89c1\u53c2\u6570\u7c7b\u578b<\/strong>\uff1a<\/p>\n<ul>\n<li><code>-Name<\/code>: \u6307\u5b9a\u540d\u79f0<\/li>\n<li><code>-Path<\/code>: \u6307\u5b9a\u8def\u5f84<\/li>\n<li><code>-Force<\/code>: \u5f3a\u5236\u6267\u884c\uff08\u65e0\u9700\u786e\u8ba4\uff09<\/li>\n<li><code>-Verbose<\/code>: \u663e\u793a\u8be6\u7ec6\u4fe1\u606f<\/li>\n<li><code>-WhatIf<\/code>: \u6a21\u62df\u8fd0\u884c\uff08\u663e\u793a\u5c06\u53d1\u751f\u4ec0\u4e48\u4f46\u4e0d\u5b9e\u9645\u6267\u884c\uff09<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b -WhatIf \u53c2\u6570<\/strong>\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u67e5\u770b\u4f1a\u53d1\u751f\u4ec0\u4e48\uff0c\u4f46\u4e0d\u5b9e\u9645\u5220\u9664\nRemove-Item &quot;test.txt&quot; -WhatIf\n<\/code><\/pre>\n<h3>\u6982\u5ff5 3\uff1a\u5bf9\u8c61<\/h3>\n<p>\u8fd9\u662f PowerShell \u6700\u91cd\u8981\u7684\u6982\u5ff5\uff01<\/p>\n<p><strong>PowerShell \u4e0d\u5904\u7406\u6587\u672c\uff0c\u800c\u662f\u5904\u7406\u5bf9\u8c61\u3002<\/strong><\/p>\n<p><strong>\u5bf9\u8c61<\/strong>\u662f\u5177\u6709\u5c5e\u6027\u548c\u65b9\u6cd5\u7684\u5b9e\u4f53\uff1a<\/p>\n<ul>\n<li><strong>\u5c5e\u6027<\/strong>\uff1a\u5bf9\u8c61\u7684\u7279\u5f81\uff08\u5982\u6587\u4ef6\u540d\u3001\u5927\u5c0f\u3001\u521b\u5efa\u65f6\u95f4\uff09<\/li>\n<li><strong>\u65b9\u6cd5<\/strong>\uff1a\u5bf9\u8c61\u53ef\u4ee5\u6267\u884c\u7684\u64cd\u4f5c\uff08\u5982\u6587\u4ef6\u53ef\u4ee5\u5220\u9664\u3001\u79fb\u52a8\uff09<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u83b7\u53d6\u6587\u4ef6\u5bf9\u8c61\n$file = Get-Item &quot;report.xlsx&quot;\n\n# \u8bbf\u95ee\u5c5e\u6027\n$file.Name      # \u6587\u4ef6\u540d\n$file.Length    # \u6587\u4ef6\u5927\u5c0f\uff08\u5b57\u8282\uff09\n$file.CreationTime  # \u521b\u5efa\u65f6\u95f4\n\n# \u8c03\u7528\u65b9\u6cd5\n$file.Delete()  # \u5220\u9664\u6587\u4ef6\n<\/code><\/pre>\n<p><strong>\u4e3a\u4ec0\u4e48\u5bf9\u8c61\u6bd4\u6587\u672c\u66f4\u597d\uff1f<\/strong><\/p>\n<p>\u5bf9\u6bd4 CMD \u7684\u8f93\u51fa\uff08\u7eaf\u6587\u672c\uff09\uff1a<\/p>\n<pre><code>2026\/03\/29  14:20    1,024 report.xlsx\n<\/code><\/pre>\n<p>PowerShell \u7684\u8f93\u51fa\uff08\u5bf9\u8c61\uff09\uff1a<\/p>\n<pre><code class=\"language-powershell\">$file.Name        # \u53ea\u83b7\u53d6\u6587\u4ef6\u540d\n$file.Length \/ 1KB # \u8ba1\u7b97\u6587\u4ef6\u5927\u5c0f\uff08KB\uff09\n$file.Extension   # \u83b7\u53d6\u6269\u5c55\u540d\n<\/code><\/pre>\n<p>\u4f60\u53ef\u4ee5<strong>\u7cbe\u786e\u8bbf\u95ee\u5bf9\u8c61\u7684\u4efb\u4f55\u5c5e\u6027<\/strong>\uff0c\u800c\u4e0d\u9700\u8981\u89e3\u6790\u6587\u672c\uff01<\/p>\n<h3>\u6982\u5ff5 4\uff1a\u7ba1\u9053\uff08Pipeline\uff09<\/h3>\n<p>\u7ba1\u9053\u7b26\u53f7 <code>|<\/code> \u53ef\u4ee5\u5c06\u4e00\u4e2a\u547d\u4ee4\u7684\u8f93\u51fa\u4f20\u9012\u7ed9\u4e0b\u4e00\u4e2a\u547d\u4ee4\u3002<\/p>\n<p><strong>\u8bed\u6cd5<\/strong>\uff1a<code>\u547d\u4ee41 | \u547d\u4ee42 | \u547d\u4ee43<\/code><\/p>\n<p><strong>\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u83b7\u53d6\u6240\u6709\u8fdb\u7a0b\uff0c\u7b5b\u9009\u51fa notepad \u8fdb\u7a0b\uff0c\u505c\u6b62\u5b83\nGet-Process | Where-Object { $_.Name -eq &quot;notepad&quot; } | Stop-Process\n<\/code><\/pre>\n<p><strong>\u5206\u89e3<\/strong>\uff1a<\/p>\n<ol>\n<li><code>Get-Process<\/code>: \u83b7\u53d6\u6240\u6709\u8fdb\u7a0b<\/li>\n<li><code>|<\/code>: \u4f20\u9012\u7ed9\u4e0b\u4e00\u547d\u4ee4<\/li>\n<li><code>Where-Object { $_.Name -eq &quot;notepad&quot; }<\/code>: \u7b5b\u9009\u51fa\u540d\u79f0\u4e3a notepad \u7684\u8fdb\u7a0b<\/li>\n<li><code>|<\/code>: \u4f20\u9012\u7ed9\u4e0b\u4e00\u547d\u4ee4<\/li>\n<li><code>Stop-Process<\/code>: \u505c\u6b62\u8fd9\u4e9b\u8fdb\u7a0b<\/li>\n<\/ol>\n<p><strong>\u7ba1\u9053\u7684\u5f3a\u5927\u4e4b\u5904<\/strong>\uff1a\u6bcf\u4e2a\u547d\u4ee4\u53ea\u505a\u4e00\u4ef6\u4e8b\uff0c\u7ec4\u5408\u8d77\u6765\u53ef\u4ee5\u5b8c\u6210\u590d\u6742\u4efb\u52a1\uff01<\/p>\n<hr>\n<h2>\ud83c\udfa8 \u914d\u7f6e PowerShell \u4f7f\u5176\u66f4\u6613\u7528<\/h2>\n<h3>1. \u4fee\u6539\u7a97\u53e3\u5916\u89c2<\/h3>\n<p>\u53f3\u952e\u70b9\u51fb PowerShell \u7a97\u53e3\u6807\u9898\u680f \u2192 \u5c5e\u6027\uff1a<\/p>\n<p><strong>\u5efa\u8bae\u8bbe\u7f6e<\/strong>\uff1a<\/p>\n<ul>\n<li><strong>\u5b57\u4f53<\/strong>\uff1aConsolas \u6216 Cascadia Mono\uff08\u7b49\u5bbd\u5b57\u4f53\uff09<\/li>\n<li><strong>\u5b57\u53f7<\/strong>\uff1a16-18\uff08\u6839\u636e\u663e\u793a\u5668\u8c03\u6574\uff09<\/li>\n<li><strong>\u989c\u8272<\/strong>\uff1a\n<ul>\n<li>\u5c4f\u5e55\u80cc\u666f\uff1a\u9ed1\u8272\uff08\u6df1\u8272\uff09<\/li>\n<li>\u5c4f\u5e55\u6587\u5b57\uff1a\u6d45\u7eff\u8272\u6216\u767d\u8272<\/li>\n<li>\u5f39\u51fa\u5f0f\u80cc\u666f\uff1a\u6df1\u7070\u8272<\/li>\n<li>\u5f39\u51fa\u5f0f\u6587\u5b57\uff1a\u767d\u8272<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u7a97\u53e3\u5927\u5c0f<\/strong>\uff1a\u5bbd\u5ea6 120\uff0c\u9ad8\u5ea6 30<\/li>\n<\/ul>\n<h3>2. \u542f\u7528\u81ea\u52a8\u8865\u5168<\/h3>\n<p>PowerShell \u652f\u6301 Tab \u952e\u81ea\u52a8\u8865\u5168\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u8f93\u5165\u90e8\u5206\u547d\u4ee4\u540e\u6309 Tab \u952e\nGet-Ch[Tab]          # \u81ea\u52a8\u8865\u5168\u4e3a Get-ChildItem\nSet-Loc[Tab]         # \u81ea\u52a8\u8865\u5168\u4e3a Set-Location\n<\/code><\/pre>\n<p><strong>\u53c2\u6570\u81ea\u52a8\u8865\u5168<\/strong>\uff1a<\/p>\n<pre><code class=\"language-powershell\">Get-Process -[Tab]   # \u663e\u793a\u6240\u6709\u53ef\u7528\u53c2\u6570\n<\/code><\/pre>\n<h3>3. \u67e5\u770b\u547d\u4ee4\u5386\u53f2<\/h3>\n<p>\u6309 <code>\u2191<\/code> \u548c <code>\u2193<\/code> \u7bad\u5934\u952e\u53ef\u4ee5\u6d4f\u89c8\u5386\u53f2\u547d\u4ee4\u3002<\/p>\n<p>\u8f93\u5165 <code>history<\/code> \u6216\u522b\u540d <code>h<\/code> \u67e5\u770b\u5b8c\u6574\u5386\u53f2\u8bb0\u5f55\uff1a<\/p>\n<pre><code class=\"language-powershell\">history\n<\/code><\/pre>\n<h3>4. \u83b7\u53d6\u5e2e\u52a9<\/h3>\n<p>PowerShell \u5185\u7f6e\u4e86\u5b8c\u5584\u7684\u5e2e\u52a9\u7cfb\u7edf\u3002<\/p>\n<p><strong>\u67e5\u770b\u547d\u4ee4\u5e2e\u52a9<\/strong>\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u663e\u793a\u57fa\u672c\u5e2e\u52a9\nGet-Help Get-Process\n\n# \u663e\u793a\u8be6\u7ec6\u793a\u4f8b\nGet-Help Get-Process -Examples\n\n# \u663e\u793a\u5b8c\u6574\u5e2e\u52a9\nGet-Help Get-Process -Full\n\n# \u663e\u793a\u5728\u7ebf\u5e2e\u52a9\uff08\u6d4f\u89c8\u5668\uff09\nGet-Help Get-Process -Online\n<\/code><\/pre>\n<p><strong>\u641c\u7d22\u547d\u4ee4<\/strong>\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u641c\u7d22\u5305\u542b &quot;service&quot; \u7684\u547d\u4ee4\nGet-Command *service*\n\n# \u641c\u7d22\u5e2e\u52a9\u6587\u6863\nGet-Help *service*\n<\/code><\/pre>\n<hr>\n<h2>\ud83d\udcdd \u5b9e\u6218\u793a\u4f8b\uff1a\u65e5\u5e38\u5de5\u4f5c\u573a\u666f<\/h2>\n<p>\u8ba9\u6211\u4eec\u901a\u8fc7\u5b9e\u9645\u5de5\u4f5c\u573a\u666f\u6765\u7ec3\u4e60\uff01<\/p>\n<h3>\u573a\u666f 1\uff1a\u67e5\u627e\u5e76\u7edf\u8ba1\u5927\u6587\u4ef6<\/h3>\n<p><strong>\u4efb\u52a1<\/strong>\uff1a\u5728\u5f53\u524d\u76ee\u5f55\u53ca\u5176\u5b50\u76ee\u5f55\u4e2d\uff0c\u67e5\u627e\u5927\u4e8e 10 MB \u7684\u6587\u4ef6\uff0c\u5e76\u6309\u5927\u5c0f\u6392\u5e8f\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong>\uff1a<\/p>\n<pre><code class=\"language-powershell\">Get-ChildItem -Recurse | Where-Object { $_.Length -gt 10MB } | Sort-Object Length -Descending\n<\/code><\/pre>\n<p><strong>\u547d\u4ee4\u89e3\u6790<\/strong>\uff1a<\/p>\n<ol>\n<li><code>Get-ChildItem -Recurse<\/code>: \u83b7\u53d6\u5f53\u524d\u76ee\u5f55\u53ca\u6240\u6709\u5b50\u76ee\u5f55\u7684\u6587\u4ef6<\/li>\n<li><code>|<\/code>: \u4f20\u9012\u7ed9\u4e0b\u4e00\u547d\u4ee4<\/li>\n<li><code>Where-Object { $_.Length -gt 10MB }<\/code>: \u7b5b\u9009\u5927\u5c0f\u5927\u4e8e 10 MB \u7684\u6587\u4ef6<\/li>\n<li><code>|<\/code>: \u4f20\u9012\u7ed9\u4e0b\u4e00\u547d\u4ee4<\/li>\n<li><code>Sort-Object Length -Descending<\/code>: \u6309\u6587\u4ef6\u5927\u5c0f\u964d\u5e8f\u6392\u5e8f<\/li>\n<\/ol>\n<p><strong>\u8f93\u51fa\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code>    \u76ee\u5f55: C:\\Users\\YourName\\Documents\n\nMode                 LastWriteTime         Length Name\n----                 -------------         ------ ----\n-a---          2026\/3\/28     15:30       52428800 backup.zip\n-a---          2026\/3\/29     10:15       31457280 video.mp4\n-a---          2026\/3\/27      9:45       20971520 presentation.pptx\n<\/code><\/pre>\n<h3>\u573a\u666f 2\uff1a\u6279\u91cf\u521b\u5efa\u6587\u4ef6\u5939<\/h3>\n<p><strong>\u4efb\u52a1<\/strong>\uff1a\u521b\u5efa 12 \u4e2a\u6708\u4efd\u6587\u4ef6\u5939\uff082024-01 \u5230 2024-12\uff09\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong>\uff1a<\/p>\n<pre><code class=\"language-powershell\">1..12 | ForEach-Object { New-Item -Path &quot;2024-$_.ToString('00')&quot; -ItemType Directory }\n<\/code><\/pre>\n<p><strong>\u547d\u4ee4\u89e3\u6790<\/strong>\uff1a<\/p>\n<ol>\n<li><code>1..12<\/code>: \u751f\u6210\u6570\u5b57 1 \u5230 12<\/li>\n<li><code>|<\/code>: \u4f20\u9012\u7ed9\u4e0b\u4e00\u547d\u4ee4<\/li>\n<li><code>ForEach-Object { ... }<\/code>: \u5bf9\u6bcf\u4e2a\u6570\u5b57\u6267\u884c\u64cd\u4f5c<\/li>\n<li><code>New-Item<\/code>: \u521b\u5efa\u65b0\u9879<\/li>\n<li><code>-Path &quot;2024-$_.ToString('00')&quot;<\/code>: \u8def\u5f84\u540d\uff08$_ \u4ee3\u8868\u5f53\u524d\u6570\u5b57\uff0c&#8217;00&#8217; \u8868\u793a\u4e24\u4f4d\u6570\u683c\u5f0f\uff09<\/li>\n<li><code>-ItemType Directory<\/code>: \u521b\u5efa\u76ee\u5f55<\/li>\n<\/ol>\n<p><strong>\u7ed3\u679c<\/strong>\uff1a<\/p>\n<pre><code>2024-01\/\n2024-02\/\n2024-03\/\n...\n2024-12\/\n<\/code><\/pre>\n<h3>\u573a\u666f 3\uff1a\u67e5\u770b\u8fd0\u884c\u65f6\u95f4\u6700\u957f\u7684\u8fdb\u7a0b<\/h3>\n<p><strong>\u4efb\u52a1<\/strong>\uff1a\u67e5\u770b\u8fd0\u884c\u65f6\u95f4\u8d85\u8fc7 1 \u5c0f\u65f6\u7684\u8fdb\u7a0b\uff0c\u5e76\u663e\u793a\u8fdb\u7a0b\u540d\u548c\u8fd0\u884c\u65f6\u95f4\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong>\uff1a<\/p>\n<pre><code class=\"language-powershell\">Get-Process | Where-Object { $_.StartTime -lt (Get-Date).AddHours(-1) } | \n    Select-Object Name, StartTime, @{Name='Runtime';Expression={(Get-Date) - $_.StartTime}}\n<\/code><\/pre>\n<p><strong>\u547d\u4ee4\u89e3\u6790<\/strong>\uff1a<\/p>\n<ol>\n<li><code>Get-Process<\/code>: \u83b7\u53d6\u6240\u6709\u8fdb\u7a0b<\/li>\n<li><code>Where-Object { $_.StartTime -lt (Get-Date).AddHours(-1) }<\/code>: \u7b5b\u9009\u542f\u52a8\u65f6\u95f4\u65e9\u4e8e 1 \u5c0f\u65f6\u524d\u7684\u8fdb\u7a0b<\/li>\n<li><code>Select-Object<\/code>: \u9009\u62e9\u8981\u663e\u793a\u7684\u5c5e\u6027<\/li>\n<li><code>Name, StartTime<\/code>: \u8fdb\u7a0b\u540d\u548c\u542f\u52a8\u65f6\u95f4<\/li>\n<li><code>@{Name='Runtime';Expression={...}}<\/code>: \u521b\u5efa\u81ea\u5b9a\u4e49\u5c5e\u6027&quot;\u8fd0\u884c\u65f6\u95f4&quot;<\/li>\n<\/ol>\n<p><strong>\u8f93\u51fa\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code>Name           StartTime              Runtime\n----           ---------              --------\nnotepad        2026\/3\/29 8:00:00      06:27:35\nchrome         2026\/3\/29 7:30:00      06:57:35\nexplorer       2026\/3\/29 6:00:00      08:27:35\n<\/code><\/pre>\n<hr>\n<h2>\u270d\ufe0f \u4eca\u65e5\u7ec3\u4e60\u4efb\u52a1<\/h2>\n<p>\u5b8c\u6210\u4ee5\u4e0b\u7ec3\u4e60\u4ee5\u5de9\u56fa\u4eca\u5929\u7684\u5b66\u4e60\u5185\u5bb9\uff1a<\/p>\n<h3>\u7ec3\u4e60 1\uff1a\u57fa\u672c\u547d\u4ee4\u64cd\u4f5c\uff08\u5fc5\u505a\uff09<\/h3>\n<ol>\n<li>\u6253\u5f00 PowerShell\uff0c\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c<\/li>\n<li>\u8f93\u5165 <code>Get-Date<\/code> \u67e5\u770b\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4<\/li>\n<li>\u8f93\u5165 <code>Get-Location<\/code> \u67e5\u770b\u5f53\u524d\u76ee\u5f55<\/li>\n<li>\u8f93\u5165 <code>Get-ChildItem<\/code> \u67e5\u770b\u5f53\u524d\u76ee\u5f55\u5185\u5bb9<\/li>\n<li>\u8f93\u5165 <code>Get-Process<\/code> \u67e5\u770b\u6240\u6709\u8fd0\u884c\u8fdb\u7a0b<\/li>\n<\/ol>\n<h3>\u7ec3\u4e60 2\uff1a\u5e2e\u52a9\u7cfb\u7edf\uff08\u5fc5\u505a\uff09<\/h3>\n<ol>\n<li>\u8f93\u5165 <code>Get-Help Get-Process<\/code> \u67e5\u770b Get-Process \u7684\u5e2e\u52a9<\/li>\n<li>\u8f93\u5165 <code>Get-Help Get-Process -Examples<\/code> \u67e5\u770b\u793a\u4f8b<\/li>\n<li>\u8f93\u5165 <code>Get-Command *service*<\/code> \u641c\u7d22\u670d\u52a1\u76f8\u5173\u547d\u4ee4<\/li>\n<li>\u8f93\u5165 <code>Get-Help *process*<\/code> \u641c\u7d22\u8fdb\u7a0b\u76f8\u5173\u5e2e\u52a9<\/li>\n<\/ol>\n<h3>\u7ec3\u4e60 3\uff1a\u7ba1\u9053\u64cd\u4f5c\uff08\u5fc5\u505a\uff09<\/h3>\n<ol>\n<li>\n<p>\u8f93\u5165 <code>Get-Process | Sort-Object CPU -Descending | Select-Object -First 5<\/code><br \/>\n\uff08\u67e5\u770b CPU \u5360\u7528\u6700\u9ad8\u7684 5 \u4e2a\u8fdb\u7a0b\uff09<\/p>\n<\/li>\n<li>\n<p>\u8f93\u5165 <code>Get-ChildItem | Sort-Object Length -Descending | Select-Object -First 10<\/code><br \/>\n\uff08\u67e5\u770b\u5f53\u524d\u76ee\u5f55\u6700\u5927\u7684 10 \u4e2a\u6587\u4ef6\uff09<\/p>\n<\/li>\n<\/ol>\n<h3>\u7ec3\u4e60 4\uff1a\u521b\u5efa\u811a\u672c\uff08\u8fdb\u9636\uff09<\/h3>\n<p>\u521b\u5efa\u4f60\u7684\u7b2c\u4e00\u4e2a PowerShell \u811a\u672c\uff01<\/p>\n<ol>\n<li>\u5728\u684c\u9762\u65b0\u5efa\u4e00\u4e2a\u6587\u672c\u6587\u4ef6<\/li>\n<li>\u91cd\u547d\u540d\u4e3a <code>hello.ps1<\/code>\uff08.ps1 \u662f PowerShell \u811a\u672c\u6269\u5c55\u540d\uff09<\/li>\n<li>\u53f3\u952e\u70b9\u51fb\u6587\u4ef6 \u2192 \u7f16\u8f91\uff08\u4f7f\u7528\u8bb0\u4e8b\u672c\u6216 VS Code\uff09<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/li>\n<\/ol>\n<pre><code class=\"language-powershell\"># \u6211\u7684\u7b2c\u4e00\u4e2a PowerShell \u811a\u672c\nWrite-Host &quot;================================&quot; -ForegroundColor Cyan\nWrite-Host &quot;  \u6b22\u8fce\u4f7f\u7528 PowerShell!&quot; -ForegroundColor Green\nWrite-Host &quot;================================&quot; -ForegroundColor Cyan\nWrite-Host &quot;&quot;\n\nWrite-Host &quot;\u5f53\u524d\u7528\u6237: $env:USERNAME&quot; -ForegroundColor Yellow\nWrite-Host &quot;\u5f53\u524d\u65f6\u95f4: $(Get-Date)&quot; -ForegroundColor Yellow\nWrite-Host &quot;\u5f53\u524d\u76ee\u5f55: $(Get-Location)&quot; -ForegroundColor Yellow\n\nWrite-Host &quot;&quot;\nWrite-Host &quot;\u8fd0\u884c\u4e2d\u7684\u8fdb\u7a0b\u6570: $((Get-Process).Count)&quot; -ForegroundColor Magenta\nWrite-Host &quot;\u7cfb\u7edf\u8fd0\u884c\u65f6\u95f4: $((Get-Date) - (Get-CimInstance Win32_OperatingSystem).LastBootUpTime)&quot; -ForegroundColor Magenta\n\nWrite-Host &quot;&quot;\nWrite-Host &quot;================================&quot; -ForegroundColor Cyan\nWrite-Host &quot;  \u811a\u672c\u6267\u884c\u5b8c\u6bd5\uff01&quot; -ForegroundColor Green\nWrite-Host &quot;================================&quot; -ForegroundColor Cyan\n<\/code><\/pre>\n<ol start=\"5\">\n<li>\u4fdd\u5b58\u6587\u4ef6<\/li>\n<li>\u5728 PowerShell \u4e2d\u8fd0\u884c\u811a\u672c\uff1a\n<pre><code class=\"language-powershell\">.\\Desktop\\hello.ps1\n<\/code><\/pre>\n<\/li>\n<li>\u5982\u679c\u63d0\u793a&quot;\u65e0\u6cd5\u52a0\u8f7d\uff0c\u56e0\u4e3a\u5728\u6b64\u7cfb\u7edf\u4e0a\u7981\u6b62\u8fd0\u884c\u811a\u672c&quot;\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code class=\"language-powershell\">Set-ExecutionPolicy RemoteSigned -Scope CurrentUser\n<\/code><\/pre>\n<p>\u7136\u540e\u91cd\u65b0\u8fd0\u884c\u811a\u672c<\/li>\n<\/ol>\n<h3>\u7ec3\u4e60 5\uff1a\u81ea\u5b9a\u4e49\u914d\u7f6e\uff08\u53ef\u9009\uff09<\/h3>\n<ol>\n<li>\u4fee\u6539 PowerShell \u7a97\u53e3\u5916\u89c2\uff08\u5b57\u4f53\u3001\u989c\u8272\u3001\u5927\u5c0f\uff09<\/li>\n<li>\u5c1d\u8bd5\u4f7f\u7528 Tab \u952e\u81ea\u52a8\u8865\u5168\u547d\u4ee4<\/li>\n<li>\u4f7f\u7528 <code>\u2191<\/code> \u548c <code>\u2193<\/code> \u6d4f\u89c8\u5386\u53f2\u547d\u4ee4<\/li>\n<li>\u8f93\u5165 <code>Clear-Host<\/code> \u6216 <code>cls<\/code> \u6e05\u7a7a\u5c4f\u5e55<\/li>\n<\/ol>\n<hr>\n<h2>\u2753 \u5e38\u89c1\u95ee\u9898\uff08FAQ\uff09<\/h2>\n<h3>Q1: PowerShell \u548c\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09\u6709\u4ec0\u4e48\u533a\u522b\uff1f\u6211\u5e94\u8be5\u7528\u54ea\u4e2a\uff1f<\/h3>\n<p><strong>A<\/strong>: \u5bf9\u4e8e\u65e5\u5e38\u529e\u516c\u81ea\u52a8\u5316\uff0c<strong>\u63a8\u8350\u4f7f\u7528 PowerShell<\/strong>\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u7279\u6027<\/th>\n<th>CMD<\/th>\n<th>PowerShell<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u529f\u80fd<\/td>\n<td>\u57fa\u7840\u6587\u4ef6\u64cd\u4f5c<\/td>\n<td>\u5f3a\u5927\u7684\u81ea\u52a8\u5316\u80fd\u529b<\/td>\n<\/tr>\n<tr>\n<td>\u5904\u7406\u65b9\u5f0f<\/td>\n<td>\u6587\u672c\u6d41<\/td>\n<td>\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>\u53ef\u6269\u5c55\u6027<\/td>\n<td>\u6709\u9650<\/td>\n<td>\u4f18\u79c0<\/td>\n<\/tr>\n<tr>\n<td>\u5b66\u4e60\u96be\u5ea6<\/td>\n<td>\u7b80\u5355\u4f46\u529f\u80fd\u53d7\u9650<\/td>\n<td>\u7a0d\u590d\u6742\u4f46\u529f\u80fd\u5f3a\u5927<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u4f60\u53ea\u662f\u7b80\u5355\u7684\u6587\u4ef6\u64cd\u4f5c\uff08\u5982\u590d\u5236\u3001\u79fb\u52a8\uff09\uff0cCMD \u5c31\u591f\u4e86\u3002\u4f46\u5982\u679c\u4f60\u9700\u8981\uff1a<\/p>\n<ul>\n<li>\u6279\u91cf\u5904\u7406\u6587\u4ef6<\/li>\n<li>\u81ea\u52a8\u5316\u91cd\u590d\u4efb\u52a1<\/li>\n<li>\u7ba1\u7406\u7cfb\u7edf\u670d\u52a1<\/li>\n<li>\u5904\u7406\u7ed3\u6784\u5316\u6570\u636e<\/li>\n<\/ul>\n<p>\u90a3\u4e48 <strong>PowerShell \u662f\u66f4\u597d\u7684\u9009\u62e9<\/strong>\u3002<\/p>\n<h3>Q2: \u6211\u770b\u5230\u7f51\u4e0a\u6709 PowerShell 5\u3001PowerShell 7\uff0c\u6211\u5e94\u8be5\u7528\u54ea\u4e2a\uff1f<\/h3>\n<p><strong>A<\/strong>: \u5bf9\u4e8e\u521d\u5b66\u8005\uff1a<\/p>\n<ul>\n<li><strong>Windows 10\/11 \u7528\u6237<\/strong>: \u7cfb\u7edf\u81ea\u5e26\u7684 <strong>PowerShell 5.x<\/strong> \u5b8c\u5168\u591f\u7528\uff0c\u672c\u6559\u7a0b\u57fa\u4e8e\u6b64\u7248\u672c<\/li>\n<li><strong>PowerShell 7<\/strong>: \u662f\u6700\u65b0\u7248\u672c\uff0c\u6027\u80fd\u66f4\u597d\uff0c\u4f46\u9700\u8981\u5355\u72ec\u5b89\u88c5\uff08\u53ef\u9009\uff09<\/li>\n<\/ul>\n<p><strong>\u5efa\u8bae<\/strong>\uff1a<\/p>\n<ol>\n<li>\u5148\u7528\u7cfb\u7edf\u81ea\u5e26\u7684 PowerShell 5.x \u5b66\u4e60\u57fa\u7840<\/li>\n<li>\u719f\u6089\u540e\u518d\u5b89\u88c5 PowerShell 7 \u4f53\u9a8c\u65b0\u529f\u80fd<\/li>\n<li>\u4e24\u8005\u8bed\u6cd5\u51e0\u4e4e\u517c\u5bb9\uff0c\u5b66\u54ea\u4e2a\u90fd\u4e00\u6837<\/li>\n<\/ol>\n<h3>Q3: \u8fd0\u884c\u811a\u672c\u65f6\u63d0\u793a&quot;\u65e0\u6cd5\u52a0\u8f7d\uff0c\u56e0\u4e3a\u5728\u6b64\u7cfb\u7edf\u4e0a\u7981\u6b62\u8fd0\u884c\u811a\u672c&quot;\u600e\u4e48\u529e\uff1f<\/h3>\n<p><strong>A<\/strong>: \u8fd9\u662f PowerShell \u7684\u5b89\u5168\u7b56\u7565\uff08\u6267\u884c\u7b56\u7565\uff09\u3002\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u67e5\u770b\u5f53\u524d\u6267\u884c\u7b56\u7565\nGet-ExecutionPolicy\n\n# \u4fee\u6539\u4e3a\u5141\u8bb8\u672c\u5730\u811a\u672c\u8fd0\u884c\uff08\u63a8\u8350\uff09\nSet-ExecutionPolicy RemoteSigned -Scope CurrentUser\n\n# \u5982\u679c\u8fd8\u4e0d\u884c\uff0c\u4e34\u65f6\u5141\u8bb8\u811a\u672c\u8fd0\u884c\nPowerShell -ExecutionPolicy Bypass -File .\\your_script.ps1\n<\/code><\/pre>\n<p><strong>\u6ce8\u610f<\/strong>\uff1a<code>RemoteSigned<\/code> \u7b56\u7565\u8868\u793a\uff1a<\/p>\n<ul>\n<li>\u672c\u5730\u521b\u5efa\u7684\u811a\u672c\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c<\/li>\n<li>\u4ece\u7f51\u4e0a\u4e0b\u8f7d\u7684\u811a\u672c\u9700\u8981\u7b7e\u540d\u6216\u624b\u52a8\u89e3\u9664\u9501\u5b9a<\/li>\n<\/ul>\n<h3>Q4: PowerShell \u547d\u4ee4\u592a\u957f\u4e86\uff0c\u6709\u6ca1\u6709\u7b80\u5199\uff1f<\/h3>\n<p><strong>A<\/strong>: \u6709\uff01PowerShell \u652f\u6301\u522b\u540d\uff08Alias\uff09\u3002<\/p>\n<p><strong>\u5e38\u7528\u522b\u540d<\/strong>\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>PowerShell \u547d\u4ee4<\/th>\n<th>\u522b\u540d<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>Get-ChildItem<\/code><\/td>\n<td><code>dir<\/code>, <code>ls<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Set-Location<\/code><\/td>\n<td><code>cd<\/code>, <code>chdir<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Get-Location<\/code><\/td>\n<td><code>pwd<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Get-Process<\/code><\/td>\n<td><code>ps<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Remove-Item<\/code><\/td>\n<td><code>rm<\/code>, <code>del<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Copy-Item<\/code><\/td>\n<td><code>copy<\/code>, <code>cp<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Move-Item<\/code><\/td>\n<td><code>move<\/code>, <code>mv<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Write-Host<\/code><\/td>\n<td><code>echo<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u67e5\u770b\u522b\u540d<\/strong>\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u67e5\u770b\u547d\u4ee4\u7684\u6240\u6709\u522b\u540d\nGet-Alias -Definition Get-ChildItem\n\n# \u67e5\u770b\u522b\u540d\u5bf9\u5e94\u7684\u547d\u4ee4\nGet-Alias dir\n<\/code><\/pre>\n<p><strong>\u6ce8\u610f<\/strong>\uff1a\u521d\u5b66\u5efa\u8bae\u7528\u5b8c\u6574\u547d\u4ee4\u540d\uff0c\u66f4\u6e05\u6670\u6613\u8bfb\u3002<\/p>\n<h3>Q5: \u5982\u4f55\u67e5\u770b PowerShell \u4e2d\u53ef\u7528\u7684\u6240\u6709\u547d\u4ee4\uff1f<\/h3>\n<p><strong>A<\/strong>: \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u67e5\u770b\u6240\u6709\u547d\u4ee4\nGet-Command\n\n# \u67e5\u770b\u7279\u5b9a\u52a8\u8bcd\u7684\u547d\u4ee4\uff08\u5982\u6240\u6709 Get \u5f00\u5934\u7684\u547d\u4ee4\uff09\nGet-Command -Verb Get\n\n# \u67e5\u770b\u7279\u5b9a\u540d\u8bcd\u7684\u547d\u4ee4\uff08\u5982\u6240\u6709 Process \u76f8\u5173\u7684\u547d\u4ee4\uff09\nGet-Command -Noun Process\n\n# \u641c\u7d22\u547d\u4ee4\uff08\u901a\u914d\u7b26\uff09\nGet-Command *service*\n<\/code><\/pre>\n<p><strong>\u7edf\u8ba1<\/strong>\uff1a<\/p>\n<ul>\n<li>PowerShell 5.x \u7ea6\u6709 1,300+ \u4e2a\u5185\u7f6e\u547d\u4ee4<\/li>\n<li>\u52a0\u8f7d\u6a21\u5757\u540e\u53ef\u8fbe 3,000+ \u4e2a\u547d\u4ee4<\/li>\n<\/ul>\n<p><strong>\u63d0\u793a<\/strong>\uff1a\u4e0d\u9700\u8981\u8bb0\u4f4f\u6240\u6709\u547d\u4ee4\uff0c\u8bb0\u4f4f <code>Get-Command<\/code> \u548c <code>Get-Help<\/code> \u5c31\u591f\u4e86\uff01<\/p>\n<h3>Q6: PowerShell \u80fd\u5728 Linux\/Mac \u4e0a\u7528\u5417\uff1f<\/h3>\n<p><strong>A<\/strong>: \u53ef\u4ee5\uff01PowerShell 7\uff08\u539f\u540d PowerShell Core\uff09\u662f\u8de8\u5e73\u53f0\u7684\u3002<\/p>\n<p><strong>\u652f\u6301\u7cfb\u7edf<\/strong>\uff1a<\/p>\n<ul>\n<li>Windows 7\/8\/10\/11<\/li>\n<li>macOS 10.13+<\/li>\n<li>Linux\uff08Ubuntu\u3001Debian\u3001CentOS\u3001Fedora \u7b49\uff09<\/li>\n<\/ul>\n<p><strong>\u5b89\u88c5\u65b9\u6cd5<\/strong>\uff1a<\/p>\n<ul>\n<li>\u8bbf\u95ee https:\/\/github.com\/PowerShell\/PowerShell<\/li>\n<li>\u4e0b\u8f7d\u5bf9\u5e94\u7cfb\u7edf\u7684\u5b89\u88c5\u5305<\/li>\n<li>\u6216\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff08\u5982 <code>brew install powershell<\/code>\uff09<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f<\/strong>\uff1a\u672c\u6559\u7a0b\u9488\u5bf9 Windows PowerShell\uff0c\u4f46\u5927\u90e8\u5206\u547d\u4ee4\u5728\u8de8\u5e73\u53f0\u7248\u672c\u4e2d\u4e5f\u9002\u7528\u3002<\/p>\n<h3>Q7: \u6211\u4e0d\u662f\u7a0b\u5e8f\u5458\uff0c\u80fd\u5b66\u4f1a PowerShell \u5417\uff1f<\/h3>\n<p><strong>A<\/strong>: <strong>\u5b8c\u5168\u53ef\u4ee5\uff01<\/strong><\/p>\n<p>PowerShell \u4e13\u4e3a\u7cfb\u7edf\u7ba1\u7406\u5458\u548c\u529e\u516c\u4eba\u5458\u8bbe\u8ba1\uff0c<strong>\u4e0d\u662f\u4e13\u4e1a\u7f16\u7a0b\u8bed\u8a00<\/strong>\u3002<\/p>\n<p><strong>\u4e3a\u4ec0\u4e48\u9002\u5408\u975e\u7a0b\u5e8f\u5458<\/strong>\uff1a<\/p>\n<ol>\n<li><strong>\u8bed\u6cd5\u63a5\u8fd1\u81ea\u7136\u8bed\u8a00<\/strong>\uff1a<code>Get-Process<\/code>\uff08\u83b7\u53d6\u8fdb\u7a0b\uff09\u6bd4\u7f16\u7a0b\u8bed\u8a00\u76f4\u89c2<\/li>\n<li><strong>\u547d\u540d\u89c4\u8303\u7edf\u4e00<\/strong>\uff1a\u52a8\u8bcd-\u540d\u8bcd\u683c\u5f0f\uff0c\u6613\u4e8e\u7406\u89e3\u548c\u8bb0\u5fc6<\/li>\n<li><strong>\u9010\u6b65\u5b66\u4e60<\/strong>\uff1a\u4ece\u7b80\u5355\u547d\u4ee4\u5f00\u59cb\uff0c\u9010\u6b65\u6df1\u5165<\/li>\n<li><strong>\u5373\u65f6\u53cd\u9988<\/strong>\uff1a\u8f93\u5165\u547d\u4ee4\u7acb\u5373\u770b\u5230\u7ed3\u679c\uff0c\u4e0d\u50cf\u7f16\u7a0b\u9700\u8981\u7f16\u8bd1<\/li>\n<li><strong>\u5b9e\u7528\u5bfc\u5411<\/strong>\uff1a\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\uff0c\u4e0d\u662f\u62bd\u8c61\u6982\u5ff5<\/li>\n<\/ol>\n<p><strong>\u5b66\u4e60\u66f2\u7ebf<\/strong>\uff1a<\/p>\n<ul>\n<li><strong>\u7b2c 1 \u5468<\/strong>\uff1a\u638c\u63e1\u57fa\u672c\u547d\u4ee4\u548c\u7ba1\u9053\u64cd\u4f5c<\/li>\n<li><strong>\u7b2c 2-4 \u5468<\/strong>\uff1a\u5b66\u4f1a\u5199\u7b80\u5355\u811a\u672c<\/li>\n<li><strong>1-3 \u4e2a\u6708<\/strong>\uff1a\u80fd\u591f\u81ea\u52a8\u5316\u65e5\u5e38\u4efb\u52a1<\/li>\n<li><strong>\u6301\u7eed\u5b66\u4e60<\/strong>\uff1a\u9010\u6b65\u638c\u63e1\u9ad8\u7ea7\u529f\u80fd<\/li>\n<\/ul>\n<p><strong>\u5efa\u8bae<\/strong>\uff1a<\/p>\n<ul>\n<li>\u6bcf\u5929\u7ec3\u4e60 30 \u5206\u949f<\/li>\n<li>\u4ece\u5b9e\u9645\u5de5\u4f5c\u573a\u666f\u51fa\u53d1<\/li>\n<li>\u9047\u5230\u95ee\u9898\u7528 <code>Get-Help<\/code> \u67e5\u8be2<\/li>\n<li>\u52a0\u5165 PowerShell \u793e\u533a\u4ea4\u6d41<\/li>\n<\/ul>\n<h3>Q8: PowerShell \u4f1a\u635f\u574f\u6211\u7684\u7cfb\u7edf\u5417\uff1f<\/h3>\n<p><strong>A<\/strong>: \u6b63\u5e38\u4f7f\u7528\u4e0d\u4f1a\uff0c\u4f46\u9700\u8981\u6ce8\u610f\uff1a<\/p>\n<p><strong>\u5b89\u5168\u5efa\u8bae<\/strong>\uff1a<\/p>\n<ol>\n<li><strong>\u4ece\u4e0d\u660e\u6765\u6e90\u8fd0\u884c\u811a\u672c\u524d\u5148\u67e5\u770b\u5185\u5bb9<\/strong>\uff1a\u7528\u8bb0\u4e8b\u672c\u6253\u5f00 <code>.ps1<\/code> \u6587\u4ef6\u68c0\u67e5<\/li>\n<li><strong>\u4f7f\u7528 <code>-WhatIf<\/code> \u53c2\u6570<\/strong>\uff1a\u5148\u6a21\u62df\u8fd0\u884c\uff0c\u786e\u8ba4\u65e0\u8bef\u540e\u518d\u6267\u884c\n<pre><code class=\"language-powershell\">Remove-Item &quot;test.txt&quot; -WhatIf\n<\/code><\/pre>\n<\/li>\n<li><strong>\u7406\u89e3\u547d\u4ee4\u518d\u6267\u884c<\/strong>\uff1a\u4e0d\u786e\u5b9a\u7684\u547d\u4ee4\u5148\u7528 <code>Get-Help<\/code> \u67e5\u770b\u5e2e\u52a9<\/li>\n<li><strong>\u5907\u4efd\u91cd\u8981\u6570\u636e<\/strong>\uff1a\u81ea\u52a8\u5316\u6279\u91cf\u64cd\u4f5c\u524d\u5148\u5907\u4efd<\/li>\n<\/ol>\n<p><strong>\u5371\u9669\u64cd\u4f5c\u793a\u4f8b<\/strong>\uff08\u9700\u8981\u8c28\u614e\uff09\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u5371\u9669\uff01\u5220\u9664 C \u76d8\u6240\u6709\u6587\u4ef6\uff08\u4e0d\u8981\u8fd0\u884c\uff01\uff09\nRemove-Item &quot;C:\\*&quot; -Recurse -Force\n\n# \u5371\u9669\uff01\u505c\u6b62\u6240\u6709\u7cfb\u7edf\u670d\u52a1\uff08\u4e0d\u8981\u8fd0\u884c\uff01\uff09\nGet-Service | Stop-Service\n<\/code><\/pre>\n<p><strong>\u5b89\u5168\u64cd\u4f5c\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u5b89\u5168\uff01\u4f7f\u7528 -WhatIf \u5148\u9884\u89c8\nRemove-Item &quot;C:\\Test\\*&quot; -Recurse -WhatIf\n\n# \u5b89\u5168\uff01\u4f7f\u7528 -Confirm \u9700\u8981\u786e\u8ba4\nRemove-Item &quot;C:\\Test\\*&quot; -Recurse -Confirm\n<\/code><\/pre>\n<h3>Q9: \u5982\u4f55\u5feb\u901f\u4e0a\u624b\uff1f\u6709\u4ec0\u4e48\u5b66\u4e60\u8def\u5f84\uff1f<\/h3>\n<p><strong>A<\/strong>: \u63a8\u8350\u7684\u5b66\u4e60\u8def\u5f84\uff1a<\/p>\n<p><strong>\u7b2c 1 \u5468\uff1a\u57fa\u7840\u5165\u95e8<\/strong>\uff08\u672c\u6559\u7a0b Day 1-7\uff09<\/p>\n<ul>\n<li>Day 1: \u7b80\u4ecb\u4e0e\u73af\u5883\u642d\u5efa \u2713<\/li>\n<li>Day 2: \u6587\u4ef6\u548c\u76ee\u5f55\u64cd\u4f5c<\/li>\n<li>Day 3: \u6587\u672c\u5904\u7406\u548c\u6570\u636e\u7b5b\u9009<\/li>\n<li>Day 4: \u53d8\u91cf\u548c\u6570\u636e\u7c7b\u578b<\/li>\n<li>Day 5: \u6761\u4ef6\u5224\u65ad\u548c\u5faa\u73af<\/li>\n<li>Day 6: \u51fd\u6570\u548c\u811a\u672c<\/li>\n<li>Day 7: \u7efc\u5408\u5b9e\u6218<\/li>\n<\/ul>\n<p><strong>\u7b2c 2-4 \u5468\uff1a\u5b9e\u6218\u5e94\u7528<\/strong><\/p>\n<ul>\n<li>\u6279\u91cf\u91cd\u547d\u540d\u6587\u4ef6<\/li>\n<li>\u81ea\u52a8\u751f\u6210\u62a5\u8868<\/li>\n<li>\u7cfb\u7edf\u7ba1\u7406\u81ea\u52a8\u5316<\/li>\n<li>\u65e5\u5fd7\u5206\u6790\u548c\u76d1\u63a7<\/li>\n<\/ul>\n<p><strong>\u6301\u7eed\u5b66\u4e60<\/strong>\uff1a<\/p>\n<ul>\n<li>\u9605\u8bfb\u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/docs.microsoft.com\/powershell\/<\/li>\n<li>\u52a0\u5165\u793e\u533a\uff1aStack Overflow\u3001Reddit r\/PowerShell<\/li>\n<li>\u89c2\u770b\u89c6\u9891\u6559\u7a0b\uff1aYouTube\u3001B\u7ad9<\/li>\n<li>\u7ec3\u4e60\u5b9e\u9645\u9879\u76ee\uff1a\u4ece\u5de5\u4f5c\u4e2d\u627e\u9700\u6c42<\/li>\n<\/ul>\n<h3>Q10: PowerShell \u4ec0\u4e48\u65f6\u5019\u7528\u4e0d\u4e0a\uff1f<\/h3>\n<p><strong>A<\/strong>: PowerShell \u4e0d\u662f\u4e07\u80fd\u7684\uff0c\u4ee5\u4e0b\u60c5\u51b5\u4e0d\u9002\u5408\uff1a<\/p>\n<p><strong>\u4e0d\u9002\u5408\u7528 PowerShell \u7684\u573a\u666f<\/strong>\uff1a<\/p>\n<ol>\n<li><strong>\u590d\u6742 GUI \u5e94\u7528\u5f00\u53d1<\/strong>\uff1a\u7528 C#\u3001Java \u7b49\u4e13\u4e1a\u7f16\u7a0b\u8bed\u8a00<\/li>\n<li><strong>\u9ad8\u6027\u80fd\u8ba1\u7b97<\/strong>\uff1a\u7528 Python\u3001C++<\/li>\n<li><strong>\u8de8\u5e73\u53f0\u517c\u5bb9\u6027\u8981\u6c42\u6781\u9ad8<\/strong>\uff1a\u8003\u8651 Python<\/li>\n<li><strong>\u7b80\u5355\u4e00\u6b21\u6027\u64cd\u4f5c<\/strong>\uff1a\u624b\u52a8\u64cd\u4f5c\u53ef\u80fd\u66f4\u5feb<\/li>\n<\/ol>\n<p><strong>PowerShell \u6700\u9002\u5408\u7684\u573a\u666f<\/strong>\uff1a<\/p>\n<ul>\n<li>\u2705 Windows \u7cfb\u7edf\u7ba1\u7406<\/li>\n<li>\u2705 Office \u81ea\u52a8\u5316\uff08Excel\u3001Word\uff09<\/li>\n<li>\u2705 \u6279\u91cf\u6587\u4ef6\u5904\u7406<\/li>\n<li>\u2705 \u5b9a\u65f6\u4efb\u52a1\u548c\u76d1\u63a7<\/li>\n<li>\u2705 \u7cfb\u7edf\u7ef4\u62a4\u548c\u90e8\u7f72<\/li>\n<\/ul>\n<hr>\n<h2>\ud83c\udf93 \u4eca\u65e5\u77e5\u8bc6\u70b9\u603b\u7ed3<\/h2>\n<h3>\u6838\u5fc3\u6982\u5ff5<\/h3>\n<ol>\n<li><strong>PowerShell<\/strong>: Windows \u5185\u7f6e\u7684\u547d\u4ee4\u884c\u5de5\u5177\u548c\u811a\u672c\u8bed\u8a00<\/li>\n<li><strong>Cmdlet<\/strong>: PowerShell \u7684\u57fa\u672c\u547d\u4ee4\u5355\u5143\uff08\u52a8\u8bcd-\u540d\u8bcd\u683c\u5f0f\uff09<\/li>\n<li><strong>\u53c2\u6570<\/strong>: \u4f20\u9012\u7ed9\u547d\u4ee4\u7684\u989d\u5916\u4fe1\u606f\uff08-ParameterName Value\uff09<\/li>\n<li><strong>\u5bf9\u8c61<\/strong>: PowerShell \u5904\u7406\u7684\u57fa\u672c\u5355\u4f4d\uff08\u6709\u5c5e\u6027\u548c\u65b9\u6cd5\uff09<\/li>\n<li><strong>\u7ba1\u9053<\/strong>: \u7528 <code>|<\/code> \u8fde\u63a5\u591a\u4e2a\u547d\u4ee4\uff0c\u4f20\u9012\u6570\u636e<\/li>\n<\/ol>\n<h3>\u5e38\u7528\u547d\u4ee4<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u547d\u4ee4<\/th>\n<th>\u529f\u80fd<\/th>\n<th>\u793a\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>Get-Help<\/code><\/td>\n<td>\u67e5\u770b\u5e2e\u52a9<\/td>\n<td><code>Get-Help Get-Process<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Get-Command<\/code><\/td>\n<td>\u67e5\u627e\u547d\u4ee4<\/td>\n<td><code>Get-Command *service*<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Get-Date<\/code><\/td>\n<td>\u83b7\u53d6\u65e5\u671f<\/td>\n<td><code>Get-Date<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Get-Location<\/code><\/td>\n<td>\u83b7\u53d6\u5f53\u524d\u8def\u5f84<\/td>\n<td><code>Get-Location<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Set-Location<\/code><\/td>\n<td>\u5207\u6362\u76ee\u5f55<\/td>\n<td><code>Set-Location C:\\Windows<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Get-ChildItem<\/code><\/td>\n<td>\u5217\u51fa\u76ee\u5f55\u5185\u5bb9<\/td>\n<td><code>Get-ChildItem<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>Get-Process<\/code><\/td>\n<td>\u83b7\u53d6\u8fdb\u7a0b<\/td>\n<td><code>Get-Process<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u5feb\u6377\u952e<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u5feb\u6377\u952e<\/th>\n<th>\u529f\u80fd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>Tab<\/code><\/td>\n<td>\u81ea\u52a8\u8865\u5168\u547d\u4ee4\u548c\u53c2\u6570<\/td>\n<\/tr>\n<tr>\n<td><code>\u2191<\/code> \/ <code>\u2193<\/code><\/td>\n<td>\u6d4f\u89c8\u5386\u53f2\u547d\u4ee4<\/td>\n<\/tr>\n<tr>\n<td><code>Ctrl + C<\/code><\/td>\n<td>\u4e2d\u6b62\u5f53\u524d\u547d\u4ee4<\/td>\n<\/tr>\n<tr>\n<td><code>Ctrl + L<\/code> \u6216 <code>Clear-Host<\/code><\/td>\n<td>\u6e05\u7a7a\u5c4f\u5e55<\/td>\n<\/tr>\n<tr>\n<td><code>F7<\/code><\/td>\n<td>\u663e\u793a\u5386\u53f2\u547d\u4ee4\u83dc\u5355<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr>\n<h2>\ud83d\udcda \u6269\u5c55\u9605\u8bfb\u8d44\u6e90<\/h2>\n<h3>\u5b98\u65b9\u6587\u6863<\/h3>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/powershell\/\">PowerShell \u5b98\u65b9\u6587\u6863<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/powershell\/scripting\/whats-new\/what-s-new-in-powershell-74\">PowerShell 7.4 \u6587\u6863<\/a><\/li>\n<\/ul>\n<h3>\u5b66\u4e60\u7f51\u7ad9<\/h3>\n<ul>\n<li>PowerShell.org\uff1ahttps:\/\/powershell.org\/<\/li>\n<li>Stack Overflow PowerShell \u6807\u7b7e\uff1ahttps:\/\/stackoverflow.com\/questions\/tagged\/powershell<\/li>\n<\/ul>\n<h3>\u63a8\u8350\u4e66\u7c4d<\/h3>\n<ul>\n<li>\u300aPowerShell \u5b9e\u6218\u6307\u5357\u300b<\/li>\n<li>\u300aWindows PowerShell in Action\u300b<\/li>\n<li>\u300aLearn PowerShell in a Month of Lunches\u300b<\/li>\n<\/ul>\n<h3>\u793e\u533a<\/h3>\n<ul>\n<li>Reddit\uff1ahttps:\/\/reddit.com\/r\/PowerShell<\/li>\n<li>Discord\uff1ahttps:\/\/discord.gg\/powershell<\/li>\n<\/ul>\n<hr>\n<h2>\ud83d\ude80 \u4e0b\u4e00\u6b65<\/h2>\n<p>\u606d\u559c\u4f60\u5b8c\u6210\u4e86 Day 1 \u7684\u5b66\u4e60\uff01\u4f60\u5df2\u7ecf\u638c\u63e1\u4e86\uff1a<\/p>\n<p>\u2705 PowerShell \u7684\u57fa\u672c\u6982\u5ff5<br \/>\n\u2705 \u73af\u5883\u642d\u5efa\u548c\u914d\u7f6e<br \/>\n\u2705 \u7b2c\u4e00\u4e2a\u547d\u4ee4\u7684\u8fd0\u884c<br \/>\n\u2705 \u6838\u5fc3\u6982\u5ff5\u7684\u7406\u89e3<\/p>\n<p><strong>\u660e\u5929\u9884\u544a<\/strong>\uff1aDay 2 &#8211; \u6587\u4ef6\u548c\u76ee\u5f55\u64cd\u4f5c<\/p>\n<p>\u4f60\u5c06\u5b66\u4e60\uff1a<\/p>\n<ul>\n<li>\u5982\u4f55\u521b\u5efa\u3001\u590d\u5236\u3001\u79fb\u52a8\u3001\u5220\u9664\u6587\u4ef6\u548c\u6587\u4ef6\u5939<\/li>\n<li>\u6279\u91cf\u91cd\u547d\u540d\u6587\u4ef6<\/li>\n<li>\u67e5\u627e\u7279\u5b9a\u6587\u4ef6<\/li>\n<li>\u5b9e\u6218\u9879\u76ee\uff1a\u81ea\u52a8\u6574\u7406\u4e0b\u8f7d\u6587\u4ef6\u5939<\/li>\n<\/ul>\n<p><strong>\u4fdd\u6301\u5b66\u4e60\u7684\u70ed\u60c5<\/strong>\uff0c\u81ea\u52a8\u5316\u529e\u516c\u7684\u4e16\u754c\u6b63\u5728\u5411\u4f60\u655e\u5f00\u5927\u95e8\uff01\ud83d\udcaa<\/p>\n<hr>\n<h2>\ud83d\udcdd \u5b66\u4e60\u7b14\u8bb0<\/h2>\n<p><strong>\u8bb0\u5f55\u4f60\u7684\u5b66\u4e60\u5fc3\u5f97<\/strong>\uff1a<\/p>\n<ol>\n<li>\n<h2>\u4eca\u5929\u6700\u6709\u6536\u83b7\u7684\u77e5\u8bc6\u70b9\uff1a<\/h2>\n<ul>\n<li><\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u9047\u5230\u7684\u95ee\u9898\u548c\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>\u95ee\u9898\uff1a<\/li>\n<li>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/li>\n<\/ul>\n<\/li>\n<li>\n<h2>\u60f3\u8981\u8fdb\u4e00\u6b65\u63a2\u7d22\u7684\u5185\u5bb9\uff1a<\/h2>\n<ul>\n<li><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr>\n<p><strong>\u6559\u7a0b\u4fe1\u606f<\/strong>\uff1a<\/p>\n<ul>\n<li>\u4f5c\u8005\uff1aPowerShell \u81ea\u52a8\u5316\u6559\u7a0b<\/li>\n<li>\u7248\u672c\uff1av1.0<\/li>\n<li>\u6700\u540e\u66f4\u65b0\uff1a2026\u5e743\u670829\u65e5<\/li>\n<li>\u8bb8\u53ef\uff1aCC BY-NC-SA 4.0<\/li>\n<\/ul>\n<p><strong>\u95ee\u9898\u53cd\u9988<\/strong>\uff1a\u5982\u53d1\u73b0\u9519\u8bef\u6216\u6709\u6539\u8fdb\u5efa\u8bae\uff0c\u6b22\u8fce\u63d0\u51fa\uff01<\/p>\n<hr>\n<p><em>Happy Scripting! \ud83d\ude80<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Day 1: PowerShell \u7b80\u4ecb\u4e0e\u73af\u5883\u642d\u5efa \u6b22\u8fce\u6765\u5230 PowerShell \u81ea\u52a8\u5316\u6559\u7a0b\u7684\u7b2c\u4e00\u5929\uff01 \u672c\u6559 &#8230; <a title=\"Day-1-PowerShell\u7b80\u4ecb\u4e0e\u73af\u5883\u642d\u5efa\" class=\"read-more\" href=\"https:\/\/www.resilence.cn\/?p=313\" aria-label=\"\u7ee7\u7eed\u9605\u8bfbDay-1-PowerShell\u7b80\u4ecb\u4e0e\u73af\u5883\u642d\u5efa\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-313","post","type-post","status-publish","format-standard","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/posts\/313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=313"}],"version-history":[{"count":1,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/posts\/313\/revisions"}],"predecessor-version":[{"id":314,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/posts\/313\/revisions\/314"}],"wp:attachment":[{"href":"https:\/\/www.resilence.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}