{"id":1038,"date":"2023-05-23T08:24:46","date_gmt":"2023-05-23T08:24:46","guid":{"rendered":"https:\/\/mustafauzun.co\/blog\/?p=1038"},"modified":"2023-05-23T08:24:46","modified_gmt":"2023-05-23T08:24:46","slug":"powershell-host-checker-script","status":"publish","type":"post","link":"https:\/\/mustafauzun.co\/blog\/powershell-host-checker-script\/","title":{"rendered":"Powershell, Host Checker Script"},"content":{"rendered":"\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-file=\"Checker.ps1\"><code>Write-Host &quot;[Host Check]&quot;\n\n$informationTexts = @{\n    Success = @{Text = &quot;Success&quot;; BackgroundColor = &quot;DarkGreen&quot;}\n    Error = @{Text = &quot;Error&quot;; BackgroundColor = &quot;DarkRed&quot;}\n}\n\n$tcpHosts = @(\n                @{ IP = &quot;google.com&quot;; port = 443 },\n                @{ IP = &quot;mustafauzun.co&quot;; port = 80 }\n            )\nforeach($tcpHost in $tcpHosts)\n{\n    $connect = Test-NetConnection -ComputerName $tcpHost.IP -InformationLevel &quot;Detailed&quot; -Port $tcpHost.port -WarningAction SilentlyContinue\n\n    Write-Host $tcpHost.IP : $tcpHost.port -NoNewLine\n    Write-Host &quot; - &quot; -NoNewLine\n    \n    if($connect.TcpTestSucceeded)\n    {\n        Write-Host $informationTexts.Success.Text -BackgroundColor $informationTexts.Success.BackgroundColor\n    }\n    else\n    {\n        Write-Host $informationTexts.Error.Text -BackgroundColor $informationTexts.Error.BackgroundColor\n    }\n\n}\npause<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":1034,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[68],"tags":[],"class_list":["post-1038","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/posts\/1038","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/comments?post=1038"}],"version-history":[{"count":1,"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/posts\/1038\/revisions"}],"predecessor-version":[{"id":1039,"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/posts\/1038\/revisions\/1039"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/media\/1034"}],"wp:attachment":[{"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/media?parent=1038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/categories?post=1038"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/tags?post=1038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}