{"id":1647,"date":"2010-03-16T00:25:02","date_gmt":"2010-03-16T05:25:02","guid":{"rendered":"http:\/\/www.bhargavs.com\/index.php\/powershell\/2010\/03\/send-a-tweet-from-powershell\/"},"modified":"2010-03-16T00:25:02","modified_gmt":"2010-03-16T05:25:02","slug":"send-a-tweet-from-powershell","status":"publish","type":"post","link":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/","title":{"rendered":"Send a Tweet from PowerShell"},"content":{"rendered":"<blockquote><p><span style=\"color: #ff0000;\">While I chose to keep this article here for archiving, Please note that this doesn&#8217;t work anymore. Twitter API has since changed and what used to work, doesn&#8217;t anymore.<\/span><\/p><\/blockquote>\n<p>I was reading Shay\u2019s article on <a href=\"http:\/\/blogs.microsoft.co.il\/blogs\/scriptfanatic\/archive\/2009\/05\/10\/how-to-send-twitter-direct-messages-from-powershell.aspx\">how to send direct messages on twitter using PowerShell<\/a> when I couldn\u2019t resist but find a way to send normal tweets from PowerShell. While trying to do that, I also incorporated security so that your transmission is secure and so is your input. Here\u2019s the code:<\/p>\n<pre lang=\"powershell\">function Send-Tweet($Message,$UserName)\n{\n   if ($Message -eq $null) {$Message = Read-Host \"Enter your tweet\"}\n   if ($Username -eq $null) {$Username = read-host \"Enter your twitter username\"}\n   if ($Password -eq $null)\n   {\n\t$Password = read-host -assecurestring \"Enter your twitter password\"\n\t$marshal = [Runtime.InteropServices.Marshal]\n\t$Password = $marshal::PtrToStringAuto($marshal::SecureStringToBSTR($Password))\n   }\n   $url=\"https:\/\/twitter.com\/statuses\/update.xml?status=$Message\"\n   $request = [System.Net.WebRequest]::Create($url)\n   $request.credentials= New-Object System.Net.NetworkCredential($UserName,$Password)\n   $request.method= \"POST\"\n   $request.contentType = \"application\/x-www-form-urlencoded\"\n   $request.GetResponse().statusCode # return the status code of the request\n}<\/pre>\n<p>To send tweet, you need to type:<\/p>\n<pre lang=\"powershell\">Send-Tweet -Message \"Hello World!\" -Username userxyz<\/pre>\n<p>Notice I did not include \u2013Password. Infact, I did not include $Password in parenthesis after function. This way even if you were using tab to cycle through available parameters, you won\u2019t see \u201cPassword\u201d as a parameter. It still won\u2019t stop you from typing:<\/p>\n<pre lang=\"powershell\">Send-Tweet -Message \"Hello World!\" -Username userxyz -Password password<\/pre>\n<p>But by not declaring the parameter, I am encouraging one to skip typing password in plain-text. When user sends tweet using first option (without password) this script will prompt user for password. How is it secure? Notice \u2013assecurestring when I am prompting user for password. This way your entry will show up as ****** instead of plaintext. If you were to use second method, you will type your password in plaintext and I am assuming you will do that when you are sure your screen is not visible to anyone else.<\/p>\n<p>Another nice feature in my script is, I am using https in URL. This way I am sending authentication string over SSL. Shay\u2019s original script for direct message does not use SSL hence username and password is transmitted in base64 encoding of string \u201cusername:password\u201d. Your tweet will be published and will be in public domain but I don\u2019t like the idea of transmitting username and password the same way. Here\u2019s why:<\/p>\n<p>The network capture shows the following:<\/p>\n<p><a href=\"http:\/\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" alt=\"image\" src=\"http:\/\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image-thumb.png\" width=\"657\" height=\"94\" border=\"0\" \/><\/a><\/p>\n<p>Now let\u2019s see what we can do with highlighted string in PowerShell:<\/p>\n<pre lang=\"powershell\">PS&gt; $b64upass = \"dXNlcm5hbWU6cGFzc3dvcmQ=\"\nPS&gt; $bytes = [convert]::FromBase64String($b64upass)\nPS&gt; $decoded = [System.Text.Encoding]::UTF8.GetString($bytes)\nPS&gt; $decoded\nusername:password<\/pre>\n<p>So as you can see, even though Base64 is not plaintext, it\u2019s very easy to decode and your username and password is more valuable than that!<\/p>\n<p>If you are going to use Shay\u2019s script for direct tweets, you can simply change URL to https and it should transmit securely. you can also use other ideas from my script to make password entry more secure.<\/p>\n<p>Here\u2019s another way of doing it:<\/p>\n<pre lang=\"powershell\">$Tweetcred = Get-Credential\n$UserName=$Tweetcred.GetNetworkCredential().UserName\n$Password=$Tweetcred.GetNetworkCredential().Password<\/pre>\n<p>Using this method simply asks user for username and password in standard windows security dialog box and stores it in credential object of the OS.<\/p>\n<p><a href=\"http:\/\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" alt=\"image\" src=\"http:\/\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image-thumb1.png\" width=\"244\" height=\"196\" border=\"0\" \/><\/a><\/p>\n<p>I thank Shay for showing me way and hope you will benefit from both his and my scripts!<\/p>\n<p><strong>Update:<\/strong> Including link to Wikipedia article on <a href=\"http:\/\/en.wikipedia.org\/wiki\/Basic_authentication_scheme\">HTTP Basic Access Authentication<\/a> for reference.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While I chose to keep this article here for archiving, Please note that this doesn&#8217;t work anymore. Twitter API has since changed and what used to work, doesn&#8217;t anymore. I [&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_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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[19],"tags":[85,212,234,258],"class_list":["post-1647","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-base64","tag-powershell","tag-security","tag-twitter"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Send a Tweet from PowerShell - 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\/2010\/03\/16\/send-a-tweet-from-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Send a Tweet from PowerShell - Bhargav&#039;s IT Playground\" \/>\n<meta property=\"og:description\" content=\"While I chose to keep this article here for archiving, Please note that this doesn&#8217;t work anymore. Twitter API has since changed and what used to work, doesn&#8217;t anymore. I [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"Bhargav&#039;s IT Playground\" \/>\n<meta property=\"article:published_time\" content=\"2010-03-16T05:25:02+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image-thumb.png\" \/>\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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/\"},\"author\":{\"name\":\"Bhargav\",\"@id\":\"https:\\\/\\\/bhargavs.com\\\/#\\\/schema\\\/person\\\/28f6d8c9b29f3a879483d65fc2ab5e26\"},\"headline\":\"Send a Tweet from PowerShell\",\"datePublished\":\"2010-03-16T05:25:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/\"},\"wordCount\":456,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/#\\\/schema\\\/person\\\/28f6d8c9b29f3a879483d65fc2ab5e26\"},\"image\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.bhargavs.com\\\/wp-content\\\/uploads\\\/2010\\\/03\\\/image-thumb.png\",\"keywords\":[\"base64\",\"PowerShell\",\"Security\",\"twitter\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/\",\"url\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/\",\"name\":\"Send a Tweet from PowerShell - Bhargav&#039;s IT Playground\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.bhargavs.com\\\/wp-content\\\/uploads\\\/2010\\\/03\\\/image-thumb.png\",\"datePublished\":\"2010-03-16T05:25:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/#primaryimage\",\"url\":\"http:\\\/\\\/www.bhargavs.com\\\/wp-content\\\/uploads\\\/2010\\\/03\\\/image-thumb.png\",\"contentUrl\":\"http:\\\/\\\/www.bhargavs.com\\\/wp-content\\\/uploads\\\/2010\\\/03\\\/image-thumb.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/bhargavs.com\\\/index.php\\\/2010\\\/03\\\/16\\\/send-a-tweet-from-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/bhargavs.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Send a Tweet from PowerShell\"}]},{\"@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":"Send a Tweet from PowerShell - 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\/2010\/03\/16\/send-a-tweet-from-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Send a Tweet from PowerShell - Bhargav&#039;s IT Playground","og_description":"While I chose to keep this article here for archiving, Please note that this doesn&#8217;t work anymore. Twitter API has since changed and what used to work, doesn&#8217;t anymore. I [&hellip;]","og_url":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/","og_site_name":"Bhargav&#039;s IT Playground","article_published_time":"2010-03-16T05:25:02+00:00","og_image":[{"url":"http:\/\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image-thumb.png","type":"","width":"","height":""}],"author":"Bhargav","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Bhargav","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/#article","isPartOf":{"@id":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/"},"author":{"name":"Bhargav","@id":"https:\/\/bhargavs.com\/#\/schema\/person\/28f6d8c9b29f3a879483d65fc2ab5e26"},"headline":"Send a Tweet from PowerShell","datePublished":"2010-03-16T05:25:02+00:00","mainEntityOfPage":{"@id":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/"},"wordCount":456,"commentCount":6,"publisher":{"@id":"https:\/\/bhargavs.com\/#\/schema\/person\/28f6d8c9b29f3a879483d65fc2ab5e26"},"image":{"@id":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image-thumb.png","keywords":["base64","PowerShell","Security","twitter"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/","url":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/","name":"Send a Tweet from PowerShell - Bhargav&#039;s IT Playground","isPartOf":{"@id":"https:\/\/bhargavs.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/#primaryimage"},"image":{"@id":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image-thumb.png","datePublished":"2010-03-16T05:25:02+00:00","breadcrumb":{"@id":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/#primaryimage","url":"http:\/\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image-thumb.png","contentUrl":"http:\/\/www.bhargavs.com\/wp-content\/uploads\/2010\/03\/image-thumb.png"},{"@type":"BreadcrumbList","@id":"https:\/\/bhargavs.com\/index.php\/2010\/03\/16\/send-a-tweet-from-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/bhargavs.com\/"},{"@type":"ListItem","position":2,"name":"Send a Tweet from PowerShell"}]},{"@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":34526,"url":"https:\/\/bhargavs.com\/index.php\/2024\/01\/30\/clearing-microsoft-teams-cache-with-powershell\/","url_meta":{"origin":1647,"position":0},"title":"Clearing Microsoft Teams Cache with PowerShell","author":"Bhargav","date":"January 30, 2024","format":false,"excerpt":"Introduction I recently came across a need to clear Teams cache. While the task might be simple, I ended up spending a little more time to address the scenarios I can foresee so the PowerShell script is more useful that a single use case. In this blog post, we'll be\u2026","rel":"","context":"In &quot;General&quot;","block_context":{"text":"General","link":"https:\/\/bhargavs.com\/index.php\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1650,"url":"https:\/\/bhargavs.com\/index.php\/2010\/03\/29\/script-to-enable-preview-pane-for-powershell-scripts\/","url_meta":{"origin":1647,"position":1},"title":"Script to enable preview pane for PowerShell scripts","author":"Bhargav","date":"March 29, 2010","format":false,"excerpt":"If you are running Windows 7, you probably know what preview pane is. And if you use PowerShell and create ps1 scripts, you may also wonder how can you enable preview for PowerShell scripts in Windows Explorer. Well, Nate Bruneau shared how to edit registry to enable preview for ps1\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":1643,"url":"https:\/\/bhargavs.com\/index.php\/2010\/02\/19\/powershell-variables-and-scopes\/","url_meta":{"origin":1647,"position":2},"title":"PowerShell Variables and scopes","author":"Bhargav","date":"February 19, 2010","format":false,"excerpt":"I was helping someone with a profile script. The script is supposed to connect to a remote Exchange 2010 server using PowerShell v2.0 when it is launched. The script had a function which is called upon when profile is loaded. The function looked like the following: function connect-remotely() { if\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":[]},{"id":721,"url":"https:\/\/bhargavs.com\/index.php\/2014\/03\/17\/ignoring-ssl-trust-in-powershell-using-system-net-webclient\/","url_meta":{"origin":1647,"position":3},"title":"Ignoring SSL Trust in PowerShell using System.Net.WebClient","author":"Bhargav","date":"March 17, 2014","format":false,"excerpt":"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 original article but posting updated article here for everyone to benefit from. The Problem We all at one point or\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":1647,"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":1652,"url":"https:\/\/bhargavs.com\/index.php\/2010\/07\/07\/deceiving-scopes-of-variables-in-a-function\/","url_meta":{"origin":1647,"position":5},"title":"Deceiving scopes of variables in a function","author":"Bhargav","date":"July 7, 2010","format":false,"excerpt":"I was recently troubleshooting a script when I came across a problem where a variable with defined scope was not retaining its value even though scope seemed correct. Let\u2019s look at simplified example below:Function Global:Name-ofaFunction { $Global:VariableinQuestion = $null $VariableinQuestion = \"Value\" $VariableinQuestion } Name-ofaFunction $VariableinQuestion The function \u201cName-ofaFunction\u201d when\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":[]}],"jetpack_shortlink":"https:\/\/wp.me\/pkROc-qz","_links":{"self":[{"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/posts\/1647","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=1647"}],"version-history":[{"count":0,"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/posts\/1647\/revisions"}],"wp:attachment":[{"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/media?parent=1647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/categories?post=1647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bhargavs.com\/index.php\/wp-json\/wp\/v2\/tags?post=1647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}