Powershell

How to Use the Get-Host (Microsoft.PowerShell.Utility) Cmdlet in PowerShell?

The “Get-Host” cmdlet is used to represent the current host program, such as the PowerShell version, region, or color. It only returns information for the current host session. It can return information like the current culture and the UI culture in Windows PowerShell. Moreover, it can be used to customize the user interface of the console, such as changing the text color and background color.

This article will explain the “Get-Host” cmdlet with the help of various examples.

How to Use the Get-Host (Microsoft.PowerShell.Utility) Cmdlet in PowerShell?

The “Get-Host” cmdlet is used to get the information about the PowerShell host. Let’s have an overview of some examples to learn the usage of the stated cmdlet.

Example 1: Use the “Get-Host” Cmdlet to Retrieve Information About the PowerShell Host

Execute the “Get-Host” cmdlet to get the information about the host:

Get-Host

Example 2: Use the “Get-Host” Cmdlet to Get the Version of the PowerShell Host

To retrieve the version of the PowerShell host, simply concatenate the “Get-Host” cmdlet with “version”:

(Get-Host).version

Example 3: Use the “Get-Host” Cmdlet to Get the Current Culture’s DateTimeFormat

In order to retrieve the date and time format of the current culture, simply execute the given command:

(Get-Host).CurrentCulture.DateTimeFormat

Example 4: Use the “Get-Host” Cmdlet to Retrieve the Properties of RawUI

To get the PowerShell UI properties, such as text color, text size, background, and more. Then, execute the below-provided command:

(Get-Host).UI.RawUI

That’s it! We have explained the “Get-Host” cmdlet in PowerShell with the help of several examples.

Conclusion

PowerShell’s “Get-Host” cmdlet is used to return the current host information, such as a version, region, and many more. It can also customize the PowerShell’s console, such as changing text color and background color. This write-up has demonstrated the “Get-Host” cmdlet in PowerShell.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.