{"id":1311,"date":"2014-05-21T00:01:00","date_gmt":"2014-05-21T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2014\/05\/21\/whats-in-your-powershell-profile-users-favorites-part-2\/"},"modified":"2014-05-21T00:01:00","modified_gmt":"2014-05-21T00:01:00","slug":"whats-in-your-powershell-profile-users-favorites-part-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/whats-in-your-powershell-profile-users-favorites-part-2\/","title":{"rendered":"What&#039;s in Your PowerShell Profile? Users&#039; Favorites Part 2"},"content":{"rendered":"<p><b>Summary<\/b>: Microsoft Scripting Guy, Ed Wilson, talks to various Microsoft Windows PowerShell users about what is in their profile.\nMicrosoft Scripting Guy, Ed Wilson, is here. Today I have more items that Microsoft employees have in their profiles.\n<span style=\"font-size:large\"><b>Michael Lyons<\/b><\/span> shared this:\nTo make my Windows PowerShell profile easier to use, I like to customize it with:<\/p>\n<ul>\n<li>Some additional aliases to give a quick shorthand to common commands.<\/li>\n<li>A prompt that has color and times every command. It shows the time if it took more than 3&nbsp;seconds to run, and it beeps if it took more than 20 seconds (so if I&rsquo;m reading email or browsing the web, I can tell when it&rsquo;s done).<\/li>\n<li>A replacement for &ldquo;dir&rdquo; and &ldquo;rd&rdquo; that call &ldquo;cmd.exe&rdquo; so that the syntax is the same. It&rsquo;s too burnt into my brain. If I&rsquo;m currently in a PS drive, it will mount it to a valid drive letter first (because <b>cmd.exe<\/b> must be called from a valid drive).<\/li>\n<li>A <b>hosts<\/b> function to edit <b>$env:windirsystem32driversetchosts<\/b>.<\/li>\n<li>Some <b>Update-FormatData<\/b> changes. For example, file sizes shown with <b>gci<\/b> have thousands separators, junctions will show that they are junctions, and certificates will show if they have a private key.<\/li>\n<\/ul>\n<p>Here&rsquo;s my <b>dir <\/b>function:<\/p>\n<p style=\"margin-left:30px\">function GLOBAL:dir<\/p>\n<p style=\"margin-left:30px\">{<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; $cwd = &amp; cmd.exe \/c cd 2&gt; $null<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; if ($cwd -eq $pwd.Path)<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp; cmd.exe \/c dir $args<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; else<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $cwd = $pwd.ProviderPath<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pushd $home<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp; cmd.exe \/c pushd &#8220;$cwd&#8221; `&amp; dir $args<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; popd<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">}\n<span style=\"font-size:large\"><b>Tiger Wang<\/b><\/span> provided the following function called <b>DllOptimizationControl.psm1<\/b>.<b> <\/b>Each function recursively turns ON and OFF the optimization for each DLL under the current path. For more information about, .NET Framework Debugging Control, see <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/9dd8z24x(VS.80).aspx\" target=\"_blank\">Making an Image Easier to Debug<\/a>.<\/p>\n<p style=\"margin-left:30px\">function Disable-DllOptimization($path=&#8221;$PWD&#8221;)<\/p>\n<p style=\"margin-left:30px\">{<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; Get-ChildItem $path -Recurse | Where-Object {$_.Name.Contains(&#8220;.dll&#8221;)} |<br \/> &nbsp; &nbsp; ForEach-Object {$_.FullName.Replace(&#8220;.dll&#8221;, &#8220;.ini&#8221;)} | ForEach-Object {Remove-Item $_ -Force}<\/p>\n<p style=\"margin-left:30px\">}\n&nbsp;<\/p>\n<p style=\"margin-left:30px\">function Enable-DllOptimization($path=&#8221;$PWD&#8221;)<\/p>\n<p style=\"margin-left:30px\">{<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; $debugInfo =<\/p>\n<p style=\"margin-left:30px\">@&#8217;<\/p>\n<p style=\"margin-left:30px\">[.NET Framework Debugging Control]<\/p>\n<p style=\"margin-left:30px\">AllowOptimize=0<\/p>\n<p style=\"margin-left:30px\">GenerateTrackingInfo=1<\/p>\n<p style=\"margin-left:30px\">&#8216;@\n&nbsp;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; Get-ChildItem $path -Recurse | Where-Object {$_.Name.Contains(&#8220;.dll&#8221;)} | <br \/>&nbsp; &nbsp; &nbsp;ForEach-Object {$_.FullName.Replace(&#8220;.dll&#8221;, &#8220;.ini&#8221;)} | ForEach-Object {$debugInfo | Out-File $_}<\/p>\n<p style=\"margin-left:30px\">}\n<b><span style=\"font-size:large\">Tim Dunn<\/span> <\/b>provided a link to a recent blog post he wrote called <a href=\"http:\/\/blogs.msdn.com\/b\/timid\/archive\/2014\/02\/05\/profile-and-rdp-sessions.aspx\" target=\"_blank\">$PROFILE and RDP Sessions<\/a>. I am not going to explain his entire post, but I wanted to point out one item. He has a real cool method of mapping his home drive when accessing resources by remoting into machines in different domains. It is pretty clever and it is worth a read.\n<span style=\"font-size:large\"><b>Rahul Duggal<\/b><\/span> wrote:\n&#8220;I usually work with SQL Server, and I&rsquo;ve found the following function to be useful in my profile.&#8221;<\/p>\n<p style=\"margin-left:30px\">Write-Host &#8220;Loading SQLPS Module, Hold your horses!&#8221; -Fore Green # To tell user, why PS is not showing prompt yet<\/p>\n<p style=\"margin-left:30px\">Import-Module SQLPS -DisableNameChecking<\/p>\n<p style=\"margin-left:30px\">Write-Host &#8220;Welcome $env:USERNAME , Let&#8217;s Automate !!!&#8221; -Fore yellow&nbsp; # Small motivation<\/p>\n<p style=\"margin-left:30px\">Set-Location E:PowerShell #I change default directory to avoid accidental damage to important folders in C: drive<\/p>\n<p style=\"margin-left:30px\">$host.PrivateData.ErrorForegroundColor = &#8220;gray&#8221; &nbsp;# RED colour in error message stresses me out J\nTomorrow we will see what is in the profiles of some Windows PowerShell MVPs.\nI invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/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.\n<b>Ed Wilson, Microsoft Scripting Guy<\/b>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks to various Microsoft Windows PowerShell users about what is in their profile. Microsoft Scripting Guy, Ed Wilson, is here. Today I have more items that Microsoft employees have in their profiles. Michael Lyons shared this: To make my Windows PowerShell profile easier to use, I like to customize [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[144,3,4,45],"class_list":["post-1311","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-profiles","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks to various Microsoft Windows PowerShell users about what is in their profile. Microsoft Scripting Guy, Ed Wilson, is here. Today I have more items that Microsoft employees have in their profiles. Michael Lyons shared this: To make my Windows PowerShell profile easier to use, I like to customize [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/1311","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\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=1311"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/1311\/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=1311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=1311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=1311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}