{"id":721,"date":"2014-03-17T16:15:09","date_gmt":"2014-03-17T20:15:09","guid":{"rendered":"http:\/\/www.bhargavs.com\/?p=721"},"modified":"2014-03-17T16:15:09","modified_gmt":"2014-03-17T20:15:09","slug":"ignoring-ssl-trust-in-powershell-using-system-net-webclient","status":"publish","type":"post","link":"https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/","title":{"rendered":"Ignoring SSL Trust in PowerShell using System.Net.WebClient"},"content":{"rendered":"<p>This article was originally posted on my PFE blog here: <a title=\"http:\/\/blogs.technet.com\/b\/bshukla\/archive\/2012\/08\/22\/3324650.aspx\" href=\"http:\/\/blogs.technet.com\/b\/bshukla\/archive\/2012\/08\/22\/3324650.aspx\">http:\/\/blogs.technet.com\/b\/bshukla\/archive\/2012\/08\/22\/3324650.aspx<\/a>.<\/p>\n<p>I noticed a few inaccuracies with the article and since I am not a PFE anymore, I can\u2019t edit original article but posting updated article here for everyone to benefit from.<\/p>\n<h3>The Problem<\/h3>\n<p>We all at one point or another have come across a coding issue where we are trying to connect to a website using a script and the website is secure with either self-signed or untrusted SSL certificate. This poses a challenge. A challenge to tell code to ignore the trust related issues and move forward with rest of the logic. The error you are presented with when certificate trust fails looks something like this:<\/p>\n<blockquote>\n<p>Exception calling &#8220;DownloadString&#8221; with &#8220;1&#8221; argument(s): &#8220;The underlying connection was closed: Could not establish trust relationship for the SSL\/TLS secure channel.&#8221;<\/p>\n<\/blockquote>\n<h3>The solution<\/h3>\n<p>When using PowerShell, the logic is relatively simple. Using .Net framework class libraries, you can <a href=\"http:\/\/msdn.microsoft.com\/en-us\/vstudio\/system.net.servicepointmanager.servercertificatevalidationcallback(v=vs.103).aspx\" target=\"_blank\" rel=\"noopener noreferrer\">set custom validation of server certificate by the client<\/a>. In plain english, you can override the certificate trust by telling code that you explicitly trust the certificate presented by the server. Here\u2019s what the one-liner looks like:<\/p>\n<blockquote>\n<p>[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}<\/p>\n<\/blockquote>\n<p>Once set, you can create web client object and proceed with your web client calls. Simplified example would look something like the following:<\/p>\n<blockquote>\n<p>$wc = New-Object System.Net.WebClient $src = $wc.downloadstring(<a href=\"https:\/\/server\/abc.htm\">https:\/\/server\/abc.htm<\/a>)<\/p>\n<p>$src = $wc.downloadstring(<a href=\"https:\/\/server\/abc.htm\">https:\/\/server\/abc.htm<\/a>)<\/p>\n<\/blockquote>\n<p>Note that this setting is per session setting and will be valid only for given session or PowerShell Window.<\/p>\n<h3>The Confusion Addressed<\/h3>\n<p>Now let\u2019s talk about the confusion from original post. After overriding certificate trust, I received malformed header error:<\/p>\n<blockquote>\n<p>Exception calling &#8220;DownloadString&#8221; with &#8220;1&#8221; argument(s): &#8220;The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF&#8221;<\/p>\n<\/blockquote>\n<p>It looked as if I hadn\u2019t resolved SSL trust error. However, if you pay close attention, you will notice that the issue is protocol violation. In this case a malformed header. Response header isn\u2019t presenting information as it should and is missing LF after presenting CR. And that\u2019s where most readers assumed, what followed was a solution to certificate errors when it actually was solution to address malformed headers issue.<\/p>\n<p>As I mentioned in my original article, you can address malformed headers issue in one of the two ways. You can use it on sources that you trust. I would be very carful using it against any website that you may not trust. Consider yourself warned.<\/p>\n<p>Here are two methods to address malformed headers:<\/p>\n<ol>\n<li>Create PowerShell.exe.config in $PSHOME location. Personally, I don\u2019t like this idea as adding following lines to the file means telling PowerShell to ignore such protocol violations forever. Not a good security measure. However, if you are curious, here\u2019s how your PowerShell.exe.config would look like (if you create a new one). it\u2019s the \u201cuseUnsafeHeaderParsing\u201d that is important to understand.<br \/>\n<blockquote>\n<p>&lt;!&#8211;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243; ?&#8211;&gt;<br \/>&lt;configuration&gt;<br \/>&nbsp;&nbsp; &lt;system.net&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;settings&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;httpwebrequest useunsafeheaderparsing=&#8221;true&#8221;&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/httpwebrequest&gt;&lt;\/settings&gt;<br \/>&lt;\/configuration&gt;<\/p>\n<\/blockquote>\n<\/li>\n<li>Since I didn\u2019t like the idea of leaving doors wide open, I found another way of doing it at <a href=\"http:\/\/www.leeholmes.com\/blog\/ConvertingCToPowerShell.aspx\">Lee Holmes\u2019 Blog<\/a>. This sure looks ugly because we are trying to change Internal .Net system settings. The code would have been prettier otherwise. The reason I like this is, your settings of ignoring what follows are short lived and will go away when you close your PowerShell session (i.e. close current PowerShell window). This is better approach to security than opening a hole in your system every time you run PowerShell as described in option 1 above.<\/li>\n<\/ol>\n<blockquote>\n<pre><font face=\"Calibri\">$netAssembly = [Reflection.Assembly]::GetAssembly([System.Net.Configuration.SettingsSection])\n\nif($netAssembly)\n{\n    $bindingFlags = [Reflection.BindingFlags] \"Static,GetProperty,NonPublic\"\n    $settingsType = $netAssembly.GetType(\"System.Net.Configuration.SettingsSectionInternal\")\n\n    $instance = $settingsType.InvokeMember(\"Section\", $bindingFlags, $null, $null, @())\n\n    if($instance)\n    {\n        $bindingFlags = \"NonPublic\",\"Instance\"\n        $useUnsafeHeaderParsingField = $settingsType.GetField(\"useUnsafeHeaderParsing\", $bindingFlags)\n\n        if($useUnsafeHeaderParsingField)\n        {\n          $useUnsafeHeaderParsingField.SetValue($instance, $true)\n        }\n    }\n}\n<\/font><\/pre>\n<\/blockquote>\n<p>Hopefully this helps you address WebClient errors, namely SSL trust and malformed headers. Cheers!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article was originally posted on my PFE blog here: http:\/\/blogs.technet.com\/b\/bshukla\/archive\/2012\/08\/22\/3324650.aspx. I noticed a few inaccuracies with the article and since I am not a PFE anymore, I can\u2019t edit [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pgc_sgb_lightbox_settings":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[19],"tags":[147,163,186,212,219,246],"class_list":["post-721","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-ignore-trust","tag-malformed-headers","tag-net-webclient","tag-powershell","tag-protocol-violation","tag-ssl"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Ignoring SSL Trust in PowerShell using System.Net.WebClient - Bhargav&#039;s IT Playground<\/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:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ignoring SSL Trust in PowerShell using System.Net.WebClient - Bhargav&#039;s IT Playground\" \/>\n<meta property=\"og:description\" content=\"This article was originally posted on my PFE blog here: http:\/\/blogs.technet.com\/b\/bshukla\/archive\/2012\/08\/22\/3324650.aspx. I noticed a few inaccuracies with the article and since I am not a PFE anymore, I can\u2019t edit [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/\" \/>\n<meta property=\"og:site_name\" content=\"Bhargav&#039;s IT Playground\" \/>\n<meta property=\"article:published_time\" content=\"2014-03-17T20:15:09+00:00\" \/>\n<meta name=\"author\" content=\"Bhargav\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bhargav\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2014\\\/03\\\/17\\\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2014\\\/03\\\/17\\\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\\\/\"},\"author\":{\"name\":\"Bhargav\",\"@id\":\"https:\\\/\\\/bhargavs.com\\\/#\\\/schema\\\/person\\\/28f6d8c9b29f3a879483d65fc2ab5e26\"},\"headline\":\"Ignoring SSL Trust in PowerShell using System.Net.WebClient\",\"datePublished\":\"2014-03-17T20:15:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2014\\\/03\\\/17\\\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\\\/\"},\"wordCount\":681,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/#\\\/schema\\\/person\\\/28f6d8c9b29f3a879483d65fc2ab5e26\"},\"keywords\":[\"Ignore Trust\",\"Malformed Headers\",\"Net.WebClient\",\"PowerShell\",\"Protocol Violation\",\"SSL\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2014\\\/03\\\/17\\\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2014\\\/03\\\/17\\\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\\\/\",\"url\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2014\\\/03\\\/17\\\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\\\/\",\"name\":\"Ignoring SSL Trust in PowerShell using System.Net.WebClient - Bhargav&#039;s IT Playground\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/#website\"},\"datePublished\":\"2014-03-17T20:15:09+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2014\\\/03\\\/17\\\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2014\\\/03\\\/17\\\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2014\\\/03\\\/17\\\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/bhargavs.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ignoring SSL Trust in PowerShell using System.Net.WebClient\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/bhargavs.com\\\/#website\",\"url\":\"https:\\\/\\\/bhargavs.com\\\/\",\"name\":\"Bhargav's IT Playground\",\"description\":\"Passion for Technology. Power of Collaboration.\",\"publisher\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/#\\\/schema\\\/person\\\/28f6d8c9b29f3a879483d65fc2ab5e26\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/bhargavs.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/bhargavs.com\\\/#\\\/schema\\\/person\\\/28f6d8c9b29f3a879483d65fc2ab5e26\",\"name\":\"Bhargav\",\"logo\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/#\\\/schema\\\/person\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/bhargavs.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ignoring SSL Trust in PowerShell using System.Net.WebClient - Bhargav&#039;s IT Playground","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:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/","og_locale":"en_US","og_type":"article","og_title":"Ignoring SSL Trust in PowerShell using System.Net.WebClient - Bhargav&#039;s IT Playground","og_description":"This article was originally posted on my PFE blog here: http:\/\/blogs.technet.com\/b\/bshukla\/archive\/2012\/08\/22\/3324650.aspx. I noticed a few inaccuracies with the article and since I am not a PFE anymore, I can\u2019t edit [&hellip;]","og_url":"https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/","og_site_name":"Bhargav&#039;s IT Playground","article_published_time":"2014-03-17T20:15:09+00:00","author":"Bhargav","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Bhargav","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/#article","isPartOf":{"@id":"https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/"},"author":{"name":"Bhargav","@id":"https:\/\/bhargavs.com\/#\/schema\/person\/28f6d8c9b29f3a879483d65fc2ab5e26"},"headline":"Ignoring SSL Trust in PowerShell using System.Net.WebClient","datePublished":"2014-03-17T20:15:09+00:00","mainEntityOfPage":{"@id":"https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/"},"wordCount":681,"commentCount":5,"publisher":{"@id":"https:\/\/bhargavs.com\/#\/schema\/person\/28f6d8c9b29f3a879483d65fc2ab5e26"},"keywords":["Ignore Trust","Malformed Headers","Net.WebClient","PowerShell","Protocol Violation","SSL"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/","url":"https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/","name":"Ignoring SSL Trust in PowerShell using System.Net.WebClient - Bhargav&#039;s IT Playground","isPartOf":{"@id":"https:\/\/bhargavs.com\/#website"},"datePublished":"2014-03-17T20:15:09+00:00","breadcrumb":{"@id":"https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/bhargavs.com\/"},{"@type":"ListItem","position":2,"name":"Ignoring SSL Trust in PowerShell using System.Net.WebClient"}]},{"@type":"WebSite","@id":"https:\/\/bhargavs.com\/#website","url":"https:\/\/bhargavs.com\/","name":"Bhargav's IT Playground","description":"Passion for Technology. Power of Collaboration.","publisher":{"@id":"https:\/\/bhargavs.com\/#\/schema\/person\/28f6d8c9b29f3a879483d65fc2ab5e26"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/bhargavs.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/bhargavs.com\/#\/schema\/person\/28f6d8c9b29f3a879483d65fc2ab5e26","name":"Bhargav","logo":{"@id":"https:\/\/bhargavs.com\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/bhargavs.com"]}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1647,"url":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/","url_meta":{"origin":721,"position":0},"title":"Send a Tweet from PowerShell","author":"Bhargav","date":"March 16, 2010","format":false,"excerpt":"While I chose to keep this article here for archiving, Please note that this doesn't work anymore. Twitter API has since changed and what used to work, doesn't anymore. I was reading Shay\u2019s article on how to send direct messages on twitter using PowerShell when I couldn\u2019t resist but find\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/bhargavs.com\/index.php\/category\/microsoft\/powershell\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image-thumb.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image-thumb.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image-thumb.png?resize=525%2C300 1.5x"},"classes":[]},{"id":1695,"url":"https:\/\/bhargavs.com\/index.php\/2013\/05\/13\/how-to-setup-office-web-apps-server-2013-farm\/","url_meta":{"origin":721,"position":1},"title":"How to setup Office Web Apps Server 2013 farm","author":"Bhargav","date":"May 13, 2013","format":false,"excerpt":"If you are deploying Lync Server 2013 and want to present Powerpoint presentations in Web Conferencing, Office Web Apps Server is a requirement. Most references I found talks about deploying a single server, however, I wanted to deploy redundant setup. In today\u2019s post, I\u2019m going to show you how to\u2026","rel":"","context":"In &quot;Load Balancing&quot;","block_context":{"text":"Load Balancing","link":"https:\/\/bhargavs.com\/index.php\/category\/technology\/load-balancing\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/bhargavs.com\/wp-content\/uploads\/2013\/05\/image_thumb.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1667,"url":"https:\/\/bhargavs.com\/index.php\/2011\/05\/23\/exchange-team-blog-mobile-and-powershell-error-handling\/","url_meta":{"origin":721,"position":2},"title":"Exchange Team Blog Mobile and PowerShell Error Handling","author":"Bhargav","date":"May 23, 2011","format":false,"excerpt":"I admit the two topics don\u2019t have anything in common except both has something to do with me. That\u2019s why they are both being talked about in same post! So If you haven\u2019t caught up on this yet, I created a Windows Phone App for the Exchange Team Blog. I\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/bhargavs.com\/index.php\/category\/microsoft\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1658,"url":"https:\/\/bhargavs.com\/index.php\/2010\/12\/09\/powershell-script-to-report-uptime\/","url_meta":{"origin":721,"position":3},"title":"PowerShell script to report uptime","author":"Bhargav","date":"December 9, 2010","format":false,"excerpt":"UPDATED - Fixed issues reporting boottime. 3\/20\/2012 I was reading Hey, Scripting Guy! article \u201cCalculating Server Uptime\u201d and decided to write a script that can do the same. While the article has very nice script that calculates uptime from event log, my script isn\u2019t fancy and simply calculates uptime since\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/bhargavs.com\/index.php\/category\/microsoft\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1203,"url":"https:\/\/bhargavs.com\/index.php\/2015\/12\/23\/how-to-find-net-framework-version-using-powershell\/","url_meta":{"origin":721,"position":4},"title":"How to find .NET Framework version using PowerShell","author":"Bhargav","date":"December 23, 2015","format":false,"excerpt":"Often times when I am getting ready to install Exchange 2016 or Exchange 2013, I look at pre-requisites and wonder if correct version of .NET Framework is already installed on the server or not. It certainly saves me time if it is already installed and depending on status of latest\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/bhargavs.com\/index.php\/category\/microsoft\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1679,"url":"https:\/\/bhargavs.com\/index.php\/2012\/05\/03\/exchange-management-shell-error-500-internal-server-error\/","url_meta":{"origin":721,"position":5},"title":"Exchange Management Shell Error 500 &#8211; Internal Server Error","author":"Bhargav","date":"May 3, 2012","format":false,"excerpt":"I have come across this issue enough times that even if it is documented on TechNet it deserves mention here. When you launch Exchange Management Shell or try to connect to an Exchange 2010 Server remotely using PowerShell, you get error \u201c500 \u2013 Internal Server Error. There is a problem\u2026","rel":"","context":"In &quot;Exchange 2010&quot;","block_context":{"text":"Exchange 2010","link":"https:\/\/bhargavs.com\/index.php\/category\/microsoft\/exchange-server\/exchange-2010\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_shortlink":"https:\/\/wp.me\/pkROc-bD","_links":{"self":[{"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/posts\/721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/comments?post=721"}],"version-history":[{"count":0,"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/posts\/721\/revisions"}],"wp:attachment":[{"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/media?parent=721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/categories?post=721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/tags?post=721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}