{"id":319,"date":"2026-04-12T21:59:53","date_gmt":"2026-04-12T13:59:53","guid":{"rendered":"https:\/\/www.resilence.cn\/?p=319"},"modified":"2026-04-12T21:59:53","modified_gmt":"2026-04-12T13:59:53","slug":"day-4-%e8%bf%90%e7%ae%97%e7%ac%a6%e4%b8%8e%e8%a1%a8%e8%be%be%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/www.resilence.cn\/?p=319","title":{"rendered":"Day-4-\u8fd0\u7b97\u7b26\u4e0e\u8868\u8fbe\u5f0f"},"content":{"rendered":"<h1>Day 4: \u8fd0\u7b97\u7b26\u4e0e\u8868\u8fbe\u5f0f<\/h1>\n<h2>\ud83c\udfaf \u5b66\u4e60\u76ee\u6807<\/h2>\n<ul>\n<li>\u7406\u89e3 PowerShell \u4e2d\u5404\u79cd\u8fd0\u7b97\u7b26\u7684\u4f5c\u7528\u548c\u7528\u6cd5<\/li>\n<li>\u638c\u63e1\u7b97\u672f\u8fd0\u7b97\u7b26\u8fdb\u884c\u6570\u5b66\u8ba1\u7b97<\/li>\n<li>\u5b66\u4f1a\u6bd4\u8f83\u8fd0\u7b97\u7b26\u8fdb\u884c\u6761\u4ef6\u5224\u65ad<\/li>\n<li>\u4f7f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26\u7ec4\u5408\u591a\u4e2a\u6761\u4ef6<\/li>\n<li>\u4e86\u89e3\u5b57\u7b26\u4e32\u8fd0\u7b97\u7b26\u7684\u7279\u6b8a\u7528\u6cd5<\/li>\n<li>\u638c\u63e1\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7\u89c4\u5219<\/li>\n<\/ul>\n<hr>\n<h2>\ud83d\udca1 \u6838\u5fc3\u6982\u5ff5<\/h2>\n<h3>\u4ec0\u4e48\u662f\u8fd0\u7b97\u7b26\uff1f<\/h3>\n<p>\u8fd0\u7b97\u7b26\u662f\u7528\u4e8e\u6267\u884c\u64cd\u4f5c\u7684\u7b26\u53f7\u6216\u5173\u952e\u5b57\u3002\u5728 PowerShell \u4e2d\uff0c\u8fd0\u7b97\u7b26\u53ef\u4ee5\u7528\u4e8e\uff1a<\/p>\n<ul>\n<li>\u6570\u5b66\u8ba1\u7b97<\/li>\n<li>\u5b57\u7b26\u4e32\u64cd\u4f5c<\/li>\n<li>\u6bd4\u8f83\u503c\u7684\u5927\u5c0f<\/li>\n<li>\u903b\u8f91\u5224\u65ad<\/li>\n<li>\u7c7b\u578b\u8f6c\u6362<\/li>\n<\/ul>\n<h3>\u4ec0\u4e48\u662f\u8868\u8fbe\u5f0f\uff1f<\/h3>\n<p>\u8868\u8fbe\u5f0f\u662f\u7531\u8fd0\u7b97\u7b26\u3001\u64cd\u4f5c\u6570\uff08\u53d8\u91cf\u3001\u503c\u3001\u51fd\u6570\u8c03\u7528\u7b49\uff09\u7ec4\u5408\u800c\u6210\u7684\u5f0f\u5b50\uff0c\u53ef\u4ee5\u88ab PowerShell \u6c42\u503c\u5e76\u4ea7\u751f\u7ed3\u679c\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre><code class=\"language-powershell\"># \u7b80\u5355\u8868\u8fbe\u5f0f\n5 + 3\n\n# \u590d\u6742\u8868\u8fbe\u5f0f\n($age -ge 18) -and ($hasLicense -eq $true)\n<\/code><\/pre>\n<hr>\n<h2>\ud83d\udcdd \u7b97\u672f\u8fd0\u7b97\u7b26<\/h2>\n<p>\u7b97\u672f\u8fd0\u7b97\u7b26\u7528\u4e8e\u6267\u884c\u6570\u5b66\u8fd0\u7b97\u3002<\/p>\n<h3>\u57fa\u672c\u7b97\u672f\u8fd0\u7b97\u7b26<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u540d\u79f0<\/th>\n<th>\u793a\u4f8b<\/th>\n<th>\u7ed3\u679c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>+<\/code><\/td>\n<td>\u52a0\u6cd5<\/td>\n<td><code>5 + 3<\/code><\/td>\n<td><code>8<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>-<\/code><\/td>\n<td>\u51cf\u6cd5<\/td>\n<td><code>10 - 4<\/code><\/td>\n<td><code>6<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>*<\/code><\/td>\n<td>\u4e58\u6cd5<\/td>\n<td><code>6 * 7<\/code><\/td>\n<td><code>42<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>\/<\/code><\/td>\n<td>\u9664\u6cd5<\/td>\n<td><code>15 \/ 3<\/code><\/td>\n<td><code>5<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>%<\/code><\/td>\n<td>\u53d6\u6a21\uff08\u4f59\u6570\uff09<\/td>\n<td><code>10 % 3<\/code><\/td>\n<td><code>1<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u793a\u4f8b\u4ee3\u7801<\/h3>\n<pre><code class=\"language-powershell\"># \u57fa\u672c\u7b97\u672f\u8fd0\u7b97\n$a = 10\n$b = 3\n\n$sum = $a + $b          # 13\n$difference = $a - $b   # 7\n$product = $a * $b      # 30\n$quotient = $a \/ $b     # 3.3333...\n$remainder = $a % $b    # 1\n\nWrite-Host &quot;\u52a0\u6cd5: $sum&quot;\nWrite-Host &quot;\u51cf\u6cd5: $difference&quot;\nWrite-Host &quot;\u4e58\u6cd5: $product&quot;\nWrite-Host &quot;\u9664\u6cd5: $quotient&quot;\nWrite-Host &quot;\u4f59\u6570: $remainder&quot;\n<\/code><\/pre>\n<h3>\u5b9e\u9645\u5e94\u7528\uff1a\u8ba1\u7b97\u8d2d\u7269\u603b\u4ef7<\/h3>\n<pre><code class=\"language-powershell\"># \u573a\u666f\uff1a\u8ba1\u7b97\u8d2d\u7269\u603b\u4ef7\n$price = 59.9\n$quantity = 3\n$taxRate = 0.08\n\n# \u8ba1\u7b97\u5c0f\u8ba1\n$subtotal = $price * $quantity\n\n# \u8ba1\u7b97\u7a0e\u989d\n$tax = $subtotal * $taxRate\n\n# \u8ba1\u7b97\u603b\u4ef7\n$total = $subtotal + $tax\n\nWrite-Host &quot;\u5546\u54c1\u5355\u4ef7: \uffe5$price&quot;\nWrite-Host &quot;\u8d2d\u4e70\u6570\u91cf: $quantity&quot;\nWrite-Host &quot;\u5c0f\u8ba1: \uffe5$subtotal&quot;\nWrite-Host &quot;\u7a0e\u989d: \uffe5$tax&quot;\nWrite-Host &quot;\u603b\u4ef7: \uffe5$total&quot;\n<\/code><\/pre>\n<hr>\n<h2>\ud83d\udcdd \u8d4b\u503c\u8fd0\u7b97\u7b26<\/h2>\n<p>\u8d4b\u503c\u8fd0\u7b97\u7b26\u7528\u4e8e\u7ed9\u53d8\u91cf\u8d4b\u503c\u3002<\/p>\n<h3>\u5e38\u7528\u8d4b\u503c\u8fd0\u7b97\u7b26<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u540d\u79f0<\/th>\n<th>\u793a\u4f8b<\/th>\n<th>\u7b49\u4ef7\u4e8e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>=<\/code><\/td>\n<td>\u7b80\u5355\u8d4b\u503c<\/td>\n<td><code>$a = 5<\/code><\/td>\n<td>&#8211;<\/td>\n<\/tr>\n<tr>\n<td><code>+=<\/code><\/td>\n<td>\u52a0\u5e76\u8d4b\u503c<\/td>\n<td><code>$a += 3<\/code><\/td>\n<td><code>$a = $a + 3<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>-=<\/code><\/td>\n<td>\u51cf\u5e76\u8d4b\u503c<\/td>\n<td><code>$a -= 2<\/code><\/td>\n<td><code>$a = $a - 2<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>*=<\/code><\/td>\n<td>\u4e58\u5e76\u8d4b\u503c<\/td>\n<td><code>$a *= 4<\/code><\/td>\n<td><code>$a = $a * 4<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>\/=<\/code><\/td>\n<td>\u9664\u5e76\u8d4b\u503c<\/td>\n<td><code>$a \/= 2<\/code><\/td>\n<td><code>$a = $a \/ 2<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>%=<\/code><\/td>\n<td>\u53d6\u6a21\u5e76\u8d4b\u503c<\/td>\n<td><code>$a %= 3<\/code><\/td>\n<td><code>$a = $a % 3<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u793a\u4f8b\u4ee3\u7801<\/h3>\n<pre><code class=\"language-powershell\"># \u57fa\u672c\u8d4b\u503c\n$count = 0\nWrite-Host &quot;\u521d\u59cb\u503c: $count&quot;  # 0\n\n# \u52a0\u5e76\u8d4b\u503c\n$count += 5\nWrite-Host &quot;\u52a05\u540e: $count&quot;   # 5\n\n# \u51cf\u5e76\u8d4b\u503c\n$count -= 2\nWrite-Host &quot;\u51cf2\u540e: $count&quot;   # 3\n\n# \u4e58\u5e76\u8d4b\u503c\n$count *= 4\nWrite-Host &quot;\u4e584\u540e: $count&quot;   # 12\n\n# \u9664\u5e76\u8d4b\u503c\n$count \/= 3\nWrite-Host &quot;\u9664\u4ee53\u540e: $count&quot; # 4\n<\/code><\/pre>\n<h3>\u5b9e\u9645\u5e94\u7528\uff1a\u8ba1\u6570\u5668<\/h3>\n<pre><code class=\"language-powershell\"># \u573a\u666f\uff1a\u7edf\u8ba1\u6587\u4ef6\u6570\u91cf\n$fileCount = 0\n\n# \u6a21\u62df\u5904\u7406\u591a\u4e2a\u6587\u4ef6\n$files = @(&quot;doc1.txt&quot;, &quot;doc2.txt&quot;, &quot;doc3.txt&quot;, &quot;doc4.txt&quot;)\n\nforeach ($file in $files) {\n    Write-Host &quot;\u5904\u7406\u6587\u4ef6: $file&quot;\n    $fileCount += 1  # \u6bcf\u5904\u7406\u4e00\u4e2a\u6587\u4ef6\uff0c\u8ba1\u6570\u5668\u52a01\n}\n\nWrite-Host &quot;`n\u603b\u5171\u5904\u7406\u4e86 $fileCount \u4e2a\u6587\u4ef6&quot;\n<\/code><\/pre>\n<hr>\n<h2>\ud83d\udcdd \u6bd4\u8f83\u8fd0\u7b97\u7b26<\/h2>\n<p>\u6bd4\u8f83\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u4e24\u4e2a\u503c\uff0c\u8fd4\u56de <code>True<\/code> \u6216 <code>False<\/code>\u3002<\/p>\n<h3>PowerShell \u7279\u6b8a\u8bed\u6cd5<\/h3>\n<p>\u26a0\ufe0f <strong>\u91cd\u8981<\/strong>\uff1aPowerShell \u7684\u6bd4\u8f83\u8fd0\u7b97\u7b26\u4e0d\u662f\u4f20\u7edf\u7684\u7b26\u53f7\uff08\u5982 <code>==<\/code>, <code>&gt;<\/code>, <code>&lt;<\/code>\uff09\uff0c\u800c\u662f\u5b57\u6bcd\u7ec4\u5408\uff01<\/p>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u540d\u79f0<\/th>\n<th>\u793a\u4f8b<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>-eq<\/code><\/td>\n<td>\u7b49\u4e8e<\/td>\n<td><code>5 -eq 5<\/code><\/td>\n<td>\u7b49\u4e8e\u8fd4\u56de True<\/td>\n<\/tr>\n<tr>\n<td><code>-ne<\/code><\/td>\n<td>\u4e0d\u7b49\u4e8e<\/td>\n<td><code>5 -ne 3<\/code><\/td>\n<td>\u4e0d\u7b49\u4e8e\u8fd4\u56de True<\/td>\n<\/tr>\n<tr>\n<td><code>-gt<\/code><\/td>\n<td>\u5927\u4e8e<\/td>\n<td><code>10 -gt 5<\/code><\/td>\n<td>\u5927\u4e8e\u8fd4\u56de True<\/td>\n<\/tr>\n<tr>\n<td><code>-ge<\/code><\/td>\n<td>\u5927\u4e8e\u7b49\u4e8e<\/td>\n<td><code>10 -ge 10<\/code><\/td>\n<td>\u5927\u4e8e\u7b49\u4e8e\u8fd4\u56de True<\/td>\n<\/tr>\n<tr>\n<td><code>-lt<\/code><\/td>\n<td>\u5c0f\u4e8e<\/td>\n<td><code>3 -lt 5<\/code><\/td>\n<td>\u5c0f\u4e8e\u8fd4\u56de True<\/td>\n<\/tr>\n<tr>\n<td><code>-le<\/code><\/td>\n<td>\u5c0f\u4e8e\u7b49\u4e8e<\/td>\n<td><code>3 -le 3<\/code><\/td>\n<td>\u5c0f\u4e8e\u7b49\u4e8e\u8fd4\u56de True<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u7248\u672c<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>-ieq<\/code>, -ine<code>, <\/code>-igt<code>, <\/code>-ige<code>, <\/code>-ilt<code>, <\/code>-ile`<\/td>\n<td>\u663e\u5f0f\u5927\u5c0f\u5199\u4e0d\u654f\u611f\uff08\u9ed8\u8ba4\uff09<\/td>\n<\/tr>\n<tr>\n<td><code>-ceq<\/code>, <code>-cne<\/code>, <code>-cgt<\/code>, <code>-cge<\/code>, <code>-clt<\/code>, <code>-cle<\/code><\/td>\n<td>\u5927\u5c0f\u5199\u654f\u611f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u793a\u4f8b\u4ee3\u7801<\/h3>\n<pre><code class=\"language-powershell\"># \u6570\u503c\u6bd4\u8f83\n$age = 25\n\n$isAdult = $age -ge 18\nWrite-Host &quot;\u662f\u5426\u6210\u5e74: $isAdult&quot;  # True\n\n$isSenior = $age -ge 60\nWrite-Host &quot;\u662f\u5426\u8001\u5e74: $isSenior&quot; # False\n\n# \u5b57\u7b26\u4e32\u6bd4\u8f83\uff08\u9ed8\u8ba4\u5927\u5c0f\u5199\u4e0d\u654f\u611f\uff09\n$name1 = &quot;PowerShell&quot;\n$name2 = &quot;powershell&quot;\n\n$isSame = $name1 -eq $name2\nWrite-Host &quot;\u540d\u79f0\u76f8\u540c: $isSame&quot;  # True\uff08\u56e0\u4e3a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff09\n\n# \u5b57\u7b26\u4e32\u6bd4\u8f83\uff08\u5927\u5c0f\u5199\u654f\u611f\uff09\n$isSameCase = $name1 -ceq $name2\nWrite-Host &quot;\u540d\u79f0\u5b8c\u5168\u76f8\u540c: $isSameCase&quot;  # False\uff08\u533a\u5206\u5927\u5c0f\u5199\uff09\n<\/code><\/pre>\n<h3>\u5b9e\u9645\u5e94\u7528\uff1a\u6210\u7ee9\u5224\u65ad<\/h3>\n<pre><code class=\"language-powershell\"># \u573a\u666f\uff1a\u5224\u65ad\u6210\u7ee9\u7b49\u7ea7\n$score = 85\n\nif ($score -ge 90) {\n    Write-Host &quot;\u4f18\u79c0&quot;\n} elseif ($score -ge 80) {\n    Write-Host &quot;\u826f\u597d&quot;\n} elseif ($score -ge 60) {\n    Write-Host &quot;\u53ca\u683c&quot;\n} else {\n    Write-Host &quot;\u4e0d\u53ca\u683c&quot;\n}\n# \u8f93\u51fa: \u826f\u597d\n<\/code><\/pre>\n<hr>\n<h2>\ud83d\udcdd \u903b\u8f91\u8fd0\u7b97\u7b26<\/h2>\n<p>\u903b\u8f91\u8fd0\u7b97\u7b26\u7528\u4e8e\u7ec4\u5408\u591a\u4e2a\u6761\u4ef6\uff0c\u8fd4\u56de <code>True<\/code> \u6216 <code>False<\/code>\u3002<\/p>\n<h3>\u57fa\u672c\u903b\u8f91\u8fd0\u7b97\u7b26<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u540d\u79f0<\/th>\n<th>\u8bf4\u660e<\/th>\n<th>\u793a\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>-and<\/code><\/td>\n<td>\u4e0e<\/td>\n<td>\u4e24\u4e2a\u6761\u4ef6\u90fd\u4e3a True \u65f6\u8fd4\u56de True<\/td>\n<td><code>$age -ge 18 -and $hasLicense<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>-or<\/code><\/td>\n<td>\u6216<\/td>\n<td>\u4e24\u4e2a\u6761\u4ef6\u4efb\u4e00\u4e3a True \u65f6\u8fd4\u56de True<\/td>\n<td><code>$isStudent -or $isSenior<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>-xor<\/code><\/td>\n<td>\u5f02\u6216<\/td>\n<td>\u4e24\u4e2a\u6761\u4ef6\u6709\u4e14\u4ec5\u6709\u4e00\u4e2a\u4e3a True \u65f6\u8fd4\u56de True<\/td>\n<td><code>$a -xor $b<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>-not<\/code><\/td>\n<td>\u975e<\/td>\n<td>\u53d6\u53cd<\/td>\n<td><code>-not ($isReady)<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>!<\/code><\/td>\n<td>\u975e<\/td>\n<td><code>-not<\/code> \u7684\u7b80\u5199<\/td>\n<td><code>! $isReady<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u903b\u8f91\u8fd0\u7b97\u7b26\u771f\u503c\u8868<\/h3>\n<table>\n<thead>\n<tr>\n<th>A<\/th>\n<th>B<\/th>\n<th>A -and B<\/th>\n<th>A -or B<\/th>\n<th>A -xor B<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>True<\/td>\n<td>True<\/td>\n<td>True<\/td>\n<td>True<\/td>\n<td>False<\/td>\n<\/tr>\n<tr>\n<td>True<\/td>\n<td>False<\/td>\n<td>False<\/td>\n<td>True<\/td>\n<td>True<\/td>\n<\/tr>\n<tr>\n<td>False<\/td>\n<td>True<\/td>\n<td>False<\/td>\n<td>True<\/td>\n<td>True<\/td>\n<\/tr>\n<tr>\n<td>False<\/td>\n<td>False<\/td>\n<td>False<\/td>\n<td>False<\/td>\n<td>False<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u793a\u4f8b\u4ee3\u7801<\/h3>\n<pre><code class=\"language-powershell\"># -and \u8fd0\u7b97\u7b26\uff1a\u4e24\u4e2a\u6761\u4ef6\u90fd\u5fc5\u987b\u4e3a\u771f\n$age = 25\n$hasLicense = $true\n\n$canDrive = ($age -ge 18) -and $hasLicense\nWrite-Host &quot;\u53ef\u4ee5\u5f00\u8f66: $canDrive&quot;  # True\n\n# -or \u8fd0\u7b97\u7b26\uff1a\u81f3\u5c11\u4e00\u4e2a\u6761\u4ef6\u4e3a\u771f\n$isStudent = $false\n$isSenior = $true\n\n$hasDiscount = $isStudent -or $isSenior\nWrite-Host &quot;\u6709\u6298\u6263: $hasDiscount&quot;  # True\n\n# -not \u8fd0\u7b97\u7b26\uff1a\u53d6\u53cd\n$isReady = $false\n$isNotReady = -not $isReady\nWrite-Host &quot;\u672a\u51c6\u5907\u597d: $isNotReady&quot;  # True\n<\/code><\/pre>\n<h3>\u5b9e\u9645\u5e94\u7528\uff1a\u767b\u5f55\u9a8c\u8bc1<\/h3>\n<pre><code class=\"language-powershell\"># \u573a\u666f\uff1a\u7528\u6237\u767b\u5f55\u9a8c\u8bc1\n$username = &quot;admin&quot;\n$password = &quot;secret123&quot;\n$isActive = $true\n$isLocked = $false\n\n# \u9a8c\u8bc1\u6761\u4ef6\uff1a\u7528\u6237\u540d\u6b63\u786e \u4e14 \u5bc6\u7801\u6b63\u786e \u4e14 \u8d26\u6237\u6fc0\u6d3b \u4e14 \u672a\u9501\u5b9a\n$isValid = ($username -eq &quot;admin&quot;) -and `\n           ($password -eq &quot;secret123&quot;) -and `\n           $isActive -and `\n           (-not $isLocked)\n\nif ($isValid) {\n    Write-Host &quot;\u767b\u5f55\u6210\u529f\uff01&quot;\n} else {\n    Write-Host &quot;\u767b\u5f55\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002&quot;\n}\n<\/code><\/pre>\n<h3>\u5b9e\u9645\u5e94\u7528\uff1a\u6587\u4ef6\u7b5b\u9009<\/h3>\n<pre><code class=\"language-powershell\"># \u573a\u666f\uff1a\u67e5\u627e\u5927\u6587\u4ef6\u4e14\u6700\u8fd1\u4fee\u6539\u8fc7\u7684\u6587\u4ef6\n$files = Get-ChildItem &quot;C:\\Logs&quot;\n\nforeach ($file in $files) {\n    # \u7b5b\u9009\u6761\u4ef6\uff1a\u5927\u4e8e1MB \u4e14 \u57287\u5929\u5185\u4fee\u6539\u8fc7\n    if (($file.Length -gt 1MB) -and ($file.LastWriteTime -gt (Get-Date).AddDays(-7))) {\n        Write-Host &quot;\u53d1\u73b0\u5927\u6587\u4ef6: $($file.Name) - \u5927\u5c0f: $([math]::Round($file.Length \/ 1MB, 2)) MB&quot;\n    }\n}\n<\/code><\/pre>\n<hr>\n<h2>\ud83d\udcdd \u5b57\u7b26\u4e32\u8fd0\u7b97\u7b26<\/h2>\n<p>\u5b57\u7b26\u4e32\u8fd0\u7b97\u7b26\u7528\u4e8e\u5b57\u7b26\u4e32\u7684\u6bd4\u8f83\u548c\u64cd\u4f5c\u3002<\/p>\n<h3>\u5b57\u7b26\u4e32\u6bd4\u8f83\u8fd0\u7b97\u7b26<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u540d\u79f0<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>-eq<\/code>, <code>-ne<\/code>, <code>-gt<\/code>, <code>-ge<\/code>, <code>-lt<\/code>, <code>-le<\/code><\/td>\n<td>\u6bd4\u8f83<\/td>\n<td>\u6309\u5b57\u6bcd\u987a\u5e8f\u6bd4\u8f83<\/td>\n<\/tr>\n<tr>\n<td><code>-like<\/code>, <code>-notlike<\/code><\/td>\n<td>\u901a\u914d\u7b26\u5339\u914d<\/td>\n<td>\u652f\u6301\u901a\u914d\u7b26 <code>*<\/code>, <code>?<\/code>, <code>[]<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>-match<\/code>, <code>-notmatch<\/code><\/td>\n<td>\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d<\/td>\n<td>\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u5b57\u7b26\u4e32\u8fde\u63a5\u8fd0\u7b97\u7b26<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u540d\u79f0<\/th>\n<th>\u793a\u4f8b<\/th>\n<th>\u7ed3\u679c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>+<\/code><\/td>\n<td>\u8fde\u63a5<\/td>\n<td><code>&quot;Hello&quot; + &quot; &quot; + &quot;World&quot;<\/code><\/td>\n<td><code>&quot;Hello World&quot;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>*<\/code><\/td>\n<td>\u91cd\u590d<\/td>\n<td><code>&quot;A&quot; * 5<\/code><\/td>\n<td><code>&quot;AAAAA&quot;<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u793a\u4f8b\u4ee3\u7801<\/h3>\n<pre><code class=\"language-powershell\"># \u5b57\u7b26\u4e32\u8fde\u63a5\n$firstName = &quot;\u5f20&quot;\n$lastName = &quot;\u4e09&quot;\n$fullName = $firstName + $lastName\nWrite-Host &quot;\u59d3\u540d: $fullName&quot;  # \u5f20\u4e09\n\n# \u5b57\u7b26\u4e32\u91cd\u590d\n$separator = &quot;-&quot; * 20\nWrite-Host $separator  # --------------------\n\n# \u901a\u914d\u7b26\u5339\u914d\n$filename = &quot;report2024.xlsx&quot;\n$isExcelFile = $filename -like &quot;*.xlsx&quot;\nWrite-Host &quot;\u662fExcel\u6587\u4ef6: $isExcelFile&quot;  # True\n\n# \u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\n$email = &quot;user@example.com&quot;\n$isValidEmail = $email -match &quot;^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$&quot;\nWrite-Host &quot;\u6709\u6548\u90ae\u7bb1: $isValidEmail&quot;  # True\n<\/code><\/pre>\n<h3>\u5b9e\u9645\u5e94\u7528\uff1a\u6587\u4ef6\u7b5b\u9009<\/h3>\n<pre><code class=\"language-powershell\"># \u573a\u666f\uff1a\u7b5b\u9009\u7279\u5b9a\u7c7b\u578b\u7684\u6587\u4ef6\n$files = @(&quot;report.docx&quot;, &quot;data.xlsx&quot;, &quot;image.jpg&quot;, &quot;backup.zip&quot;, &quot;summary.docx&quot;)\n\nforeach ($file in $files) {\n    # \u7b5b\u9009 Word \u6587\u6863\n    if ($file -like &quot;*.docx&quot;) {\n        Write-Host &quot;Word\u6587\u6863: $file&quot;\n    }\n}\n\n# \u8f93\u51fa:\n# Word\u6587\u6863: report.docx\n# Word\u6587\u6863: summary.docx\n<\/code><\/pre>\n<h3>\u5b9e\u9645\u5e94\u7528\uff1a\u6570\u636e\u9a8c\u8bc1<\/h3>\n<pre><code class=\"language-powershell\"># \u573a\u666f\uff1a\u9a8c\u8bc1\u8f93\u5165\u6570\u636e\u683c\u5f0f\n$phone = &quot;13812345678&quot;\n\n# \u9a8c\u8bc1\u624b\u673a\u53f7\u683c\u5f0f\uff0811\u4f4d\u6570\u5b57\uff09\n$isValidPhone = $phone -match &quot;^\\d{11}$&quot;\nif ($isValidPhone) {\n    Write-Host &quot;\u624b\u673a\u53f7\u683c\u5f0f\u6b63\u786e&quot;\n} else {\n    Write-Host &quot;\u624b\u673a\u53f7\u683c\u5f0f\u9519\u8bef&quot;\n}\n<\/code><\/pre>\n<hr>\n<h2>\ud83d\udcdd \u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7<\/h2>\n<p>\u5f53\u4e00\u4e2a\u8868\u8fbe\u5f0f\u4e2d\u5305\u542b\u591a\u4e2a\u8fd0\u7b97\u7b26\u65f6\uff0cPowerShell \u6309\u7167\u4f18\u5148\u7ea7\u987a\u5e8f\u6267\u884c\u3002<\/p>\n<h3>\u4f18\u5148\u7ea7\u4ece\u9ad8\u5230\u4f4e<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u4f18\u5148\u7ea7<\/th>\n<th>\u8fd0\u7b97\u7b26\u7c7b\u578b<\/th>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1\uff08\u6700\u9ad8\uff09<\/td>\n<td>\u62ec\u53f7<\/td>\n<td><code>()<\/code><\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>\u4e00\u5143\u8fd0\u7b97\u7b26<\/td>\n<td><code>-<\/code>, <code>+<\/code>, <code>--<\/code>, <code>++<\/code>, <code>!<\/code>, <code>-not<\/code><\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>\u4e58\u9664\u6a21<\/td>\n<td><code>*<\/code>, <code>\/<\/code>, <code>%<\/code><\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>\u52a0\u51cf<\/td>\n<td><code>+<\/code>, <code>-<\/code><\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>\u6bd4\u8f83\u8fd0\u7b97\u7b26<\/td>\n<td><code>-eq<\/code>, <code>-ne<\/code>, <code>-gt<\/code>, <code>-ge<\/code>, <code>-lt<\/code>, <code>-le<\/code><\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>\u903b\u8f91\u4e0e<\/td>\n<td><code>-and<\/code><\/td>\n<\/tr>\n<tr>\n<td>7\uff08\u6700\u4f4e\uff09<\/td>\n<td>\u903b\u8f91\u6216<\/td>\n<td><code>-or<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u793a\u4f8b\u4ee3\u7801<\/h3>\n<pre><code class=\"language-powershell\"># \u4f18\u5148\u7ea7\u793a\u4f8b\n$result1 = 2 + 3 * 4    # \u7ed3\u679c: 14\uff08\u5148\u4e58\u540e\u52a0\uff09\n$result2 = (2 + 3) * 4  # \u7ed3\u679c: 20\uff08\u62ec\u53f7\u4f18\u5148\uff09\n\nWrite-Host &quot;2 + 3 * 4 = $result1&quot;      # 14\nWrite-Host &quot;(2 + 3) * 4 = $result2&quot;    # 20\n\n# \u903b\u8f91\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\n$age = 25\n$isStudent = $true\n\n# -and \u4f18\u5148\u7ea7\u9ad8\u4e8e -or\n$result3 = $age -lt 18 -or $isStudent -and $age -lt 25\n# \u76f8\u5f53\u4e8e: $age -lt 18 -or ($isStudent -and $age -lt 25)\n# False -or (True -and False) = False\n\nWrite-Host &quot;\u7ed3\u679c: $result3&quot;  # False\n\n# \u4f7f\u7528\u62ec\u53f7\u660e\u786e\u4f18\u5148\u7ea7\n$result4 = ($age -lt 18 -or $isStudent) -and $age -lt 25\n# (False -or True) -and False = False\n\nWrite-Host &quot;\u7ed3\u679c: $result4&quot;  # False\n<\/code><\/pre>\n<h3>\u5efa\u8bae<\/h3>\n<p><strong>\u26a0\ufe0f \u91cd\u8981<\/strong>\uff1a\u5f53\u8868\u8fbe\u5f0f\u590d\u6742\u65f6\uff0c<strong>\u59cb\u7ec8\u4f7f\u7528\u62ec\u53f7<\/strong>\u660e\u786e\u4f18\u5148\u7ea7\uff0c\u5373\u4f7f\u9ed8\u8ba4\u987a\u5e8f\u6b63\u786e\u4e5f\u8981\u52a0\u62ec\u53f7\u3002\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\uff1a<\/p>\n<ul>\n<li>\u4ee3\u7801\u66f4\u6613\u8bfb<\/li>\n<li>\u907f\u514d\u6b67\u4e49<\/li>\n<li>\u9632\u6b62\u672a\u6765\u7ef4\u62a4\u65f6\u51fa\u9519<\/li>\n<\/ul>\n<pre><code class=\"language-powershell\"># \u63a8\u8350\uff1a\u4f7f\u7528\u62ec\u53f7\n$isValid = ($age -ge 18) -and ($hasLicense -eq $true)\n\n# \u4e0d\u63a8\u8350\uff1a\u4f9d\u8d56\u9ed8\u8ba4\u4f18\u5148\u7ea7\n$isValid = $age -ge 18 -and $hasLicense -eq $true\n<\/code><\/pre>\n<hr>\n<h2>\ud83c\udfae \u5b8c\u6574\u5b9e\u6218\u793a\u4f8b<\/h2>\n<h3>\u793a\u4f8b1\uff1a\u8ba1\u7b97\u5668\u811a\u672c<\/h3>\n<pre><code class=\"language-powershell\"># \u573a\u666f\uff1a\u7b80\u5355\u8ba1\u7b97\u5668\n\nWrite-Host &quot;=== PowerShell \u8ba1\u7b97\u5668 ===&quot; -ForegroundColor Cyan\nWrite-Host &quot;&quot;\n\n# \u83b7\u53d6\u7528\u6237\u8f93\u5165\n$num1 = Read-Host &quot;\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u6570\u5b57&quot;\n$operator = Read-Host &quot;\u8bf7\u8f93\u5165\u8fd0\u7b97\u7b26 (+, -, *, \/, %)&quot;\n$num2 = Read-Host &quot;\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u6570\u5b57&quot;\n\n# \u8f6c\u6362\u4e3a\u6570\u5b57\n$number1 = [double]$num1\n$number2 = [double]$num2\n\n# \u8ba1\u7b97\u7ed3\u679c\n$result = 0\n$isValid = $true\n\nswitch ($operator) {\n    &quot;+&quot; { $result = $number1 + $number2 }\n    &quot;-&quot; { $result = $number1 - $number2 }\n    &quot;*&quot; { $result = $number1 * $number2 }\n    &quot;\/&quot; {\n        if ($number2 -eq 0) {\n            Write-Host &quot;\u9519\u8bef\uff1a\u9664\u6570\u4e0d\u80fd\u4e3a\u96f6\uff01&quot; -ForegroundColor Red\n            $isValid = $false\n        } else {\n            $result = $number1 \/ $number2\n        }\n    }\n    &quot;%&quot; { $result = $number1 % $number2 }\n    default {\n        Write-Host &quot;\u9519\u8bef\uff1a\u4e0d\u652f\u6301\u7684\u8fd0\u7b97\u7b26\uff01&quot; -ForegroundColor Red\n        $isValid = $false\n    }\n}\n\n# \u663e\u793a\u7ed3\u679c\nif ($isValid) {\n    Write-Host &quot;&quot;\n    Write-Host &quot;\u8ba1\u7b97\u7ed3\u679c: $number1 $operator $number2 = $result&quot; -ForegroundColor Green\n}\n<\/code><\/pre>\n<h3>\u793a\u4f8b2\uff1a\u6e29\u5ea6\u8f6c\u6362\u5668<\/h3>\n<pre><code class=\"language-powershell\"># \u573a\u666f\uff1a\u6e29\u5ea6\u5355\u4f4d\u8f6c\u6362\uff08\u6444\u6c0f\u5ea6 \u2194 \u534e\u6c0f\u5ea6\uff09\n\nWrite-Host &quot;=== \u6e29\u5ea6\u8f6c\u6362\u5668 ===&quot; -ForegroundColor Cyan\nWrite-Host &quot;&quot;\n\n# \u83b7\u53d6\u7528\u6237\u8f93\u5165\n$temp = Read-Host &quot;\u8bf7\u8f93\u5165\u6e29\u5ea6\u503c&quot;\n$unit = Read-Host &quot;\u8bf7\u9009\u62e9\u5355\u4f4d (C=\u6444\u6c0f\u5ea6, F=\u534e\u6c0f\u5ea6)&quot;\n\n# \u8f6c\u6362\u4e3a\u6570\u5b57\n$temperature = [double]$temp\n\n# \u8f6c\u6362\u6e29\u5ea6\nif ($unit -eq &quot;C&quot; -or $unit -eq &quot;c&quot;) {\n    # \u6444\u6c0f\u5ea6\u8f6c\u534e\u6c0f\u5ea6\n    $fahrenheit = $temperature * 9 \/ 5 + 32\n    Write-Host &quot;$temperature\u00b0C = $fahrenheit\u00b0F&quot;\n} elseif ($unit -eq &quot;F&quot; -or $unit -eq &quot;f&quot;) {\n    # \u534e\u6c0f\u5ea6\u8f6c\u6444\u6c0f\u5ea6\n    $celsius = ($temperature - 32) * 5 \/ 9\n    Write-Host &quot;$temperature\u00b0F = $celsius\u00b0C&quot;\n} else {\n    Write-Host &quot;\u65e0\u6548\u7684\u5355\u4f4d\uff01&quot; -ForegroundColor Red\n}\n<\/code><\/pre>\n<h3>\u793a\u4f8b3\uff1a\u6210\u7ee9\u7edf\u8ba1\u7cfb\u7edf<\/h3>\n<pre><code class=\"language-powershell\"># \u573a\u666f\uff1a\u5b66\u751f\u6210\u7ee9\u7edf\u8ba1\n\nWrite-Host &quot;=== \u6210\u7ee9\u7edf\u8ba1\u7cfb\u7edf ===&quot; -ForegroundColor Cyan\nWrite-Host &quot;&quot;\n\n# \u83b7\u53d6\u5b66\u751f\u6210\u7ee9\n$chinese = [int](Read-Host &quot;\u8bed\u6587\u6210\u7ee9&quot;)\n$math = [int](Read-Host &quot;\u6570\u5b66\u6210\u7ee9&quot;)\n$english = [int](Read-Host &quot;\u82f1\u8bed\u6210\u7ee9&quot;)\n\n# \u8ba1\u7b97\u603b\u5206\u548c\u5e73\u5747\u5206\n$totalScore = $chinese + $math + $english\n$averageScore = $totalScore \/ 3\n\n# \u56db\u820d\u4e94\u5165\u5230\u4e24\u4f4d\u5c0f\u6570\n$averageScore = [math]::Round($averageScore, 2)\n\nWrite-Host &quot;&quot;\nWrite-Host &quot;=== \u6210\u7ee9\u5355 ===&quot; -ForegroundColor Green\nWrite-Host &quot;\u8bed\u6587: $chinese&quot;\nWrite-Host &quot;\u6570\u5b66: $math&quot;\nWrite-Host &quot;\u82f1\u8bed: $english&quot;\nWrite-Host &quot;\u603b\u5206: $totalScore&quot;\nWrite-Host &quot;\u5e73\u5747\u5206: $averageScore&quot;\nWrite-Host &quot;&quot;\n\n# \u5224\u65ad\u7b49\u7ea7\nif ($averageScore -ge 90) {\n    Write-Host &quot;\u7b49\u7ea7: \u4f18\u79c0&quot; -ForegroundColor Green\n} elseif ($averageScore -ge 80) {\n    Write-Host &quot;\u7b49\u7ea7: \u826f\u597d&quot; -ForegroundColor Cyan\n} elseif ($averageScore -ge 60) {\n    Write-Host &quot;\u7b49\u7ea7: \u53ca\u683c&quot; -ForegroundColor Yellow\n} else {\n    Write-Host &quot;\u7b49\u7ea7: \u4e0d\u53ca\u683c&quot; -ForegroundColor Red\n}\n\n# \u5224\u65ad\u662f\u5426\u6240\u6709\u79d1\u76ee\u90fd\u53ca\u683c\n$allPass = ($chinese -ge 60) -and ($math -ge 60) -and ($english -ge 60)\nif ($allPass) {\n    Write-Host &quot;\u606d\u559c\uff01\u6240\u6709\u79d1\u76ee\u90fd\u53ca\u683c\u4e86\uff01&quot; -ForegroundColor Green\n} else {\n    Write-Host &quot;\u6ce8\u610f\uff1a\u6709\u79d1\u76ee\u4e0d\u53ca\u683c\uff0c\u9700\u8981\u52aa\u529b\uff01&quot; -ForegroundColor Red\n}\n<\/code><\/pre>\n<hr>\n<h2>\u26a0\ufe0f \u91cd\u8981\u6ce8\u610f\u4e8b\u9879<\/h2>\n<h3>1. \u6bd4\u8f83\u8fd0\u7b97\u7b26\u7684\u7279\u6b8a\u8bed\u6cd5<\/h3>\n<p>\u26a0\ufe0f <strong>\u5e38\u89c1\u9519\u8bef<\/strong>\uff1a\u521d\u5b66\u8005\u5e38\u5199\u6210\u4f20\u7edf\u7b26\u53f7<\/p>\n<pre><code class=\"language-powershell\"># \u274c \u9519\u8bef\u5199\u6cd5\nif ($age == 18) { }    # \u9519\u8bef\uff01\nif ($age &gt; 18) { }     # \u9519\u8bef\uff01\n\n# \u2705 \u6b63\u786e\u5199\u6cd5\nif ($age -eq 18) { }   # \u6b63\u786e\nif ($age -gt 18) { }   # \u6b63\u786e\n<\/code><\/pre>\n<h3>2. \u5b57\u7b26\u4e32\u6bd4\u8f83\u9ed8\u8ba4\u4e0d\u533a\u5206\u5927\u5c0f\u5199<\/h3>\n<pre><code class=\"language-powershell\"># \u9ed8\u8ba4\u4e0d\u533a\u5206\u5927\u5c0f\u5199\n&quot;HELLO&quot; -eq &quot;hello&quot;  # \u8fd4\u56de True\n\n# \u5982\u9700\u533a\u5206\u5927\u5c0f\u5199\uff0c\u4f7f\u7528 -c \u524d\u7f00\n&quot;HELLO&quot; -ceq &quot;hello&quot;  # \u8fd4\u56de False\n<\/code><\/pre>\n<h3>3. \u9664\u6cd5\u8fd0\u7b97\u7684\u7ed3\u679c\u7c7b\u578b<\/h3>\n<pre><code class=\"language-powershell\"># \u6574\u6570\u9664\u6cd5\u53ef\u80fd\u8fd4\u56de\u5c0f\u6570\n$result = 10 \/ 3  # \u7ed3\u679c\u662f 3.3333...\uff0c\u4e0d\u662f\u6574\u6570\n\n# \u5982\u9700\u6574\u6570\u9664\u6cd5\uff0c\u4f7f\u7528 [int] \u8f6c\u6362\u6216\u53d6\u6574\u51fd\u6570\n$result = [int](10 \/ 3)  # 3\uff08\u622a\u65ad\uff09\n$result = [Math]::Floor(10 \/ 3)  # 3\uff08\u5411\u4e0b\u53d6\u6574\uff09\n$result = [Math]::Round(10 \/ 3)  # 3\uff08\u56db\u820d\u4e94\u5165\uff09\n<\/code><\/pre>\n<h3>4. \u903b\u8f91\u8fd0\u7b97\u7b26\u7684\u77ed\u8def\u7279\u6027<\/h3>\n<pre><code class=\"language-powershell\"># -and \u8fd0\u7b97\u7b26\uff1a\u7b2c\u4e00\u4e2a\u6761\u4ef6\u4e3a False\uff0c\u4e0d\u4f1a\u8ba1\u7b97\u7b2c\u4e8c\u4e2a\u6761\u4ef6\n$result = $false -and (1 \/ 0)  # \u4e0d\u4f1a\u62a5\u9519\uff0c\u56e0\u4e3a\u7b2c\u4e00\u4e2a\u6761\u4ef6\u4e3a False\n\n# -or \u8fd0\u7b97\u7b26\uff1a\u7b2c\u4e00\u4e2a\u6761\u4ef6\u4e3a True\uff0c\u4e0d\u4f1a\u8ba1\u7b97\u7b2c\u4e8c\u4e2a\u6761\u4ef6\n$result = $true -or (1 \/ 0)   # \u4e0d\u4f1a\u62a5\u9519\uff0c\u56e0\u4e3a\u7b2c\u4e00\u4e2a\u6761\u4ef6\u4e3a True\n<\/code><\/pre>\n<h3>5. \u8fd0\u7b97\u7b26\u4e24\u4fa7\u7a7a\u683c\u4e0d\u5f71\u54cd\u7ed3\u679c<\/h3>\n<pre><code class=\"language-powershell\"># \u4ee5\u4e0b\u5199\u6cd5\u90fd\u662f\u6b63\u786e\u7684\n$result = 5+3        # \u7d27\u51d1\n$result = 5 + 3      # \u63a8\u8350\uff1a\u6709\u7a7a\u683c\n$result = 5  +  3    # \u591a\u4e2a\u7a7a\u683c\uff08\u4e0d\u63a8\u8350\uff09\n<\/code><\/pre>\n<p><strong>\u5efa\u8bae<\/strong>\uff1a\u8fd0\u7b97\u7b26\u4e24\u4fa7\u52a0\u7a7a\u683c\uff0c\u63d0\u9ad8\u4ee3\u7801\u53ef\u8bfb\u6027\u3002<\/p>\n<hr>\n<h2>\u270d\ufe0f \u7ec3\u4e60\u4efb\u52a1<\/h2>\n<h3>\u57fa\u7840\u7ec3\u4e60<\/h3>\n<ol>\n<li>\n<p><strong>\u8ba1\u7b97\u7ec3\u4e60<\/strong><\/p>\n<ul>\n<li>\u521b\u5efa\u811a\u672c\uff0c\u8ba1\u7b97\u5706\u7684\u9762\u79ef\u548c\u5468\u957f\uff08\u7528\u6237\u8f93\u5165\u534a\u5f84\uff09<\/li>\n<li>\u63d0\u793a\uff1a\u9762\u79ef = \u03c0 \u00d7 r\u00b2\uff0c\u5468\u957f = 2 \u00d7 \u03c0 \u00d7 r<\/li>\n<li>\u03c0 \u7684\u503c\uff1a<code>[Math]::PI<\/code><\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u6bd4\u8f83\u7ec3\u4e60<\/strong><\/p>\n<ul>\n<li>\u8ba9\u7528\u6237\u8f93\u5165\u5e74\u9f84<\/li>\n<li>\u5224\u65ad\u5e76\u8f93\u51fa\uff1a\u672a\u6210\u5e74\uff08&lt;18\uff09\u3001\u6210\u5e74\uff0818-60\uff09\u3001\u8001\u5e74\uff08&gt;60\uff09<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u903b\u8f91\u7ec3\u4e60<\/strong><\/p>\n<ul>\n<li>\u5224\u65ad\u4e00\u4e2a\u5e74\u4efd\u662f\u5426\u4e3a\u95f0\u5e74<\/li>\n<li>\u95f0\u5e74\u89c4\u5219\uff1a\u80fd\u88ab4\u6574\u9664\u4f46\u4e0d\u80fd\u88ab100\u6574\u9664\uff0c\u6216\u8005\u80fd\u88ab400\u6574\u9664<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>\u8fdb\u9636\u7ec3\u4e60<\/h3>\n<ol start=\"4\">\n<li>\n<p><strong>\u7b80\u6613\u8d2d\u7269\u7cfb\u7edf<\/strong><\/p>\n<ul>\n<li>\u7528\u6237\u8f93\u5165\u5546\u54c1\u5355\u4ef7\u548c\u6570\u91cf<\/li>\n<li>\u6839\u636e\u6570\u91cf\u8ba1\u7b97\u6298\u6263\uff08\u226510\u4ef69\u6298\uff0c\u226550\u4ef68\u6298\uff09<\/li>\n<li>\u8ba1\u7b97\u5e76\u663e\u793a\u5c0f\u8ba1\u3001\u6298\u6263\u3001\u7a0e\u989d\uff088%\uff09\u3001\u603b\u4ef7<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u6587\u4ef6\u7ba1\u7406\u52a9\u624b<\/strong><\/p>\n<ul>\n<li>\u83b7\u53d6\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6<\/li>\n<li>\u7edf\u8ba1\u6587\u4ef6\u603b\u6570\u3001\u603b\u5927\u5c0f<\/li>\n<li>\u7b5b\u9009\u5e76\u663e\u793a\u5927\u4e8e\u6307\u5b9a\u5927\u5c0f\u7684\u6587\u4ef6<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u6210\u7ee9\u7b49\u7ea7\u5224\u5b9a<\/strong><\/p>\n<ul>\n<li>\u7528\u6237\u8f93\u5165\u4e09\u95e8\u8bfe\u6210\u7ee9<\/li>\n<li>\u8ba1\u7b97\u603b\u5206\u3001\u5e73\u5747\u5206\u3001\u7b49\u7ea7<\/li>\n<li>\u5224\u65ad\u662f\u5426\u6709\u4e0d\u53ca\u683c\u79d1\u76ee<\/li>\n<li>\u8f93\u51fa\u8be6\u7ec6\u7684\u6210\u7ee9\u62a5\u544a<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>\u5b9e\u6218\u6311\u6218<\/h3>\n<ol start=\"7\">\n<li>\n<p><strong>BMI \u8ba1\u7b97\u5668<\/strong><\/p>\n<ul>\n<li>\u7528\u6237\u8f93\u5165\u8eab\u9ad8\uff08\u7c73\uff09\u548c\u4f53\u91cd\uff08\u516c\u65a4\uff09<\/li>\n<li>\u8ba1\u7b97 BMI\uff1a\u4f53\u91cd \/ (\u8eab\u9ad8 \u00d7 \u8eab\u9ad8)<\/li>\n<li>\u5224\u65ad\u5065\u5eb7\u72b6\u6001\uff1a\n<ul>\n<li>BMI &lt; 18.5\uff1a\u504f\u7626<\/li>\n<li>18.5 \u2264 BMI &lt; 24\uff1a\u6b63\u5e38<\/li>\n<li>24 \u2264 BMI &lt; 28\uff1a\u8d85\u91cd<\/li>\n<li>BMI \u2265 28\uff1a\u80a5\u80d6<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5bc6\u7801\u5f3a\u5ea6\u68c0\u6d4b\u5668<\/strong><\/p>\n<ul>\n<li>\u7528\u6237\u8f93\u5165\u5bc6\u7801<\/li>\n<li>\u68c0\u6d4b\u5bc6\u7801\u5f3a\u5ea6\u5e76\u8fd4\u56de\u8bc4\u5206\uff1a\n<ul>\n<li>\u957f\u5ea6 \u2265 8\uff1a+10\u5206<\/li>\n<li>\u5305\u542b\u5927\u5199\u5b57\u6bcd\uff1a+20\u5206<\/li>\n<li>\u5305\u542b\u5c0f\u5199\u5b57\u6bcd\uff1a+10\u5206<\/li>\n<li>\u5305\u542b\u6570\u5b57\uff1a+20\u5206<\/li>\n<li>\u5305\u542b\u7279\u6b8a\u5b57\u7b26\uff1a+30\u5206<\/li>\n<li>\u603b\u5206 \u2265 60\uff1a\u5f31<\/li>\n<li>\u603b\u5206 \u2265 80\uff1a\u4e2d<\/li>\n<li>\u603b\u5206 \u2265 90\uff1a\u5f3a<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr>\n<h2>\ud83d\udca1 \u5e38\u89c1\u95ee\u9898 FAQ<\/h2>\n<h3>Q1: \u4e3a\u4ec0\u4e48 PowerShell \u7684\u6bd4\u8f83\u8fd0\u7b97\u7b26\u4e0d\u662f <code>==<\/code> \u800c\u662f <code>-eq<\/code>\uff1f<\/h3>\n<p><strong>A:<\/strong> \u8fd9\u662f PowerShell \u7684\u8bbe\u8ba1\u9009\u62e9\uff0c\u539f\u56e0\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u907f\u514d\u4e0e\u8d4b\u503c\u8fd0\u7b97\u7b26 <code>=<\/code> \u6df7\u6dc6<\/li>\n<li>\u7edf\u4e00\u7684\u8fd0\u7b97\u7b26\u547d\u540d\u89c4\u5219\uff08\u90fd\u4ee5 <code>-<\/code> \u5f00\u5934\uff09<\/li>\n<li>\u66f4\u6e05\u6670\u7684\u8bed\u6cd5\uff0c\u6613\u4e8e\u9605\u8bfb<\/li>\n<\/ul>\n<h3>Q2: <code>-eq<\/code> \u548c <code>-ceq<\/code> \u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/h3>\n<p><strong>A:<\/strong><\/p>\n<ul>\n<li><code>-eq<\/code>\uff1a\u5927\u5c0f\u5199\u4e0d\u654f\u611f\uff08\u9ed8\u8ba4\uff09\uff0c<code>&quot;A&quot; -eq &quot;a&quot;<\/code> \u8fd4\u56de True<\/li>\n<li><code>-ceq<\/code>\uff1a\u5927\u5c0f\u5199\u654f\u611f\uff0c<code>&quot;A&quot; -ceq &quot;a&quot;<\/code> \u8fd4\u56de False<\/li>\n<li>\u7c7b\u4f3c\u7684\uff0c<code>-gt<\/code>, <code>-lt<\/code> \u7b49\u90fd\u6709 <code>-c<\/code> \u524d\u7f00\u7248\u672c<\/li>\n<\/ul>\n<h3>Q3: \u5982\u4f55\u5224\u65ad\u4e00\u4e2a\u53d8\u91cf\u662f\u5426\u4e3a null\uff1f<\/h3>\n<p><strong>A:<\/strong> \u4f7f\u7528 <code>$null<\/code> \u6bd4\u8f83\uff1a<\/p>\n<pre><code class=\"language-powershell\">if ($value -eq $null) {\n    Write-Host &quot;\u53d8\u91cf\u4e3a\u7a7a&quot;\n}\n<\/code><\/pre>\n<h3>Q4: \u5b57\u7b26\u4e32\u8fde\u63a5\u7528 <code>+<\/code> \u8fd8\u662f\u53cc\u5f15\u53f7\u66f4\u9ad8\u6548\uff1f<\/h3>\n<p><strong>A:<\/strong><\/p>\n<ul>\n<li>\u5c11\u91cf\u8fde\u63a5\uff1a\u6027\u80fd\u5dee\u5f02\u4e0d\u5927\uff0c\u9009\u62e9\u66f4\u6613\u8bfb\u7684\u65b9\u5f0f<\/li>\n<li>\u5927\u91cf\u8fde\u63a5\uff1a\u5efa\u8bae\u4f7f\u7528 <code>StringBuilder<\/code> \u7c7b<\/li>\n<li>\u63a8\u8350\u4f7f\u7528\u53cc\u5f15\u53f7\u53d8\u91cf\u63d2\u503c\uff1a<code>&quot;$firstName $lastName&quot;<\/code><\/li>\n<\/ul>\n<h3>Q5: \u4e3a\u4ec0\u4e48 <code>1\/2<\/code> \u7684\u7ed3\u679c\u662f 0 \u800c\u4e0d\u662f 0.5\uff1f<\/h3>\n<p><strong>A:<\/strong> \u5728 PowerShell \u4e2d\uff0c\u6574\u6570\u76f8\u9664\u4f1a\u81ea\u52a8\u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\uff1a<\/p>\n<pre><code class=\"language-powershell\">$result = 1 \/ 2      # \u7ed3\u679c\u662f 0.5\n$result = 1.0 \/ 2    # \u7ed3\u679c\u4e5f\u662f 0.5\n<\/code><\/pre>\n<p>\u5982\u679c\u786e\u5b9e\u9700\u8981\u6574\u6570\u9664\u6cd5\uff0c\u4f7f\u7528 <code>[int]<\/code> \u8f6c\u6362\u6216\u53d6\u6574\u51fd\u6570\u3002<\/p>\n<hr>\n<h2>\ud83d\udcda \u62d3\u5c55\u9605\u8bfb<\/h2>\n<h3>\u63a8\u8350\u8d44\u6e90<\/h3>\n<ol>\n<li>\n<p><strong>\u5b98\u65b9\u6587\u6863<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.core\/about\/about_operators\">about_Operators<\/a><\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.core\/about\/about_comparison_operators\">about_Comparison_Operators<\/a><\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.core\/about\/about_logical_operators\">about_Logical_Operators<\/a><\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b66\u4e60\u5efa\u8bae<\/strong><\/p>\n<ul>\n<li>\u591a\u7ec3\u4e60\u8fd0\u7b97\u7b26\u7684\u7ec4\u5408\u4f7f\u7528<\/li>\n<li>\u6ce8\u610f\u6bd4\u8f83\u8fd0\u7b97\u7b26\u7684\u7279\u6b8a\u8bed\u6cd5<\/li>\n<li>\u719f\u7ec3\u638c\u63e1\u903b\u8f91\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7<\/li>\n<li>\u4f7f\u7528\u62ec\u53f7\u660e\u786e\u4f18\u5148\u7ea7<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4e0b\u4e00\u6b65\u5b66\u4e60<\/strong><\/p>\n<ul>\n<li>\u6761\u4ef6\u5224\u65ad\u8bed\u53e5\uff08if, elseif, else\uff09<\/li>\n<li>\u5faa\u73af\u7ed3\u6784\uff08for, foreach, while\uff09<\/li>\n<li>\u51fd\u6570\u7684\u5b9a\u4e49\u548c\u8c03\u7528<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr>\n<p><strong>\u606d\u559c\uff01\u4f60\u5df2\u7ecf\u638c\u63e1\u4e86 PowerShell \u7684\u8fd0\u7b97\u7b26\u4e0e\u8868\u8fbe\u5f0f\uff01<\/strong> \ud83c\udf89<\/p>\n<p>\u8fd9\u4e9b\u57fa\u7840\u77e5\u8bc6\u662f\u540e\u7eed\u5b66\u4e60\u7684\u57fa\u77f3\uff0c\u8bf7\u52a1\u5fc5\u591a\u52a0\u7ec3\u4e60\uff0c\u7075\u6d3b\u8fd0\u7528\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Day 4: \u8fd0\u7b97\u7b26\u4e0e\u8868\u8fbe\u5f0f \ud83c\udfaf \u5b66\u4e60\u76ee\u6807 \u7406\u89e3 PowerShell \u4e2d\u5404\u79cd\u8fd0\u7b97\u7b26\u7684\u4f5c\u7528\u548c\u7528\u6cd5 \u638c\u63e1\u7b97\u672f\u8fd0\u7b97 &#8230; <a title=\"Day-4-\u8fd0\u7b97\u7b26\u4e0e\u8868\u8fbe\u5f0f\" class=\"read-more\" href=\"https:\/\/www.resilence.cn\/?p=319\" aria-label=\"\u7ee7\u7eed\u9605\u8bfbDay-4-\u8fd0\u7b97\u7b26\u4e0e\u8868\u8fbe\u5f0f\">\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-319","post","type-post","status-publish","format-standard","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/posts\/319","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=319"}],"version-history":[{"count":1,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":320,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions\/320"}],"wp:attachment":[{"href":"https:\/\/www.resilence.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}