{"id":51233,"date":"2010-02-21T00:01:00","date_gmt":"2010-02-21T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/02\/21\/hey-scripting-guy-weekend-scripter-conversion-module-part-6\/"},"modified":"2010-02-21T00:01:00","modified_gmt":"2010-02-21T00:01:00","slug":"hey-scripting-guy-weekend-scripter-conversion-module-part-6","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-weekend-scripter-conversion-module-part-6\/","title":{"rendered":"Hey, Scripting Guy! Weekend Scripter: Conversion Module, Part 6"},"content":{"rendered":"<p><span><a class=\"addthis_button\" href=\"http:\/\/www.addthis.com\/bookmark.php?v=250&amp;pub=scriptingguys\"><em><img decoding=\"async\" alt=\"Bookmark and Share\" src=\"http:\/\/s7.addthis.com\/static\/btn\/v2\/lg-share-en.gif\" width=\"125\" height=\"16\"><\/em><\/a><br \/><\/span><\/p>\n<h2><font size=\"5\">Weekend Scripter: Conversion Module, Part 6<\/p>\n<p><\/font><\/h2>\n<p class=\"MsoNormal\">Microsoft Scripting Guy Ed Wilson here. It has been a relatively quiet weekend here in Charlotte, North Carolina. I spent a couple of hours organizing my dive pictures from a recent trip to Boca Raton, Florida. The spotted eel in the following photo was one of the highlights of that trip. <\/p>\n<p class=\"Fig-Graphic\"><img decoding=\"async\" title=\"Photo of a spotted eel\" alt=\"Photo of a spotted eel\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/hsg\/2010\/february\/hey0221\/wes-02-21-10-01.jpg\" width=\"600\" height=\"416\"><\/p>\n<p class=\"MsoNormal\">As I was looking through the pictures, I was also daydreaming a bit about the conversion module we have been working on for the last three weeks. See <a href=\"http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2010\/02\/20\/hey-scripting-guy-february-20-2010.aspx\">yesterday&rsquo;s Weekend Scripter<\/a> post for links to the other articles in this series. <\/p>\n<p class=\"MsoNormal\">The problem with modules is they can keep growing on and on and on and on until you feel as if you are painting the Golden Gate Bridge. They are a never-ending proposition. I have decided to call this the final coat of paint, unless I get some specific requests via <a href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\"><span><font face=\"Segoe\">scripter@microsoft.com<\/font><\/span><\/a>. <\/p>\n<p class=\"MsoNormal\">As an IT pro and a writer, I am a bit unusual in that I hate to type. Anytime I can reduce the amount of typing I do, I am all in favor of it. Therefore, I decided that I needed to add some aliases to the conversion module. Aliases allow us to follow best practices and give our functions nice descriptive names, but at the same time, we do not have to type the entire function name. <\/p>\n<p class=\"MsoNormal\">I wanted all of the aliases to follow a specific pattern to make them easier to remember, so I decided to make them all four-letter aliases. To see which ones are available, I used the <b>Get-Alias<\/b> cmdlet. Because all of the functions begin with <b>convertTo<\/b>, I decided the first two letters of the alias should be <b>ct<\/b>. Using the alias for <b>Get-Alias<\/b> (<b>gal<\/b>) and a wildcard character after <b>ct<\/b>, the following command reveals there are no aliases on my computer that match that configuration. This is seen here:<\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">PS C:&gt; gal ct*<br \/>PS C:&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">I can therefore use any alias that begins with <b>ct<\/b> for my module. I came up with the following aliases:<\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">New-Alias -Name CTCS -Value ConvertTo-Celsius -Description &#8220;Conversion module alias&#8221;<br \/>New-Alias -Name CTFH -Value ConvertTo-Fahrenheit -Description &#8220;Conversion module alias&#8221;<br \/>New-Alias -Name CTFT -Value ConvertTo-Feet -Description &#8220;Conversion module alias&#8221;<br \/>New-Alias -Name CTKM -Value ConvertTo-Kilometers -Description &#8220;Conversion module alias&#8221;<br \/>New-Alias -Name CTLT -Value ConvertTo-Liters -Description &#8220;Conversion module alias&#8221;<br \/>New-Alias -Name CTMT -Value ConvertTo-Meters -Description &#8220;Conversion module alias&#8221;<br \/>New-Alias -Name CTMS -Value ConvertTo-MetersPerSecond -Description &#8220;Conversion module alias&#8221;<br \/>New-Alias -Name CTML -Value ConvertTo-Miles -Description &#8220;Conversion module alias&#8221;<br \/>New-Alias -Name CTPD -Value ConvertTo-Pounds -Description &#8220;Conversion module alias&#8221;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">By default, a module will only export functions. To cause it to export our newly created aliases, I added the following command:<\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">Export-ModuleMember -alias * -function *<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">I uploaded the <b>conversionmoduleV6<\/b> module to the <a href=\"http:\/\/gallery.technet.microsoft.com\/ScriptCenter\/en-us\/d8a15c95-d6d2-4da9-874a-58d67f7be520\"><font face=\"Segoe\">Script Center Script Repository<\/font><\/a>. <\/p>\n<p class=\"MsoNormal\">If you want to know exactly what we will be looking at tomorrow, follow us on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\"><font face=\"Segoe\">Twitter<\/font><\/a> and <span><a title=\"Facebook\" href=\"http:\/\/bit.ly\/scriptingguysfacebook\"><font face=\"Segoe\">Facebook<\/font><\/a><\/span>. If you have any questions, send e-mail to us at <a href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\" target=\"_blank\"><font face=\"Segoe\">scripter@microsoft.com<\/font><\/a> or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p class=\"MsoNormal\">\n<p>&nbsp;<\/p>\n<\/p>\n<p><b><span>Ed Wilson and Craig Liebendorfer, Scripting Guys<\/p>\n<p><\/span><\/b><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Weekend Scripter: Conversion Module, Part 6 Microsoft Scripting Guy Ed Wilson here. It has been a relatively quiet weekend here in Charlotte, North Carolina. I spent a couple of hours organizing my dive pictures from a recent trip to Boca Raton, Florida. The spotted eel in the following photo was one of the highlights of [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[51,52,3,4,61,45],"class_list":["post-51233","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-getting-started","tag-modules","tag-scripting-guy","tag-scripting-techniques","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Weekend Scripter: Conversion Module, Part 6 Microsoft Scripting Guy Ed Wilson here. It has been a relatively quiet weekend here in Charlotte, North Carolina. I spent a couple of hours organizing my dive pictures from a recent trip to Boca Raton, Florida. The spotted eel in the following photo was one of the highlights of [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/51233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=51233"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/51233\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=51233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=51233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=51233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}