{"id":619,"date":"2010-04-07T10:29:51","date_gmt":"2010-04-07T15:29:51","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/2010\/04\/hey-are-you-awake\/"},"modified":"2010-04-07T10:29:51","modified_gmt":"2010-04-07T15:29:51","slug":"hey-are-you-awake","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/","title":{"rendered":"Hey, are you awake?"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/Validated01.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; margin: 0px 5px 5px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"Validated01\" border=\"0\" alt=\"Validated01\" align=\"left\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/Validated01_thumb.png\" width=\"75\" height=\"77\" \/><\/a> As many of you know, one of the things I\u2019m doing these days is helping run <a title=\"Visit the site\" href=\"http:\/\/theexpertscommunity.com\/\" target=\"_blank\">The Experts Community<\/a> web site. As such I need to make sure it is up and running. I also like to make sure my blog and a few other sites are responding to HTTP requests. To meet this need I put together a PowerShell function to test a web site and determine if it is running or not.<\/p>\n<p> <!--more-->  <\/p>\n<p>There are no cmdlets from Microsoft for testing web site connectivity. However, there is a .NET class called System.Net.WebRequest. I put together a short 2.0 function that uses this class and returns a custom object to the pipeline.<\/p>\n<pre class=\"PowerShellColorizedScript\"><span style=\"color: #00008b\">Function<\/span> <span style=\"color: #8a2be2\">Test-WebSite<\/span> <span style=\"color: #000000\">{<\/span>            \n    <span style=\"color: #a9a9a9\">[<\/span><span style=\"color: #add8e6\">cmdletBinding<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #a9a9a9\">]<\/span>            \n    <span style=\"color: #00008b\">Param<\/span> <span style=\"color: #000000\">(<\/span>            \n          <span style=\"color: #a9a9a9\">[<\/span><span style=\"color: #add8e6\">Parameter<\/span><span style=\"color: #000000\">(<\/span>            \n           <span style=\"color: #000000\">ValueFromPipeline<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$True<\/span><span style=\"color: #a9a9a9\">,<\/span><span style=\"color: #000000\">Position<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #800080\">0<\/span><span style=\"color: #a9a9a9\">,<\/span><span style=\"color: #000000\">Mandatory<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$True<\/span><span style=\"color: #a9a9a9\">,<\/span>            \n           <span style=\"color: #000000\">HelpMessage<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #8b0000\">&quot;The URL to test. Include http:\/\/ or https:\/\/&quot;<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #a9a9a9\">]<\/span>            \n           <span style=\"color: #008080\">[string]<\/span><span style=\"color: #ff4500\">$url<\/span>            \n           <span style=\"color: #000000\">)<\/span>            \n            \n    <span style=\"color: #00008b\">Begin<\/span> <span style=\"color: #000000\">{<\/span>            \n        <span style=\"color: #0000ff\">Write-Verbose<\/span> <span style=\"color: #8b0000\">&quot;Begin function&quot;<\/span>            \n        <span style=\"color: #000000\">}<\/span>            \n    <span style=\"color: #00008b\">Process<\/span> <span style=\"color: #000000\">{<\/span>            \n        <span style=\"color: #0000ff\">Write-Verbose<\/span> <span style=\"color: #8b0000\">&quot;Requesting $url&quot;<\/span>            \n                    \n        <span style=\"color: #ff4500\">$wr<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #008080\">[system.net.webrequest]<\/span><span style=\"color: #a9a9a9\">::<\/span><span style=\"color: #000000\">Create<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #ff4500\">$url<\/span><span style=\"color: #000000\">)<\/span>                 \n        <span style=\"color: #006400\">#set timeout to 7 seconds<\/span>            \n        <span style=\"color: #ff4500\">$wr<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">Timeout<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #800080\">7000<\/span>            \n        <span style=\"color: #ff4500\">$start<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #0000ff\">Get-Date<\/span>            \n                    \n        <span style=\"color: #00008b\">Try<\/span> <span style=\"color: #000000\">{<\/span>            \n            <span style=\"color: #ff4500\">$response<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$wr<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">GetResponse<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #000000\">)<\/span>            \n            <span style=\"color: #00008b\">if<\/span> <span style=\"color: #000000\">(<\/span><span style=\"color: #ff4500\">$response<\/span><span style=\"color: #000000\">)<\/span> <span style=\"color: #000000\">{<\/span>            \n                 <span style=\"color: #0000ff\">Write-Verbose<\/span> <span style=\"color: #8b0000\">&quot;Response returned&quot;<\/span>            \n                <span style=\"color: #ff4500\">$Status<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$response<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">StatusCode<\/span>            \n                <span style=\"color: #ff4500\">$StatusCode<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #ff4500\">$response<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">Statuscode<\/span> <span style=\"color: #a9a9a9\">-as<\/span> <span style=\"color: #008080\">[int]<\/span><span style=\"color: #000000\">)<\/span>            \n            <span style=\"color: #000000\">}<\/span>            \n        <span style=\"color: #000000\">}<\/span>            \n        <span style=\"color: #00008b\">Catch<\/span>  <span style=\"color: #008080\">[system.net.webexception]<\/span> <span style=\"color: #000000\">{<\/span>            \n            <span style=\"color: #0000ff\">Write-Verbose<\/span> <span style=\"color: #8b0000\">&quot;Failed to get a response from $url&quot;<\/span>            \n            <span style=\"color: #0000ff\">Write-Warning<\/span> <span style=\"color: #8b0000\">&quot;Failed to get a response from $url&quot;<\/span>            \n            <span style=\"color: #ff4500\">$status<\/span> <span style=\"color: #a9a9a9\">=<\/span>  <span style=\"color: #ff4500\">$_<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">Exception<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">Response<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">StatusCode<\/span>            \n            <span style=\"color: #ff4500\">$statuscode<\/span> <span style=\"color: #a9a9a9\">=<\/span> <span style=\"color: #000000\">(<\/span> <span style=\"color: #ff4500\">$_<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">Exception<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">Response<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">StatusCode<\/span> <span style=\"color: #a9a9a9\">-as<\/span> <span style=\"color: #008080\">[int]<\/span><span style=\"color: #000000\">)<\/span>            \n        <span style=\"color: #000000\">}<\/span>            \n                    \n        <span style=\"color: #ff4500\">$end<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #0000ff\">Get-Date<\/span>            \n        <span style=\"color: #ff4500\">$timespan<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$end<\/span><span style=\"color: #a9a9a9\">-<\/span><span style=\"color: #ff4500\">$start<\/span>            \n        <span style=\"color: #ff4500\">$ResponseMS<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$timespan<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">TotalMilliseconds<\/span>            \n                          \n        <span style=\"color: #0000ff\">Write-Verbose<\/span> <span style=\"color: #8b0000\">&quot;status is $status&quot;<\/span>            \n        <span style=\"color: #0000ff\">Write-Verbose<\/span> <span style=\"color: #8b0000\">&quot;statuscode is $statuscode&quot;<\/span>            \n        <span style=\"color: #0000ff\">Write-Verbose<\/span> <span style=\"color: #8b0000\">&quot;timer is $responseMS&quot;<\/span>            \n                    \n        <span style=\"color: #ff4500\">$obj<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #0000ff\">New-Object<\/span> <span style=\"color: #8a2be2\">PSObject<\/span> <span style=\"color: #000080\">-Property<\/span> <span style=\"color: #000000\">@{<\/span>            \n            <span style=\"color: #000000\">DateTime<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$start<\/span>            \n            <span style=\"color: #000000\">URL<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$url<\/span>            \n            <span style=\"color: #000000\">Status<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$status<\/span>            \n            <span style=\"color: #000000\">StatusCode<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$statuscode<\/span>            \n            <span style=\"color: #000000\">ResponseMS<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$ResponseMS<\/span>            \n         <span style=\"color: #000000\">}<\/span>            \n         <span style=\"color: #0000ff\">Write-Output<\/span> <span style=\"color: #ff4500\">$obj<\/span>            \n                     \n      <span style=\"color: #000000\">}<\/span> <span style=\"color: #006400\">#end Process<\/span>            \n     <span style=\"color: #00008b\">End<\/span> <span style=\"color: #000000\">{<\/span>            \n        <span style=\"color: #0000ff\">Write-Verbose<\/span> <span style=\"color: #8b0000\">&quot;End function&quot;<\/span>            \n     <span style=\"color: #000000\">}<\/span>            \n<span style=\"color: #000000\">}<\/span> <span style=\"color: #006400\">#end function<\/span><\/pre>\n<p>The function takes a URL to test and it can be piped. Using a Try\/Catch construct the function attempts to get a response from the site. If it fails, then a System.Net.WebException object is caught so I can grab the status code (eg 404 or 500).<\/p>\n<p>The .NET class doesn\u2019t include a property to capture how long the response took, at least not that I can discover. So instead I simply get the time, attempt the request, get the time again and calculate the difference. Close enough for my needs. FInally, the function writes a custom object to the pipeline using <a title=\"get online help for this cmdlet\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113355\" target=\"_blank\">New-Object<\/a>.<\/p>\n<p>When the function is loaded you can run it like this:<\/p>\n<p><font color=\"#0000ff\" size=\"2\" face=\"Consolas\">PS C:\\&gt; test-website <\/font><a href=\"http:\/\/jdhitsolutions.com\/blog\"><font color=\"#0000ff\" size=\"2\" face=\"Consolas\">http:\/\/jdhitsolutions.com\/blog<\/font><\/a><\/p>\n<p><font color=\"#0000ff\" size=\"2\" face=\"Consolas\">ResponseMS : 253.0145<br \/>\n    <br \/>StatusCode : 200 <\/p>\n<p>Status&#160;&#160;&#160;&#160; : OK <\/p>\n<p>URL&#160;&#160;&#160;&#160;&#160;&#160;&#160; : <\/font><a href=\"http:\/\/jdhitsolutions.com\/blog\"><font color=\"#0000ff\" size=\"2\" face=\"Consolas\">http:\/\/jdhitsolutions.com\/blog<\/font><\/a> <\/p>\n<p><font color=\"#0000ff\" size=\"2\" face=\"Consolas\">DateTime&#160;&#160; : 4\/7\/2010 11:04:30 AM<\/font><\/p>\n<p>With this in place, I then turned to the notification process. Windows PowerShell 2.0 includes a cmdlet, <a title=\"get online help for Send-MailMessage\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=135256\" target=\"_blank\">Send-MailMessage<\/a>, which can deliver an SMTP message. My script runs through a list of URLs, saves the objects to a variable, which I then parse out to build a message string. Each URL has its own message which is temporary stored in an array. Then the array is converted to a string and used as the message body for my email notification.<\/p>\n<p><span style=\"color: #006400\">#build message string for email<\/span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/><span style=\"color: #ff4500\">$data<\/span> <span style=\"color: #a9a9a9\">|<\/span> <span style=\"color: #0000ff\">foreach<\/span> <span style=\"color: #000000\">{<\/span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/>&#160;&#160;&#160; <span style=\"color: #ff4500\">$m<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #8b0000\">&quot;{0} {1} {2} ({3}) {4} milliseconds&quot;<\/span> <span style=\"color: #a9a9a9\">-f<\/span> `<\/p>\n<pre class=\"PowerShellColorizedScript\">      <span style=\"color: #ff4500\">$_<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">DateTime<\/span><span style=\"color: #a9a9a9\">,<\/span><span style=\"color: #ff4500\">$_<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">url<\/span><span style=\"color: #a9a9a9\">,<\/span><span style=\"color: #ff4500\">$_<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">status<\/span><span style=\"color: #a9a9a9\">,<\/span><span style=\"color: #ff4500\">$_<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">StatusCode<\/span><span style=\"color: #a9a9a9\">,<\/span><span style=\"color: #ff4500\">$_<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">ResponseMS<\/span><span style=\"color: #000000\">)<\/span>            \n    <span style=\"color: #0000ff\">Write-Verbose<\/span> <span style=\"color: #8b0000\">&quot;Building message string&quot;<\/span>             \n    <span style=\"color: #0000ff\">Write-Verbose<\/span> <span style=\"color: #ff4500\">$m<\/span>             \n    <span style=\"color: #ff4500\">$msg<\/span><span style=\"color: #a9a9a9\">+=<\/span><span style=\"color: #ff4500\">$m<\/span>            \n<span style=\"color: #000000\">}<\/span>            \n            \n<span style=\"color: #006400\">#send mail response<\/span>            \n<span style=\"color: #0000ff\">Write-Verbose<\/span> <span style=\"color: #8b0000\">&quot;Sending mail message&quot;<\/span>            \n<span style=\"color: #0000ff\">Send-MailMessage<\/span> <span style=\"color: #000080\">-To<\/span> <span style=\"color: #ff4500\">$to<\/span> <span style=\"color: #000080\">-From<\/span> <span style=\"color: #ff4500\">$from<\/span> <span style=\"color: #000080\">-Subject<\/span> <span style=\"color: #ff4500\">$subject<\/span> <span style=\"color: #000000\">`\n<\/span><span style=\"color: #000080\">-Body<\/span> <span style=\"color: #000000\">$(<\/span><span style=\"color: #ff4500\">$msg<\/span> <span style=\"color: #a9a9a9\">|<\/span><span style=\"color: #0000ff\">out-string<\/span><span style=\"color: #000000\">)<\/span> <span style=\"color: #000080\">-SmtpServer<\/span> <span style=\"color: #ff4500\">$smtpServer<\/span> <span style=\"color: #000080\">-credential<\/span> <span style=\"color: #ff4500\">$mailcred<\/span>            <\/pre>\n<p>Depending on your SMTP server configuration you may or may not need to specify a credential. Your SMTP server may also need some minor reconfiguration depending on your network.<\/p>\n<p>The last step was to simply create a scheduled task to run my PowerShell script:<\/p>\n<p>powershell.exe -noprofile -noninteractive -file c:\\scripts\\ScheduledWebCheck.ps1<\/p>\n<p>Now I get an hourly report that lets me know the web site status, which thankfully is almost always up.<br \/>\n  <\/p>\n<div style=\"padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px\" id=\"scid:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:dd74dafc-3574-4059-87d9-9795fd93ff2e\" class=\"wlWriterEditableSmartContent\">\n<div><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/TestWeb.txt\" target=\"_blank\">Download Test-Web.ps1<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>As many of you know, one of the things I\u2019m doing these days is helping run The Experts Community web site. As such I need to make sure it is up and running. I also like to make sure my blog and a few other sites are responding to HTTP requests. To meet this need&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[75,8],"tags":[534,182,181,180],"class_list":["post-619","post","type-post","status-publish","format-standard","hentry","category-powershell-v2-0","category-scripting","tag-powershell","tag-send-mailmessage","tag-webexception","tag-webresponse"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Hey, are you awake? &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hey, are you awake? &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"As many of you know, one of the things I\u2019m doing these days is helping run The Experts Community web site. As such I need to make sure it is up and running. I also like to make sure my blog and a few other sites are responding to HTTP requests. To meet this need...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2010-04-07T15:29:51+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/Validated01_thumb.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Hey, are you awake?\",\"datePublished\":\"2010-04-07T15:29:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/\"},\"wordCount\":418,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2010\\\/04\\\/Validated01_thumb.png\",\"keywords\":[\"PowerShell\",\"Send-MailMessage\",\"WebException\",\"WebResponse\"],\"articleSection\":[\"PowerShell v2.0\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/\",\"name\":\"Hey, are you awake? &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2010\\\/04\\\/Validated01_thumb.png\",\"datePublished\":\"2010-04-07T15:29:51+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2010\\\/04\\\/Validated01_thumb.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2010\\\/04\\\/Validated01_thumb.png\",\"width\":\"75\",\"height\":\"77\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/619\\\/hey-are-you-awake\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell v2.0\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-v2-0\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hey, are you awake?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hey, are you awake? &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/","og_locale":"en_US","og_type":"article","og_title":"Hey, are you awake? &#8226; The Lonely Administrator","og_description":"As many of you know, one of the things I\u2019m doing these days is helping run The Experts Community web site. As such I need to make sure it is up and running. I also like to make sure my blog and a few other sites are responding to HTTP requests. To meet this need...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/","og_site_name":"The Lonely Administrator","article_published_time":"2010-04-07T15:29:51+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/Validated01_thumb.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Hey, are you awake?","datePublished":"2010-04-07T15:29:51+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/"},"wordCount":418,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/Validated01_thumb.png","keywords":["PowerShell","Send-MailMessage","WebException","WebResponse"],"articleSection":["PowerShell v2.0","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/","name":"Hey, are you awake? &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/Validated01_thumb.png","datePublished":"2010-04-07T15:29:51+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/Validated01_thumb.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/Validated01_thumb.png","width":"75","height":"77"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/619\/hey-are-you-awake\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell v2.0","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},{"@type":"ListItem","position":2,"name":"Hey, are you awake?"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":6439,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6439\/friday-fun-with-a-cross-platform-powershell-prompt\/","url_meta":{"origin":619,"position":0},"title":"Friday Fun with a Cross-Platform PowerShell Prompt","author":"Jeffery Hicks","date":"January 18, 2019","format":false,"excerpt":"This year is turning out to be all things cross-platform for me. Continuing this line of discussion I have something fun and simple today. A PowerShell prompt function that will work cross-platform and provide some meaningful information in what I think is a elegant manner. You may not need the\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-20.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-20.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-20.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-20.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":2935,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2935\/get-ciminstance-from-powershell-2-0\/","url_meta":{"origin":619,"position":1},"title":"Get CIMInstance from PowerShell 2.0","author":"Jeffery Hicks","date":"April 10, 2013","format":false,"excerpt":"I love the new CIM cmdlets in PowerShell 3.0. Querying WMI is a little faster because the CIM cmdlets query WMI using the WSMAN protocol instead of DCOM. The catch is that remote computers must be running PowerShell 3 which includes the latest version of the WSMAN protocol and the\u2026","rel":"","context":"In &quot;Powershell 3.0&quot;","block_context":{"text":"Powershell 3.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},"img":{"alt_text":"get-ciminstance-error","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/04\/get-ciminstance-error-300x145.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4380,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4380\/more-fun-getting-powershell-user-groups\/","url_meta":{"origin":619,"position":2},"title":"More Fun Getting PowerShell User Groups","author":"Jeffery Hicks","date":"April 14, 2015","format":false,"excerpt":"A few days ago I posted a PowerShell function to retrieve information about PowerShell user groups. That function returned basic group information like this. Each group on the site has its own page which is what that Link property is for. So it didn't take much work to use the\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3555,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3555\/get-powershell-version-with-wmi\/","url_meta":{"origin":619,"position":3},"title":"Get PowerShell Version with WMI","author":"Jeffery Hicks","date":"November 13, 2013","format":false,"excerpt":"With the release of PowerShell 4.0, it is possible you might end up with a mix of systems in your environment. I know I do because I do a lot of writing, testing and development that requires multiple versions in my test network. Recently I was doing some Group Policy\u2026","rel":"","context":"In &quot;Group Policy&quot;","block_context":{"text":"Group Policy","link":"https:\/\/jdhitsolutions.com\/blog\/category\/group-policy\/"},"img":{"alt_text":"get-wmipshell","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/get-wmipshell-1024x244.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/get-wmipshell-1024x244.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/get-wmipshell-1024x244.png?resize=525%2C300 1.5x"},"classes":[]},{"id":7112,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7112\/testing-for-powershell-in-windows-terminal\/","url_meta":{"origin":619,"position":4},"title":"Testing for PowerShell in Windows Terminal","author":"Jeffery Hicks","date":"December 20, 2019","format":false,"excerpt":"I have pretty much migrated to Windows Terminal as my primary PowerShell interface. Even though my daily session is PowerShell 7 I love that I can open up other sessions in the same application. yes, I know there are still limitations and that many of you prefer ConEmu. And that's\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/12\/image_thumb-30.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/12\/image_thumb-30.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/12\/image_thumb-30.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/12\/image_thumb-30.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":6082,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6082\/searching-for-a-cim-wmi-class-with-powershell\/","url_meta":{"origin":619,"position":5},"title":"Searching for a CIM\/WMI Class with PowerShell","author":"Jeffery Hicks","date":"September 18, 2018","format":false,"excerpt":"I got a question on Twitter about an older function I has posted to get antivirus information via WMI. The function continues to work fine with Windows 10, although there's always room for improvement. However, the question was that the function did not seem to work when querying a server\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/image_thumb.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/image_thumb.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/image_thumb.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/image_thumb.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/619","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=619"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/619\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}