{"id":1044,"date":"2023-05-23T08:31:50","date_gmt":"2023-05-23T08:31:50","guid":{"rendered":"https:\/\/mustafauzun.co\/blog\/?p=1044"},"modified":"2023-05-23T08:31:50","modified_gmt":"2023-05-23T08:31:50","slug":"powershell-host-path-checker-script","status":"publish","type":"post","link":"https:\/\/mustafauzun.co\/blog\/powershell-host-path-checker-script\/","title":{"rendered":"Powershell, Host Path Checker Script"},"content":{"rendered":"\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-file=\"Checker.ps1\"><code>Write-Host &quot;[Path Checker]&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$websiteUrl = Read-Host -Prompt &#39;Input website url:&#39;\n$websiteProtocols = @(&quot;http&quot;, &quot;https&quot;)\n$websitePaths = @(\n                &quot;&quot;\n                &quot;api&quot;,\n                &quot;css&quot;,\n                &quot;users&quot;\n            )\nforeach($websiteProtocol in $websiteProtocols)\n{\n    foreach($websitePath in $websitePaths)\n    {\n    \n        $url = &quot;$($websiteProtocol+&quot;:\/\/&quot;+$websiteUrl+&quot;\/&quot;+$websitePath)&quot;\n        Write-Host $url -NoNewLine\n        Write-Host &quot; - &quot; -NoNewLine\n        try\n        {\n            $res = Invoke-WebRequest -URI $url -UseDefaultCredentials -UseBasicParsing -Method Head -TimeoutSec 5 -ErrorAction Stop\n\n            Write-Host $([int]$res.StatusCode) -NoNewLine\n            Write-Host &quot; - &quot; -NoNewLine\n            Write-Host $res.StatusDescription -BackgroundColor $informationTexts.Success.BackgroundColor\n        }\n        catch\n        {\n            Write-Host $([int]$_.Exception.Response.StatusCode.value__) -NoNewLine\n            Write-Host &quot; - &quot; -NoNewLine\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-1044","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\/1044","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=1044"}],"version-history":[{"count":1,"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/posts\/1044\/revisions"}],"predecessor-version":[{"id":1045,"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/posts\/1044\/revisions\/1045"}],"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=1044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/categories?post=1044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mustafauzun.co\/blog\/wp-json\/wp\/v2\/tags?post=1044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}