Howto hide a PowerShell prompt


Today I was asked a question… how to hide a PowerShell window.
In this specific scenario a script was executed by calling the PowerShell.exe executable with some appropriate parameters:

PowerShell.exe -WindowStyle Hidden -File D:MyScript.ps1

But… what if you have no such luxury? What if you only have a script and no control over how it’s called, yet you do want to hide the screen so that the user doesn’t see it?
Put the following code at the top of your script:

Add-Type -Name win -MemberDefinition '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);' -Namespace native
[]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle,0)

Well, it’s not hiding entirely (one sees a prompt for an instance) but it’s pretty darn close :-)

Use PowerShell to get the default IIS log directory


Part of an inventory I did for a customer were some defaults of their IIS configuration.
Here’s a oneliner to get the default log directory from IIS:

(Get-WebConfigurationProperty '/system.applicationHost/sites/siteDefaults' -Name '').Value

Video Presentation with Experts Live TV available online on YouTube


Last week I met up with Bert Wolters for a video presentation/interview. Bert has been recording a series of sessions on the latest and greatest functionality in Windows 10 and in this episode I discuss some of the new functionalities in PowerShell 5.0 in combination with Windows 10. The video has been recorded in Dutch, so unfortunately it will a bit hard to follow for the English speaking community.

In the video I showcase the following features:

  • Better Multiline support for the PowerShell console
  • Colored console for cmdlets, parameters and arguments
  • PowerShell cmdlets for Windows Defender
  • PowerShell debugging in the ISE using <CTRL> + B
  • DuPSUG, Dutch PowerShell User Group

For more information or the direct link of the video in this article please refer to the links below. Feel free to leave a comment either here or in the YouTube comment section.

Links in the article
Experts Live TV – 10 weken Windows 10 – Aflevering 9 – Powershell 5, Dutch PowerShell User Group

TwitterLinkedInFacebookGoogle+RedditWordPressEmailTumblrPinterestHacker NewsShare

  • ISESteroids

  • Pluralsight

  • Sapien

Go to Top