{"id":343,"date":"2024-07-30T02:05:36","date_gmt":"2024-07-29T18:05:36","guid":{"rendered":"https:\/\/yuthk.com\/?p=343"},"modified":"2024-07-30T02:23:48","modified_gmt":"2024-07-29T18:23:48","slug":"powershell%e5%85%b3%e4%ba%8eping%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/yuthk.com\/?p=343","title":{"rendered":"powershell\u5173\u4e8eping\u6d4b\u8bd5"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u7b80\u4ecb<\/h2>\n\n\n\n<p>\u672c\u811a\u672c\u662f\u4e0a\u4e00\u7bc7\u535a\u6587\u7684\u529f\u80fd\u62d3\u5c55\uff0c\u4e3b\u8981\u529f\u80fd<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u89e3\u6790\u57df\u540dip<\/li>\n\n\n\n<li>\u5206\u522bping\u6240\u89e3\u6790\u5230\u7684ip<\/li>\n\n\n\n<li>\u81ea\u5b9a\u4e49ping\u6b21\u6570<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u90e8\u5206\u4ee3\u7801\u539f\u7406<\/h2>\n\n\n\n<p>\u4ec5\u4f7f\u7528 DNS \u89e3\u6790\u540d\u79f0\u3002 \u4e0d\u4f1a\u53d1\u51fa LLMNR \u548c NetBIOS \u67e5\u8be2\u3002<\/p>\n\n\n\n<p><code>Resolve-DnsName -Name pdc.chana.com -DnsOnly<\/code><\/p>\n\n\n\n<p>\u5339\u914dping\u8fd4\u56de\u7684\u7ed3\u679c<code>$pingPDCTextBox.Text<\/code>\u4e3a\u53ef\u81ea\u5b9a\u4e49ping\u6b21\u6570<\/p>\n\n\n\n<p><code>ping $ipArray[$i] -n $pingPDCTextBox.Text | Where-Object {$_ -match \"\u56de\u590d\" -or $_ -match \"Reply\" -or $_ -match \"\u8bf7\u6c42\u8d85\u65f6\" -or $_ -match \"Request timed out\" -or $_ -match \"\u65e0\u6cd5\u8bbf\u95ee\u76ee\u6807\u4e3b\u673a\" -or $_ -match \"Destination host unreachable\"}<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6e90\u7801<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># \u521b\u5efaping\u6b21\u6570\u8f93\u5165\u6846\n$pingPDCTextBox = New-Object System.Windows.Forms.TextBox\n$pingPDCTextBox.Location = New-Object System.Drawing.Point(250,500)\n$pingPDCTextBox.Multiline = $true\n$pingPDCTextBox.Size = New-Object System.Drawing.Size(30,30)\n$pingPDCTextBox.BackColor = '#93d5dc'\n$pingPDCTextBox.Font = New-Object System.Drawing.Font(\"Comic Sans MS\",12)\n#$SetNameTextBox.BackColor = &#91;System.Drawing.Color]::FromName(\"Transparent\")\n$Form.Controls.Add($pingPDCTextBox)\n$pingPDCTextBox.Text = \"1\"\n$pingPDC = $pingPDCTextBox.Text\n\n# \u521b\u5efaip\u68c0\u6d4b\u6309\u94ae\n$pingPDCButton = New-Object System.Windows.Forms.Button\n$pingPDCButton.Location = New-Object System.Drawing.Point(20,500)\n$pingPDCButton.Size = New-Object System.Drawing.Size(220,30)\n$pingPDCButton.Font = New-Object System.Drawing.Font(\n  \"\u5e7c\u5706\",11,&#91;System.Drawing.FontStyle]::Regular\n)\n$pingPDCButton.Text = \"PDC\u6d4b\u8bd5\"\n$Form.Controls.Add($pingPDCButton)\n$pingPDCButton.Add_Click({\n\t$ip = Resolve-DnsName -Name pdc.chana.com -DnsOnly\n    $ipArray = $ip.IPAddress\n    for (($i = 0); $i -lt $ipArray.Count; $i++)\n    {\n        $ouput = ping $ipArray&#91;$i] -n $pingPDCTextBox.Text | Where-Object {$_ -match \"\u56de\u590d\" -or $_ -match \"Reply\" -or $_ -match \"\u8bf7\u6c42\u8d85\u65f6\" -or $_ -match \"Request timed out\" -or $_ -match \"\u65e0\u6cd5\u8bbf\u95ee\u76ee\u6807\u4e3b\u673a\" -or $_ -match \"Destination host unreachable\"}\n        $tmp1 = $ipArray&#91;$i] +\": \" + \"`n        \" + $ouput\n        $tmp = $tmp + \"`n\" + $tmp1\n    }\n    $msgBoxInput =  &#91;System.Windows.MessageBox]::Show($tmp,\"ping\u7ed3\u679c\")\n})\n\n#\u8bbe\u7f6eping\u89e3\u91ca\u6309\u94ae&#91;?]\n$pingPDCinfoButton = New-Object System.Windows.Forms.Button\n$pingPDCinfoButton.Location = New-Object System.Drawing.Point(290,500)\n$pingPDCinfoButton.Size = New-Object System.Drawing.Size(30,30)\n$pingPDCinfoButton.Font = New-Object System.Drawing.Font(\n  \"\u5e7c\u5706\",11,&#91;System.Drawing.FontStyle]::Regular\n)\n$pingPDCinfoButton.Text = \"?\"\n$Form.Controls.Add($pingPDCinfoButton)\n$pingPDCinfoButton.Add_Click({\n    $msgBoxInput =  &#91;System.Windows.MessageBox]::Show('    \u70b9\u51fb &#91;PDC\u6d4b\u8bd5]\u4f1a\u81ea\u52a8\u4eceDNS\u89e3\u6790PDC\u6240\u6709IP\u5730\u5740\u5e76ping\u6d4b\u8bd5\n    \u53f3\u4fa7\u8f93\u5165\u6846\u53ef\u81ea\u5b9a\u4e49\u6d4b\u8bd5\u6b21\u6570\uff0c\u9ed8\u8ba4\u6d4b\u8bd51\u6b21', 'PDC\u8fde\u63a5\u6d4b\u8bd5 - &#91; INFO ]')\n    \n})<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u535a\u6587\u4e3a\u57fa\u4e8epowershell\u548c\u6279\u5904\u7406\u7f16\u5199\u7684\u8fd0\u7ef4\u5de5\u5177\u7684\u65b0\u589e\u529f\u80fd\uff0c\u4e3b\u8981\u662f\u6d4b\u8bd5\u516c\u53f8AD\u57df\u63a7\u670d\u52a1\u5668\u7684\u8fde\u63a5\u60c5\u51b5\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,4,5],"tags":[19],"class_list":["post-343","post","type-post","status-publish","format-standard","hentry","category-pwershell","category-4","category-5","tag-powershell"],"_links":{"self":[{"href":"https:\/\/yuthk.com\/index.php?rest_route=\/wp\/v2\/posts\/343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yuthk.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yuthk.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yuthk.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yuthk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=343"}],"version-history":[{"count":5,"href":"https:\/\/yuthk.com\/index.php?rest_route=\/wp\/v2\/posts\/343\/revisions"}],"predecessor-version":[{"id":355,"href":"https:\/\/yuthk.com\/index.php?rest_route=\/wp\/v2\/posts\/343\/revisions\/355"}],"wp:attachment":[{"href":"https:\/\/yuthk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yuthk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yuthk.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}