{"id":33109,"date":"2010-11-18T18:07:00","date_gmt":"2010-11-18T17:07:00","guid":{"rendered":"https:\/\/www.fuhaijun.com\/?p=33109"},"modified":"2024-11-06T11:22:38","modified_gmt":"2024-11-06T03:22:38","slug":"windows-powershell-2-0%e8%af%ad%e8%a8%80%e4%b9%8b%e5%88%86%e6%94%af%e8%af%ad%e5%8f%a5%e8%ae%b2%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.fuhaijun.com\/?p=33109","title":{"rendered":"Windows PowerShell 2.0\u8bed\u8a00\u4e4b\u5206\u652f\u8bed\u53e5\u8bb2\u89e3"},"content":{"rendered":"<p>\u4e0e\u7b97\u6570\u8868\u8fbe\u5f0f\u7c7b\u4f3c\uff0c\u6761\u4ef6\u8868\u8fbe\u5f0f\u4f7f\u7528\u4e00\u7cfb\u5217\u64cd\u4f5c\u6c42\u503c\u7528\u6765\u8ba1\u7b97\u7ed3\u679c\u3002\u5e76\u4e14\u5f97\u5230\u4e00\u4e2a\u5e03\u5c14\u7c7b\u578b\u7684\u7ed3\u679c\uff0c\u5373\u771f\u548c\u5047\u3002\u5982\u679c\u6709\u65f6\u5f97\u51fa\u7684\u7ed3\u679c\u662f\u4e00\u4e2a\u5177\u4f53\u7684\u6570\u5b57\uff0c\u89e3\u6790\u5f15\u64ce\u5728\u89e3\u6790\u65f6\u4e5f\u4f1a\u6267\u884c\u5e03\u5c14\u7c7b\u578b\u8f6c\u6362\u3002\u53730\u4e3a\u5047\uff0c\u975e0\u4e3a\u771f\uff0c\u6240\u4ee5\u5728\u7a0b\u5e8f\u4e2d\u76f4\u63a5\u4ee5\u6570\u503c\u4e3a\u6d41\u7684\u63a7\u5236\u6761\u4ef6\u3002 <\/p>\n<p>\u5728PowerShell\u4e2d\u7684\u771f\u548c\u5047\u4e0e\u5176\u4ed6\u7c7bC\u8bed\u8a00\u4e2d\u7684true\u548cfalse\u4e0d\u540c\u7684\uff0c\u5176\u6761\u4ef6\u8868\u8fbe\u5f0f\u8fd4\u56de\u7684\u7ed3\u679c\u662f$true\u548c$false\u3002\u4e0b\u4f8b\u8bf4\u660e\u5982\u4f55\u6bd4\u8f83\u4e00\u4e2a\u53d8\u91cf\u503c\u662f\u5426\u5c0f\u4e8e7\uff1a <\/p>\n<pre>PS C:\\&gt; $num= 5\nPS C:\\&gt; $num-lt 7\nTrue\nPS C:\\&gt; $num- 7\n-2<\/pre>\n<p>\u5176\u4e2d\u91c7\u7528\u4e86\u4e0d\u540c\u7684\u64cd\u4f5c\u7b26\uff0c\u5f97\u51fa\u7684\u7ed3\u679c\u5206\u522b\u662f\u5e03\u5c14\u7c7b\u578b\u548c\u6570\u5b57\u7c7b\u578b\u3002-lt\u64cd\u4f5c\u7b26\u68c0\u67e5\u8fd0\u7b97\u7b26\u5de6\u8fb9\u7684\u503c\u662f\u5426\u5c0f\u4e8e\u53f3\u8fb9\u7684\u503c\u3002 <\/p>\n<p>\u5728\u6761\u4ef6\u8868\u8fbe\u5f0f\u4e2d\u53ef\u4ee5\u5305\u542b\u5c5e\u6027\u5f15\u7528\u548c\u65b9\u6cd5\u8c03\u7528\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; $user=@{&quot;Name&quot;=&quot;LiMing&quot;;&quot;Age&quot;=30}\nPS C:\\&gt; $user.Age -lt 20\nFalse\nPS C:\\&gt; $user.ContainsValue(&quot;LiMing&quot;)\nTrue<\/pre>\n<p>\u4e5f\u53ef\u4ee5\u8c03\u7528PowerShell\u7684\u51fd\u6570\u3001cmdlet\u548c\u811a\u672c\u5757\uff0c\u5982\u542f\u52a8\u4e00\u4e2anotepad.exe\u8fdb\u7a0b\u5e76\u4e14\u68c0\u67e5\u5176\u8fd0\u884c\u7684\u8fdb\u7a0b\u6570\u662f\u5426\u5c11\u4e8e\u4e24\u4e2a\u3002\u4e00\u4e9b\u7f51\u7edc\u8fdb\u7a0b\u4f1a\u5360\u7528\u56fa\u5b9a\u7684\u7aef\u53e3\u53f7\uff0c\u5982\u679c\u524d\u4e00\u4e2a\u8fdb\u7a0b\u50f5\u6b7b\uff0c\u5728\u542f\u52a8\u65b0\u7684\u8fdb\u7a0b\u4e4b\u524d\u9700\u8981\u68c0\u67e5\u662f\u5426\u5b58\u5728\u4e00\u4e2a\u8fdb\u7a0b\uff1b\u5426\u5219\u540e\u9762\u542f\u52a8\u7684\u7a0b\u5e8f\u4e0d\u80fd\u83b7\u53d6\u5df2\u7ecf\u88ab\u5360\u7528\u7684\u7aef\u53e3\u800c\u62a5\u9519\uff1a <\/p>\n<pre>PS C:\\&gt; Get-Process notepad\n\nHandles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName\n-------  ------    -----      ----- -----   ------     -- -----------\n     48       2     1208       4084    54     0.89   2188 notepad\n\nPS C:\\&gt; (Get-Process notepad).Length -lt 2\nTruePS C:\\&gt; notepad.exe\nPS C:\\&gt; (Get-Process notepad).Length -lt 2\nFalse<\/pre>\n<p>\u5f00\u59cb\u770b\u5230\u53ea\u6709\u4e00\u4e2anotepad.exe\u7684\u8fdb\u7a0b\uff0c\u7b2c2\u4e2a\u547d\u4ee4\u5224\u65ad\u5f53\u524d\u8fdb\u7a0b\u4e2d\u7684notepad.exe\u7684\u6570\u91cf\u662f\u5426\u5c11\u4e8e\u4e24\u4e2a\uff0c\u7ed3\u679c\u8fd4\u56de\u5e03\u5c14\u7c7b\u578b\u7684\u771f\u503c\u3002\u5f53\u518d\u6b21\u542f\u52a8\u4e00\u4e2a\u8fdb\u7a0b\u65f6\uff0c\u8fd4\u56de\u503c\u5c31\u53d8\u4e3a\u5047\u3002 <\/p>\n<p><b>\u503c\u6bd4\u8f83<\/b><\/p>\n<p>PowerShell\u672a\u91c7\u7528\u7b97\u6570\u7b26\u53f7\u5982&lt;\u3001&gt;\u3001&lt;=\u3001&gt;=\u53ca=\u8fdb\u884c\u503c\u6bd4\u8f83\uff0c\u9996\u5148\u5b83\u5fc5\u987b\u4ee5Shell\u7684\u5f62\u5f0f\u51fa\u73b0\uff1b\u5176\u6b21\u624d\u4f5c\u4e3a\u4e00\u95e8\u7f16\u7a0b\u8bed\u8a00\u3002\u6240\u6709\u7684Shell\u90fd\u628a&gt;\u3001&gt;&gt;\u548c&lt;\u64cd\u4f5c\u7b26\u4fdd\u7559\u4e3a\u547d\u4ee4\u7684\u8f93\u51fa\u548c\u8f93\u5165\u91cd\u5b9a\u5411\uff0cPowerShell\u4e5f\u5982\u6b64\u3002PowerShell\u4f7f\u7528\u7c7b\u4f3c\u64cd\u4f5c\u540d\u7684\u7f29\u5199\u7684\u5f00\u5173\u4f5c\u4e3a\u6bd4\u8f83\u8fd0\u7b97\u7b26\u3002 <\/p>\n<p>\uff081\uff09-eq\uff1a\u76f8\u7b49\uff08equal\uff09\u64cd\u4f5c\u7b26\uff0c\u5728\u524d\u540e\u4e24\u4e2a\u5bf9\u8c61\u76f8\u7b49\u65f6\u8fd4\u56deTrue\uff1b\u5426\u5219\u8fd4\u56deFalse\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; 3 -eq 3\nTrue\nPS C:\\&gt; 3 -eq 4\nFalse<\/pre>\n<p>\uff082\uff09-ne\uff1a\u4e0d\u76f8\u7b49\uff08not-equal\uff09\u8fd0\u7b97\u7b26\uff0c\u76f8\u7b49\u64cd\u4f5c\u7b26\u7684\u9006\u8fd0\u7b97\u7b26\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; 3 \u2013ne 3\nFalse\nPS C:\\&gt; 3 \u2013ne 4\nTrue<\/pre>\n<p>\uff083\uff09-lt\uff1a\u5c0f\u4e8e\uff08less-than\uff09\u8fd0\u7b97\u7b26\uff0c\u5de6\u4fa7\u64cd\u4f5c\u6570\u5c0f\u4e8e\u53f3\u4fa7\u65f6\u8fd4\u56deTrue\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; 3 \u2013lt 4\nTrue<\/pre>\n<p>\uff084\uff09-gt\uff1a\u5927\u4e8e\uff08greater-than\uff09\u64cd\u4f5c\u7b26\uff0c\u5de6\u4fa7\u64cd\u4f5c\u6570\u5927\u4e8e\u53f3\u4fa7\u65f6\u8fd4\u56deTrue\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; 5 \u2013gt 4\nTrue<\/pre>\n<p>\uff085\uff09le\uff1a\u5c0f\u4e0e\u7b49\u4e8e\uff08less-than-or-equal\uff09\u64cd\u4f5c\u7b26\uff0c\u5224\u65ad\u7b2c1\u4e2a\u503c\u662f\u5426\u5c0f\u4e0e\u7b49\u4e8e\u7b2c2\u4e2a\u503c\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; 3 \u2013le 4\nTrue\nPS C:\\&gt; 3 \u2013le 4\nFalse<\/pre>\n<p>\uff086\uff09\uff1a-ge\u5927\u4e8e\u7b49\u4e8e\uff08greater-than-or-equal\uff09\u64cd\u4f5c\u7b26\uff0c\u7528\u6765\u68c0\u6d4b\u7b2c1\u4e2a\u503c\u662f\u5426\u5927\u4e8e\u7b49\u4e8e\u7b2c2\u4e2a\u503c\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; $a=4\nPS C:\\&gt; $a -ge 4\nTrue\nPS C:\\&gt; $a--\nPS C:\\&gt; $a -ge 4\nFalse<\/pre>\n<p>\u4e0a\u4f8b\u4e2d\u7684$a\u8bed\u53e5\u4f5c\u4e3a\u4e00\u4e2a\u53d8\u91cf\u7684\u5f15\u7528\u6765\u4f7f\u7528\uff0c\u53d8\u91cf\u88ab\u8d4b\u503c\u4e3a4\uff0c\u7136\u540e\u6bd4\u8f83\u662f\u5426\u5927\u4e8e\u7b49\u4e8e4\u3002 <\/p>\n<p>\u53ef\u4ee5\u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32\uff0c\u64cd\u4f5c\u4f1a\u6309\u7167\u5b57\u6bcd\u8868\u987a\u5e8f\u5904\u7406\u3002\u5373\u9010\u4e2a\u5b57\u7b26\u6bd4\u8f83\uff0c\u7531\u76f8\u540c\u5b57\u7b26\u5f00\u59cb\u7684\u5b57\u7b26\u4e32\u5e8f\u5217\u8f83\u77ed\u7684\u4e00\u4e2a\u5c06\u4f1a\u662f\u8f83\u5c0f\u503c\u3002\u4ee5\u4e0b\u662f\u51e0\u4e2a\u6bd4\u8f83\u5b57\u7b26\u4e32\u7684\u4f8b\u5b50\uff1a <\/p>\n<pre>PS C:\\&gt; &quot;a&quot; -lt &quot;b&quot;\nTrue\nPS C:\\&gt; &quot;a&quot; -lt &quot;ba&quot;\nTrue\nPS C:\\&gt; &quot;aa&quot; -lt &quot;aaa&quot;\nTrue\nPS C:\\&gt; &quot;cat&quot; -gt &quot;dog&quot;\nFalse<\/pre>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b57\u7b26\u4e32\u6bd4\u8f83\u65f6\u5ffd\u7565\u5927\u5c0f\u5199\uff0c\u5982\u201cLiMing\u201d\u7b49\u4e8e\u201cLIMING\u201d\uff1a <\/p>\n<pre>PS C:\\&gt; &quot;LiMing&quot; -eq &quot;LIMING&quot;\nTrue<\/pre>\n<p>\u5982\u679c\u9700\u8981\u5927\u5c0f\u5199\u654f\u611f\u6bd4\u8f83\uff0c\u53ef\u4ee5\u4f7f\u7528\u64cd\u4f5c\u7b26-ceq\u3001-clt\u3001-cle\u3001-cgt\u548c-cge\u3002\u8fd9\u4e9b\u64cd\u4f5c\u7b26\u5728\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u64cd\u4f5c\u7b26\u524d\u52a0\u4e86c\uff0c\u8fd9\u6837\u4fbf\u4e8e\u8bb0\u5fc6\u3002\u5927\u5c0f\u5199\u654f\u611f\u6bd4\u8f83\u65f6\uff0c\u5c0f\u5199\u5b57\u6bcd\u5c0f\u4e8e\u5927\u5199\u5b57\u6bcd\u3002\u4e0b\u4f8b\u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32\uff0c\u5176\u533a\u522b\u4ec5\u4ec5\u662f\u5927\u5c0f\u5199\uff1a <\/p>\n<pre>PS C:\\&gt; &quot;john&quot; -lt &quot;JOHN&quot;\nFalse\nPS C:\\&gt; &quot;john&quot; -gt &quot;JOHN&quot;\nFalse\nPS C:\\&gt; &quot;john&quot; -eq &quot;JOHN&quot;\nTrue\nPS C:\\&gt; &quot;john&quot; -ceq &quot;JOHN&quot;\nFalse\nPS C:\\&gt; &quot;john&quot; -cgt &quot;JOHN&quot;\nFalse \nPS C:\\&gt; &quot;john&quot; -clt &quot;JOHN&quot;\nTrue<\/pre>\n<p>\u201cjohn\u201d\u5728\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u6bd4\u8f83\u65f6\u7b49\u4e8e\u201cJOHN\u201d\uff1b\u5728\u5927\u5c0f\u5199\u654f\u611f\u7684\u6bd4\u8f83\u65f6\u5c0f\u4e8e\u201cJOHN\u201d\u3002 <\/p>\n<p>\u5728PowerShell\u4e2d\u660e\u786e\u7684\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u6bd4\u8f83\u64cd\u4f5c\u7b26\u662f\u5728\u9ed8\u8ba4\u64cd\u4f5c\u7b26\u524d\u52a0\u524d\u7f00i\uff0c\u5373-ieq\u3001-ilt\u3001-ile\u3001-igt\u548c-ige\uff0c\u5176\u4f5c\u7528\u662f\u63d0\u9ad8\u7a0b\u5e8f\u7684\u53ef\u8bfb\u6027\u3002 <\/p>\n<p><b>\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362<\/b><\/p>\n<p>\u5728PowerShell\u4e2d\u81ea\u52a8\u8f6c\u6362\u7684\u901a\u5e38\u89c4\u5219\u662f\u5bf9\u4e8e\u4e24\u4e2a\u4e0d\u540c\u7c7b\u578b\u53d8\u91cf\u7ec4\u6210\u7684\u8868\u8fbe\u5f0f\uff0c\u81ea\u52a8\u5c06\u53f3\u4fa7\u7684\u53d8\u91cf\u8f6c\u6362\u4e3a\u5de6\u4fa7\u53d8\u91cf\u7684\u7c7b\u578b\uff0c\u4e4b\u540e\u8ba1\u7b97\u8868\u8fbe\u5f0f\u7684\u503c\u3002\u4e0b\u4f8b\u6bd4\u8f83\u5b57\u7b26\u4e32\u548c\u6570\u5b57\u7c7b\u578b\uff1a <\/p>\n<pre>PS C:\\&gt; 2 -eq &quot;2&quot;\nTrue\nPS C:\\&gt; &quot;2&quot; -eq 2\nTrue<\/pre>\n<p>\u8be5\u4f8b\u5206\u522b\u628a\u5b57\u7b26\u4e32\u548c\u6570\u5b57\u9690\u5f0f\u8f6c\u6362\u4e3a\u6570\u5b57\u548c\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u6267\u884c\u6bd4\u8f83\u3002 <\/p>\n<p>\u9700\u8981\u8bb0\u4f4f\u7684\u662f\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\u603b\u662f\u8f6c\u6362\u53f3\u4fa7\u7684\u503c\uff0c\u6240\u4ee5\u4f1a\u4f34\u751f\u5f88\u591a\u4e0d\u5408\u903b\u8f91\u7684\u7ed3\u679c\u3002\u5982\u4e24\u4e2a\u53d8\u91cf\u662f\u76f8\u7b49\u4ec5\u4ec5\u53d6\u51b3\u4e8e\u6bd4\u8f83\u7684\u987a\u5e8f\uff0c\u5982\u4e0b\u4f8b\uff1a <\/p>\n<pre>PS C:\\&gt; 2 -eq &quot;02&quot;\nTrue\nPS C:\\&gt; &quot;02&quot; -eq 2\nFalse<\/pre>\n<p>\u7b2c1\u4e2a\u8868\u8fbe\u5f0f\u5c06\u5b57\u7b26\u4e32\u201c02\u201d\u8f6c\u6362\u4e3a\u6570\u5b572\uff0c\u8fd9\u6837\u4e24\u4e2a\u503c\u76f8\u7b49\uff1b\u7b2c2\u4e2a\u8868\u8fbe\u5f0f\u5c06\u6570\u5b572\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u201c02\u201d\uff0c\u8fd9\u6837\u4e24\u4e2a\u5b57\u7b26\u4e32\u4e0d\u7b49\u3002\u4e0b\u4f8b\u4f7f\u7528\u5176\u4ed6\u6bd4\u8f83\u8fd0\u7b97\u7b26\u3002 <\/p>\n<pre>PS C:\\&gt; 6 \u2013lt &quot;04&quot;\nTrue\nPS C:\\&gt; &quot;06&quot; -lt 4\nTrue<\/pre>\n<p>\u4e0a\u4f8b\u5b50\u4e2d\u7684\u6570\u5b576\u5e76\u4e0d\u5c0f\u4e8e4\uff08\u6570\u5b574\u7531\u5b57\u7b26\u4e32\u201c04\u201d\u8f6c\u6362\u800c\u6765\uff09\u3002\u5728\u7b2c2\u4e2a\u8868\u8fbe\u5f0f\u4e2d\uff0c\u4f5c\u4e3a\u4e00\u4e2a\u5b57\u7b26\u4e32\u201c06\u201d\u4e2d\u76840\u662f\u6bd4\u5b57\u7b26\u4e32\u201c4\u201d\u5728\u5b57\u6bcd\u8868\u4e2d\u5148\u51fa\u73b0\u7684\uff0c\u6240\u4ee5\u5c0f\u4e8e\u64cd\u4f5c\u7b26\u8fd4\u56deTrue\u503c\u3002 <\/p>\n<p><b>\u903b\u8f91\u548c\u4f4d\u64cd\u4f5c<\/b><\/p>\n<p>\u4f7f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26\u5c06\u591a\u4e2a\u6761\u4ef6\u7ec4\u5408\u5230\u4e00\u4e2a\u590d\u6742\u7684\u8868\u8fbe\u5f0f\u4e2d\u3002 <\/p>\n<p>\uff081\uff09-and <\/p>\n<p>\u4e0e\u64cd\u4f5c\u7b26\uff0c\u5728\u64cd\u4f5c\u7b26\u4e24\u8fb9\u7684\u64cd\u4f5c\u6570\u5747\u4e3a$true\u65f6\u8fd4\u56de$true\u3002\u4e0b\u4f8b\u68c0\u6d4b\u4e00\u4e2a\u6587\u4ef6\u662f\u5426\u5177\u6709.txt\u540e\u7f00\u5e76\u4e14\u5927\u5c0f\u8d85\u8fc710 KB\uff1a <\/p>\n<pre>PS C:\\&gt; dir *.txt\n\n\n    Directory: C:\\\n\nMode                LastWriteTime     Length Name\n----                -------------     ------ ----\n-a---          2009\/1\/3      6:01      12100 largetext.txt\n\nPS C:\\&gt; $file=Get-Item largetext.txt\nPS C:\\&gt; $file.Extension -eq &quot;.txt&quot; -and $file.Length -gt 10KB\nTrue<\/pre>\n<p>\u6ce8\u610f\u4efb\u4f55\u4e00\u4e2a\u6761\u4ef6\u8fd4\u56de$false\uff0c\u5c06\u4f1a\u4f7f\u5f97\u6574\u4e2a\u8868\u8fbe\u5f0f\u8fd4\u56de$false.\uff1a <\/p>\n<pre>PS C:\\&gt; $file.Length -gt 10KB\nFalse\nPS C:\\&gt; $file.Extension -eq &quot;.txt&quot; -and $file.Length -gt 10kb\nFalse<\/pre>\n<p>\uff082\uff09-or <\/p>\n<p>\u6216\u64cd\u4f5c\u7b26\uff0c\u5728\u4efb\u4f55\u4e00\u4e2a\u64cd\u4f5c\u6570\u4e3a$true\u65f6\u8fd4\u56de$true\uff0c\u4e0b\u4f8b\u68c0\u9a8c\u6587\u4ef6\u662f\u5426\u4e3a\u4eca\u5929\u521b\u5efa\u6216\u8005\u4fee\u6539\u7684\uff1a <\/p>\n<pre>PS C:\\&gt; $file.CreationTime.Date -eq [datetime]::Today -or `\n&gt;&gt; $file.LastAccessTime.Date -eq [datetime]::Today\n&gt;&gt;\nTrue<\/pre>\n<p>\u5176\u4e2d\u4f7f\u7528CreationTime\u548cLastAccessTime\u5c5e\u6027\u83b7\u53d6\u521b\u5efa\u548c\u8bbf\u95ee\u65f6\u95f4\uff0c\u4f7f\u7528DateTime\u7684Date\u5c5e\u6027\u6765\u622a\u65ad\u6240\u9700\u7684\u65e5\u671f\u3002 <\/p>\n<p>\uff083\uff09-xor <\/p>\n<p>\u5f02\u6216\u64cd\u4f5c\u7b26\uff0c\u5982\u679c\u6709\u4e00\u4e2a\u64cd\u4f5c\u6570\u662f$true\uff0c\u90a3\u4e48\u8868\u8fbe\u5f0f\u8fd4\u56de$true\uff1b\u5982\u679c\u4e24\u4e2a\u64cd\u4f5c\u6570\u5747\u4e3a$true\uff0c\u5219\u8fd4\u56de$false\uff0c\u4e0b\u4f8b\u68c0\u67e5\u4e00\u4e2a\u6587\u4ef6\u662f\u5426\u5177\u6709.txt\u540e\u7f00\uff0c\u6216\u8005\u53ea\u8bfb\u7684\u3002\u5982\u679c\u4e24\u4e2a\u6761\u4ef6\u540c\u65f6\u6ee1\u8db3\uff0c\u5219\u6392\u9664\u5728\u5916\uff1a <\/p>\n<pre>PS C:\\&gt; attrib +r test.txt\nPS C:\\&gt; attrib -r test2.txt\nPS C:\\&gt; $file1=Get-Item test.txt\nPS C:\\&gt; $file2=Get-Item test2.txt\nPS C:\\&gt; $file1.Extension -eq &quot;.txt&quot; -xor $file1.IsReadOnly\nFalse\nPS C:\\&gt; $file2.Extension -eq &quot;.txt&quot; -xor $file2.IsReadOnly\nTrue<\/pre>\n<p>\u4e0a\u4f8b\u4e3atest.txt\u8bbe\u5b9a\u53ea\u8bfb\u5c5e\u6027\uff0c\u5e76\u4e14\u6e05\u9664test2.txt\u7684\u53ea\u8bfb\u5c5e\u6027\u3002 <\/p>\n<p>\uff084\uff09-not\u6216\u8005\uff01 <\/p>\n<p>\u53d6\u53cd\u64cd\u4f5c\u7b26\uff0c\u53ea\u6709\u4e00\u4e2a\u64cd\u4f5c\u6570\uff0c\u4f5c\u7528\u5c06\u5176\u53d6\u53cd\u3002\u5982\u679c\u64cd\u4f5c\u6570\u4e3a$true\uff0c\u5219\u8fd4\u56de$false\u3002\u4e0b\u4f8b\u68c0\u67e5\u4e00\u4e2a\u6587\u4ef6\u662f\u5426\u4e3a\u53ea\u8bfb\uff1a <\/p>\n<pre>PS C:\\&gt; $file=Get-Item test2.txt\nPS C:\\&gt; $file.IsReadOnly\nFalse\nPS C:\\&gt; -not $file.IsReadOnly\nTrue\nPS C:\\&gt; !$file.IsReadOnly\nTrue<\/pre>\n<p>\uff085\uff09-band\u548c-bor <\/p>\n<p>\u6309\u4f4d\u64cd\u4f5c\u4e0e\uff08-band\uff09\u548c\u6309\u4f4d\u6216\uff08-bor\uff09\u64cd\u4f5c\u7b26\uff0c\u4ec5\u7528\u4e8e\u6574\u6570\u3002\u4f1a\u6309\u4f4d\u6bd4\u8f83\u4e24\u4e2a\u64cd\u4f5c\u6570\u5bf9\u5e94\u7684\u4f4d\uff0c\u7ed3\u679c\u4e3a$true\u7684\u4f4d\u51d1\u6210\u7684\u6574\u6570\u3002\u5c3d\u7ba1PowerShell\u4e0d\u652f\u6301\u4e8c\u8fdb\u5236\u6570\uff0c\u4e8c\u8fdb\u5236\u64cd\u4f5c\u53ef\u4ee5\u88ab\u7406\u89e3\u4e3a\u8f93\u5165\u7684\u6570\u4ee5\u4e8c\u8fdb\u5236\u7684\u5f62\u5f0f\u51fa\u73b0\u5e76\u6267\u884c\u5bf9\u5e94\u7684\u4f4d\u64cd\u4f5c\u3002\u4e0b\u4f8b\u4f7f\u7528-band\u6309\u4f4d\u4e0e\u6570\u5b573\u548c1\uff1a <\/p>\n<pre>PS C:\\&gt; 3 -band 1\n1<\/pre>\n<p>\u6570\u5b573\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u5f62\u5f0f\u662f11\uff0c1\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u5f62\u5f0f\u662f01\u3002-band\u64cd\u4f5c\u7b26\u9010\u4f4d\u6267\u884c\u4e0e\u64cd\u4f5c\uff0c\u4e24\u4e2a\u6570\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u53ea\u6709\u53f3\u9762\u7684\u4e00\u4f4d\u540c\u65f6\u4e3a1\uff0c\u6240\u4ee5\u7ed3\u679c\u4e3a\u4e8c\u8fdb\u5236\u768401\uff0c\u540c\u6837\u5728\u5341\u8fdb\u5236\u4e2d\u4e5f\u662f1\u3002 <\/p>\n<pre>11\n-band    01\n=        01<\/pre>\n<p>-bor\u7684\u7528\u6cd5\u5982\u4e0b\uff1a <\/p>\n<pre>PS C:\\&gt; 2 -bor 1\n3<\/pre>\n<p>\u6570\u5b572\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u5f62\u5f0f\u662f10\uff0c1\u7684\u8868\u793a\u5f62\u5f0f\u662f01\u3002\u8fd9\u6837\u4e8c\u8fdb\u5236\u7684\u6216\u64cd\u4f5c\u5c06\u8fd4\u56de\u4e8c\u8fdb\u5236\u768411\uff0c\u5373\u5341\u8fdb\u5236\u4e2d\u76843\uff1a <\/p>\n<pre>10\n-bor      01\n=         11<\/pre>\n<p>\u4e0e\u4f4d\u64cd\u4f5c\u5728\u811a\u672c\u8bed\u8a00\u4e2d\u4e0e\u5916\u90e8\u4ea4\u4e92\u65f6\u4f7f\u7528\uff0c\u5982\u4f20\u9012\u7ed9\u7a0b\u5e8f\u4e00\u4e2a\u6807\u5fd7\u4f4d\u5e76\u9a8c\u8bc1\u5176\u662f\u5426\u6210\u529f\u8bbe\u7f6e\uff0c\u4e3a\u6b64\u9700\u8981\u6267\u884c\u6309\u4f4d\u4e0e\uff08-and\uff09\u64cd\u4f5c\u3002\u66f4\u5e38\u89c1\u7684\u4f8b\u5b50\u662f\u4e0e.NET\u5bf9\u8c61\u4ea4\u4e92\u65f6\u8fd4\u56de\u4e00\u4e2a\u679a\u4e3e\u6807\u5fd7\u4f4d\uff0c\u8fd9\u4e9b\u679a\u4e3e\u7684\u503c\u662f\u7ecf\u8fc7\u4ed4\u7ec6\u6311\u9009\u7684\uff0c\u5b83\u4eec\u5360\u7528\u4e0d\u540c\u7684\u4f4d\uff0c\u800c\u4e14\u5176\u4e2d\u7684\u591a\u4f4d\u80fd\u591f\u7528\u4e8c\u8fdb\u5236\u6216\u64cd\u4f5c\u5408\u5e76\u4e3a\u4e00\u4e2a\u503c\u3002\u4e0a\u9762\u7b2c1\u4e2a\u4f8b\u5b50\u4e2d\u5b58\u5728\u4e00\u4e2a\u6587\u4ef6\u5c5e\u6027\u7684\u679a\u4e3e\u5bf9\u8c61\u3002\u6587\u4ef6\u5c5e\u6027\uff08FileInfo\uff09\u5bf9\u8c61\u7684\u5c5e\u6027\u5c06\u8fd4\u56de\u4e00\u4e2aSystem.IO.FileAttributes\u679a\u4e3e\u5bf9\u8c61\uff0c\u5176\u7ec4\u6210\u5982\u88681\u6240\u793a\u3002 <\/p>\n<p align=\"center\">\u88681 System.IO.FileAttributes\u7684\u7ec4\u6210 <\/p>\n<table style=\"border-left-color: #000000; border-bottom-color: #000000; border-top-color: #000000\" cellspacing=\"0\" cellpadding=\"0\" width=\"352\" border=\"1\">\n<tbody>\n<tr>\n<td width=\"168\">\n<p>\u540d\u79f0<\/p>\n<\/td>\n<td width=\"182\">\u503c<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">ReadOnly<\/td>\n<td width=\"182\">0x01<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Hidden<\/td>\n<td width=\"182\">0x02<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">System<\/td>\n<td width=\"182\">0x04<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Archive<\/td>\n<td width=\"182\">0x20<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Directory<\/td>\n<td width=\"182\">0x10<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Device<\/td>\n<td width=\"182\">0x40<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Normal<\/td>\n<td width=\"182\">0x80<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Temporary<\/td>\n<td width=\"182\">0x100<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">SparseFile<\/td>\n<td width=\"182\">0x200<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">ReparsePoint<\/td>\n<td width=\"182\">0x400<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Compressed<\/td>\n<td width=\"182\">0x800<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">ReadOnly<\/td>\n<td width=\"182\">0x01<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Hidden<\/td>\n<td width=\"182\">0x02<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">System<\/td>\n<td width=\"182\">0x04<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Archive<\/td>\n<td width=\"182\">0x20<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Directory<\/td>\n<td width=\"182\">0x10 <\/td>\n<\/tr>\n<tr>\n<td width=\"168\">\n<p>Device<\/p>\n<\/td>\n<td width=\"182\">0x40<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Normal<\/td>\n<td width=\"182\">0x80<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Temporary<\/td>\n<td width=\"182\">0x100<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">SparseFile<\/td>\n<td width=\"182\">0x200<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">ReparsePoint<\/td>\n<td width=\"182\">0x400<\/td>\n<\/tr>\n<tr>\n<td width=\"168\">Compressed<\/td>\n<td width=\"182\">0x800 <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u5728\u68c0\u6d4b\u4e00\u4e2a\u6587\u4ef6\u7684\u5c5e\u6027\u65f6\u5f97\u5230\u7684\u503c\u662f\u5341\u516d\u8fdb\u5236\u76843\uff0c\u5219\u8bf4\u660e\u8fd9\u4e2a\u6587\u4ef6\u540c\u65f6\u5177\u6709\u53ea\u8bfb\u548c\u9690\u85cf\u5c5e\u6027\u3002\u56e0\u4e3a1\u6309\u4f4d\u62162\u6309\u4f4d\u5f97\u5230\u7684\u503c\u662f3\uff0c\u5373\u4e8c\u8fdb\u5236\u4e2d\u768411\u3002\u4e0b\u4f8b\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\u6765\u68c0\u6d4b\u4e00\u4e2a\u5177\u6709\u53ea\u8bfb\u5c5e\u6027\u7684\u6587\u4ef6\uff1a <\/p>\n<pre>PS C:\\&gt; $file=Get-Item C:\\pagefile.sys -force\nPS C:\\&gt; $file.Attributes -band 0x01\n0\nPS C:\\&gt; $file.Attributes -band 0x02\n2\nPS C:\\&gt; $file.Attributes -band 0x04\n4<\/pre>\n<p>\u7b2c1\u4e2a\u64cd\u4f5c\u7684\u8fd4\u56de\u503c\u662f0\uff0c\u8bf4\u660e\u4e0d\u662f\u53ea\u8bfb\u7684\uff1b\u7b2c2\u4e2a\u64cd\u4f5c\u8fd4\u56de\u975e\u96f6\u503c\uff0c\u8bf4\u660e\u5df2\u8bbe\u7f6e\u76f8\u5e94\u4f4d\uff0c\u5373\u8be5\u6587\u4ef6\u5177\u6709\u9690\u85cf\u548c\u7cfb\u7edf\u5c5e\u6027\u3002\u9700\u8981\u6ce8\u610f\u7684\u4e00\u70b9\u662f\u5728\u4f7f\u7528Get-Item\u83b7\u53d6\u9690\u85cf\u5bf9\u8c61\u6587\u4ef6\u65f6\u4f7f\u7528\u4e86-force\u5f00\u5173\u3002 <\/p>\n<p>\u4e3a\u4e86\u68c0\u6d4b\u6587\u4ef6\u662f\u5426\u5177\u6709\u9690\u85cf\u548c\u7cfb\u7edf\u5c5e\u6027\uff0c\u53ef\u4ee5\u75286\u6309\u4f4d\u4e0e\u5176\u5c5e\u6027\u503c\uff0c\u53732\u548c4\u6309\u4f4d\u83b7\u5f97\u7ed3\u679c\uff1a <\/p>\n<pre>PS C:\\&gt; $file.Attributes -band 0x06\n6<\/pre>\n<p>\u901a\u5e38\u60c5\u51b5\u4e0b\u4e3a\u63d0\u9ad8\u7a0b\u5e8f\u7684\u53ef\u8bfb\u6027\uff0c\u4f1a\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\uff1a <\/p>\n<pre>PS C:\\&gt; $file.Attributes -band (0x02 \u2013bor 0x04)\n6<\/pre>\n<p>\u7b14\u8005\u63a8\u8350\u4f7f\u7528\u53d8\u91cf\u6765\u5b9e\u73b0\u64cd\u4f5c\u610f\u56fe\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; $hidden=0x02\nPS C:\\&gt; $system=0x04\nPS C:\\&gt; $file.Attributes -band ($hidden -bor $system)\n6<\/pre>\n<p><b>\u5e03\u5c14\u8f6c\u6362<\/b><\/p>\n<p>\u5305\u62ec\u4f4d\u64cd\u4f5c\u7b26\u5728\u5185\u7684\u591a\u4e2a\u64cd\u4f5c\u7b26\u8fd4\u56de\u6570\u5b57\u7c7b\u578b\u7684\u503c\uff0cPowerShell\u53ef\u4ee5\u81ea\u52a8\u5c06\u5176\u8f6c\u6362\u4e3a\u5e03\u5c14\u7c7b\u578b\u7684\u503c\uff0c\u8f6c\u6362\u89c4\u5219\u662f\u4efb\u4f55\u975e\u7a7a\u503c\u5c06\u4f1a\u88ab\u8f6c\u6362\u4e3a$true\u3002\u975e\u7a7a\u7684\u6982\u5ff5\u53ef\u4ee5\u88ab\u5ef6\u4f38\u5230\u66f4\u5bbd\u6cdb\u7684\u8303\u56f4\uff0c\u4e0b\u7684\u5373PowerShell\u5c06\u4f1a\u5728\u9700\u8981\u65f6\u9690\u5f0f\u8f6c\u6362\u4e3a\u5e03\u5c14\u503c\u3002\u4e5f\u53ef\u4ee5\u5728\u4efb\u4f55\u503c\u524d\u52a0[bool]\u6765\u663e\u5f0f\u6267\u884c\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\uff0c\u8f6c\u6362\u89c4\u5219\u5982\u4e0b\u3002 <\/p>\n<p>\uff081\uff09\u4efb\u4f55\u975e\u96f6\u503c\u5c06\u4f1a\u88ab\u8f6c\u6362\u4e3a$true\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; [bool] 1\nTrue\nPS C:\\&gt; [bool] 5\nTrue\nPS C:\\&gt; [bool] 5000\nTrue\nPS C:\\&gt; [bool] 0\nFalse<\/pre>\n<p>\u8fd9\u610f\u5473\u7740\u53ef\u5728\u6761\u4ef6\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u6570\u5b57\uff0cPowerShell\u7684\u89e3\u91ca\u5f15\u64ce\u5c06\u4f1a\u81ea\u52a8\u5b8c\u6210\u8f6c\u6362\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; $true -and 3000\nTrue<\/pre>\n<p>\uff082\uff09\u975e\u96f6\u957f\u5ea6\u7684\u5b57\u7b26\u4e32\u5c06\u4f1a\u88ab\u8f6c\u6362\u4e3a$true\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; [bool] &quot;true&quot;\nTrue\nPS C:\\&gt; [bool] &quot;false&quot;\nTrue\nPS C:\\&gt; [bool] &quot;something else&quot;\nTrue\nPS C:\\&gt; [bool] &quot;&quot;\nFalse<\/pre>\n<p>\uff083\uff09\u81f3\u5c11\u6709\u4e00\u9879\u7684\u96c6\u5408\u4f1a\u8fd4\u56de$true\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; [bool] (1,2)\nTrue\nPS C:\\&gt; [bool] (&quot;one&quot;,&quot;two&quot;)\nTrue\nPS C:\\&gt; [bool] @()\nFalse<\/pre>\n<p>\uff084\uff09\u5176\u4ed6\u5bf9\u8c61\u5c06\u4f1a\u88ab\u8f6c\u6362\u6210$true\uff0c\u9664\u975e\u5b83\u4eec\u4e3a$null\u3002\u5047\u8bbeWord\u6b63\u5728\u8fd0\u884c\uff0c\u4e0b\u4f8b\u5c06\u5176\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5e03\u5c14\u7c7b\u578b\u7684\u503c\uff1a <\/p>\n<pre>PS C:\\&gt; [bool] (Get-Process winword)\nTrue<\/pre>\n<p>\u53ef\u4ee5\u4f9d\u6b64\u7c7b\u63a8\uff0c\u975e$null\u503c\u7684\u5bf9\u8c61\u4f1a\u88ab\u8f6c\u6362\u4e3afalse\uff0c\u5982\uff1a <\/p>\n<pre>PS C:\\&gt; $user=@{&quot;Name&quot;=&quot;LiMing&quot;;&quot;Age&quot;=20}\nPS C:\\&gt; [bool]$user\nTrue\nPS C:\\&gt; [bool]$null\nFalse<\/pre>\n<p>\u524d\u9762\u4f7f\u7528\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u7684\u4ee3\u7801\u53ea\u662f\u4e3a\u4e86\u63cf\u8ff0PowerShell\u5982\u4f55\u6267\u884c\u7c7b\u578b\u8f6c\u6362\uff0c\u5373\u4f7f\u672a\u6307\u5b9a\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\uff0cPowerShell\u4e5f\u4f1a\u81ea\u52a8\u5b8c\u6210\u8f6c\u6362\u3002 <\/p>\n<p>\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\u901a\u8fc7\u4e00\u5bf9\u53d6\u53cd\u64cd\u4f5c\u7b26\uff08!!\uff09\uff0c\u5982\u628a\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5e03\u5c14\u7c7b\u578b\uff1a <\/p>\n<pre>PS C:\\&gt; !!2\nTrue\nPS C:\\&gt; !!&quot;test&quot;\nTrue\nPS C:\\&gt; !!0\nFalse\nPS C:\\&gt; !!$null\nFalse\nPS C:\\&gt; !!(Get-Process winword)\nTrue<\/pre>\n<p>\u9760\u8fd1\u5bf9\u8c61\u7684\u4e00\u4e2a\u611f\u53f9\u53f7\u5c06\u539f\u59cb\u503c\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\u4e3a\u5e03\u5c14\u503c\u5e76\u4e14\u5c06\u5176\u53d6\u53cd\uff0c\u9760\u5916\u4fa7\u7684\u611f\u53f9\u53f7\u518d\u6b21\u5bf9\u7ed3\u679c\u53d6\u53cd\u3002\u4f7f\u7528\u53cc\u611f\u53f9\u53f7\u80fd\u591f\u5728\u547d\u4ee4\u884c\u4e2d\u5feb\u901f\u6267\u884c\u8f6c\u6362\uff0c\u4f46\u662f\u5728\u5927\u578b\u7684\u811a\u672c\u4e2d\u6700\u597d\u8fd8\u662f\u4f7f\u7528\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\uff0c\u4ee5\u63d0\u9ad8\u5176\u53ef\u8bfb\u6027\u3002 <\/p>\n<p><b>\u5b57\u7b26\u4e92\u8f6c\u6362\u7684\u4f5c\u7528<\/b><\/p>\n<p>\u5982\u524d\u6240\u8ff0\uff0c-like\u548c-match\u5b57\u7b26\u4e32\u64cd\u4f5c\u7b26\u4e3a\u771f\uff0c\u53ef\u4ee5\u7528\u5176\u68c0\u6d4b\u5b57\u7b26\u4e32\u662f\u5426\u7531\u7279\u5b9a\u6a21\u5f0f\u7ec4\u6210\u6216\u5176\u4e2d\u662f\u5426\u5305\u542b\u6240\u9700\u7684\u5b57\u7b26\u4e32\u5f62\u5f0f\u3002\u5f53\u9700\u8981\u628a\u5404\u5f0f\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u65f6\uff0c\u8fd9\u662f\u5f88\u6709\u7528\u7684\uff0c\u5e76\u4e14\u53ef\u4ee5\u4f7f\u6761\u4ef6\u8868\u8fbe\u66f4\u52a0\u7d27\u51d1\u548c\u5bcc\u6709\u8868\u73b0\u529b\u3002\u4e0b\u4f8b\u4ecd\u83b7\u53d6\u6587\u4ef6\u5c5e\u6027\uff0cSystem.IO.FileAttributes\u679a\u4e3e\u5bf9\u8c61\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff1a <\/p>\n<pre>PS C:\\&gt; $file=Get-Item C:\\pagefile.sys -force\nPS C:\\&gt; $file.Attributes\nHidden, System, Archive\nPS C:\\&gt; [string] $file.Attributes\nHidden, System, Archive<\/pre>\n<p>\u53ef\u4ee5\u4f7f\u7528-like\u64cd\u4f5c\u7b26\u6765\u68c0\u6d4b\u8fd9\u4e2a\u6587\u4ef6\u662f\u5426\u4e3a\u9690\u85cf\u6216\u8005\u7cfb\u7edf\u6587\u4ef6\uff1a <\/p>\n<pre>PS C:\\&gt; $file.Attributes -like &quot;*Hidden*&quot;\nTrue\nPS C:\\&gt; $file.Attributes -like &quot;*System*&quot;\nTrue<\/pre>\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528-or\u64cd\u4f5c\u7b26\u68c0\u6d4b\u8fd9\u4e2a\u6587\u4ef6\u5b58\u5728\u9690\u85cf\u6216\u8005\u7cfb\u7edf\u5c5e\u6027\uff1a <\/p>\n<pre>PS C:\\&gt; $file.Attributes -like &quot;*Hidden*&quot; \u2013or  $file.Attributes -like &quot;*System*&quot;\nTrue<\/pre>\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528-match\u64cd\u4f5c\u7b26\uff0c\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u540c\u65f6\u68c0\u6d4b\u4e24\u4e2a\u5c5e\u6027\uff1a <\/p>\n<pre>PS C:\\&gt; $file.Attributes -match &quot;Hidden|System&quot;\nTrue<\/pre>\n<p><b>\u96c6\u5408\u4e0e\u6761\u4ef6\u8868\u8fbe\u5f0f<\/b><\/p>\n<p>\u7edd\u5927\u591a\u6570\u7f16\u7a0b\u8bed\u8a00\u628a\u96c6\u5408\u4f5c\u4e3a\u5355\u72ec\u7684\u5bf9\u8c61\u6765\u5904\u7406\uff0c\u5141\u8bb8\u7528\u6237\u901a\u8fc7\u68c0\u67e5\u96c6\u5408\u5bf9\u8c61\u6216\u4f7f\u7528\u5bf9\u8c61\u96c6\u5408\u5185\u90e8\u7684\u5bf9\u8c61\u6765\u4e66\u5199\u6761\u4ef6\u8868\u8fbe\u5f0f\u3002PowerShell\u5141\u8bb8\u5728\u6761\u4ef6\u8868\u8fbe\u5f0f\u7684\u5de6\u8fb9\u4f7f\u7528\u96c6\u5408\u3002Shell\u89e3\u91ca\u5f15\u64ce\u5c06\u4f1a\u628a\u6761\u4ef6\u8868\u8fbe\u5f0f\u9010\u4e2a\u5e94\u7528\u5230\u96c6\u5408\u7684\u6210\u5458\u4e0a\uff0c\u7ed3\u679c\u662f\u5305\u542b\u8fd4\u56de\u771f\u503c\u7684\u6210\u5458\u65b0\u96c6\u5408\u3002\u4e8b\u5b9e\u4e0a\u8fd9\u4e2a\u7279\u6027\u53ef\u4ee5\u7528\u6765\u8fc7\u6ee4\u96c6\u5408\uff0c\u5982\u4e0b\u4f8b\uff1a <\/p>\n<pre>PS C:\\&gt; 1,2,3,4,5 -lt 3\n1\n2\nPS C:\\&gt; 1..6 -le 4\n1\n2\n3\n4<\/pre>\n<p>\u5728\u5305\u542b\u4efb\u4f55\u7c7b\u578b\u5bf9\u8c61\u7684\u96c6\u5408\u4e0a\u4f7f\u7528\u6761\u4ef6\u8868\u8fbe\u5f0f\uff0c\u4e0b\u4f8b\u83b7\u53d6\u5b57\u7b26\u4e32\u201cLiMing\u201d\uff1a <\/p>\n<pre>PS C:\\&gt; &quot;LiMing&quot;,&quot;XiaoPang&quot;,&quot;WangGang&quot;,&quot;XiaoHu&quot;,&quot;LiMing&quot; -eq &quot;LiMing&quot;\nLiMing\nLiMing<\/pre>\n<p>\u6240\u6709\u7684\u6761\u4ef6\u8868\u8fbe\u5f0f\u7684\u89c4\u5219\u5728\u8fd9\u91cc\u5747\u53ef\u7528\uff0c\u53ea\u662f\u6761\u4ef6\u8868\u8fbe\u5f0f\u7684\u5bf9\u8c61\u6539\u4e3a\u5bf9\u8c61\u7684\u96c6\u5408\uff0c\u4e0b\u4f8b\u8bf4\u660e\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\u7684\u4f5c\u7528\uff1a <\/p>\n<pre>PS C:\\&gt; 3,4,5,6 -eq &quot;4&quot;\n4<\/pre>\n<p><b>\u603b\u7ed3<\/b><\/p>\n<p>\u5982\u679c\u8bf4\u7b97\u6cd5\u662f\u7a0b\u5e8f\u7684\u7075\u9b42\uff0c\u90a3\u4e48\u63a7\u5236\u6d41\u5c31\u662f\u7a0b\u5e8f\u8fd0\u884c\u7684\u9aa8\u67b6\u3002\u63a7\u5236\u6d41\u76f4\u63a5\u51b3\u5b9a\u4e86\u7a0b\u5e8f\u8fd0\u884c\u8def\u5f84\uff0c\u63a7\u5236\u6d41\u7684\u5185\u5bb9\u5c06\u4f1a\u8d2f\u7a7f\u6574\u4e2aPowerShell\u5b66\u4e60\u7684\u5168\u8fc7\u7a0b\uff0c\u672c\u6587\u4e3b\u8981\u8bb2\u89e3\u4e86\u5206\u652f\u8bed\u53e5\uff0c\u638c\u63e1\u4e86\u8fd9\u90e8\u5206\u5185\u5bb9\u4e4b\u540e\u8bfb\u8005\u5c31\u53ef\u4ee5\u5199\u51fa\u5728\u65e5\u5e38\u5de5\u4f5c\u4e2d\u7528\u5230\u8be5\u529f\u80fd\u7684\u547d\u4ee4\u3002<\/p>\n<p>\u8d5b\u8fea\u7f51\u5730\u5740\uff1a<a title=\"http:\/\/news.ccidnet.com\/art\/32857\/20100610\/2083229_1.html\" href=\"http:\/\/news.ccidnet.com\/art\/32857\/20100610\/2083229_1.html\">http:\/\/news.ccidnet.com\/art\/32857\/20100610\/2083229_1.html<\/a><\/p>\n<p>\u4f5c\u8005: \u4ed8\u6d77\u519b<br \/>\n  <br \/>\u7248\u6743\uff1a\u672c\u6587\u7248\u6743\u5f52\u4f5c\u8005\u6240\u6709<\/p>\n<p>\u8f6c\u8f7d\uff1a\u6b22\u8fce\u8f6c\u8f7d\uff0c\u4e3a\u4e86\u4fdd\u5b58\u4f5c\u8005\u7684\u521b\u4f5c\u70ed\u60c5\uff0c\u8bf7\u6309\u8981\u6c42\u3010\u8f6c\u8f7d\u3011\uff0c\u8c22\u8c22<\/p>\n<p>\u8981\u6c42\uff1a\u672a\u7ecf\u4f5c\u8005\u540c\u610f\uff0c\u5fc5\u987b\u4fdd\u7559\u6b64\u6bb5\u58f0\u660e\uff1b\u5fc5\u987b\u5728\u6587\u7ae0\u4e2d\u7ed9\u51fa\u539f\u6587\u8fde\u63a5\uff1b\u5426\u5219\u5fc5\u7a76\u6cd5\u5f8b\u8d23\u4efb <\/p>\n<p>\u4e2a\u4eba\u7f51\u7ad9: http:\/\/txj.shell.tor.hu\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0e\u7b97\u6570\u8868\u8fbe\u5f0f\u7c7b\u4f3c\uff0c\u6761\u4ef6\u8868\u8fbe\u5f0f\u4f7f\u7528\u4e00\u7cfb\u5217\u64cd\u4f5c\u6c42\u503c\u7528\u6765\u8ba1\u7b97\u7ed3\u679c\u3002\u5e76\u4e14\u5f97\u5230\u4e00\u4e2a\u5e03\u5c14\u7c7b\u578b\u7684\u7ed3\u679c\uff0c\u5373\u771f\u548c\u5047\u3002\u5982\u679c\u6709\u65f6\u5f97\u51fa [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-33109","post","type-post","status-publish","format-standard","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=\/wp\/v2\/posts\/33109"}],"collection":[{"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=33109"}],"version-history":[{"count":1,"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=\/wp\/v2\/posts\/33109\/revisions"}],"predecessor-version":[{"id":33807,"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=\/wp\/v2\/posts\/33109\/revisions\/33807"}],"wp:attachment":[{"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=33109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=33109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=33109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}