{"id":6041,"date":"2008-06-02T20:29:18","date_gmt":"2008-06-02T20:29:18","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2008\/06\/02\/show-powershell-hide-powershell\/"},"modified":"2019-02-18T13:15:51","modified_gmt":"2019-02-18T20:15:51","slug":"show-powershell-hide-powershell","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/show-powershell-hide-powershell\/","title":{"rendered":"Show-PowerShell \/ Hide-PowerShell"},"content":{"rendered":"<p>During the Week of WPF, someone requested an example of how to minimize the PowerShell window.<\/p>\n<p>Here&#8217;s a quick module to make it happen.&#160; Copy\/paste the code below into Documents\\WindowsPowerShell\\Packages\\PowerShell\\PowerShell.psm1<\/p>\n<blockquote>\n<p>$script:showWindowAsync = Add-Type &#8211;memberDefinition @&#8221;      <br \/>[DllImport(&quot;user32.dll&quot;)]       <br \/>public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);       <br \/>&#8220;@ -name &#8220;Win32ShowWindowAsync&#8221; -namespace Win32Functions &#8211;passThru<\/p>\n<p>function Show-PowerShell() {      <br \/>&#160;&#160;&#160;&#160; $null = $showWindowAsync::ShowWindowAsync((Get-Process &#8211;id $pid).MainWindowHandle, 10)       <br \/>}<\/p>\n<p>function Hide-PowerShell() {      <br \/>&#160;&#160;&#160; $null = $showWindowAsync::ShowWindowAsync((Get-Process &#8211;id $pid).MainWindowHandle, 2)       <br \/>}<\/p>\n<\/blockquote>\n<p>Now you can use the code below to Show and Hide PowerShell:<\/p>\n<blockquote>\n<p>Add-Module PowerShell      <br \/># Minimize PowerShell       <br \/>Hide-PowerShell       <br \/>sleep 2       <br \/># Then Restore it       <br \/>Show-PowerShell<\/p>\n<\/blockquote>\n<p>Hope this Helps,    <br \/>James Brundage[MSFT]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>During the Week of WPF, someone requested an example of how to minimize the PowerShell window. Here&#8217;s a quick module to make it happen.&#160; Copy\/paste the code below into Documents\\WindowsPowerShell\\Packages\\PowerShell\\PowerShell.psm1 $script:showWindowAsync = Add-Type &#8211;memberDefinition @&#8221; [DllImport(&quot;user32.dll&quot;)] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); &#8220;@ -name &#8220;Win32ShowWindowAsync&#8221; -namespace Win32Functions &#8211;passThru function Show-PowerShell() { &#160;&#160;&#160;&#160; $null [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[96],"class_list":["post-6041","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-add-type"],"acf":[],"blog_post_summary":"<p>During the Week of WPF, someone requested an example of how to minimize the PowerShell window. Here&#8217;s a quick module to make it happen.&#160; Copy\/paste the code below into Documents\\WindowsPowerShell\\Packages\\PowerShell\\PowerShell.psm1 $script:showWindowAsync = Add-Type &#8211;memberDefinition @&#8221; [DllImport(&quot;user32.dll&quot;)] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); &#8220;@ -name &#8220;Win32ShowWindowAsync&#8221; -namespace Win32Functions &#8211;passThru function Show-PowerShell() { &#160;&#160;&#160;&#160; $null [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/6041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=6041"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/6041\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=6041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=6041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=6041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}