Updates from: 03/23/2021 04:15:07
Service Microsoft Docs article Related commit history on GitHub Change details
Microsoft.PowerShell.Core Receive Job (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/Receive-Job.md
external help file: System.Management.Automation.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Core Previously updated : 06/09/2017 Last updated : 03/22/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/receive-job?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Receive-Job
Running AppMgmt Application Management Server02
# Use the New-PSSession cmdlet to create three user-managed PSSessions on three servers, and save the sessions in the $s variable. $s = New-PSSession -ComputerName Server01, Server02, Server03 # Use Invoke-Command run a Start-Job command in each of the PSSessions in the $s variable.
-# The job outputs the ComputerName of each server.
+# The creates a new job with a custom name to each server
+# The job outputs the datetime from each server
# Save the job objects in the $j variable.
-$j = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {$env:COMPUTERNAME}}
+$j = Invoke-Command -Session $s -ScriptBlock {ΓÇïStart-Job -Name $('MyJob-' +$env:COMPUTERNAME) -ScriptBlock {(Get-Date).ToString()ΓÇï}ΓÇï}
# To confirm that these job objects are from the remote machines, run Get-Job to show no local jobs running.
-Get-Job
+Get-JobΓÇïΓÇï
``` ```Output
$j
``` ```Output
-Id Name State HasMoreData Location Command
-1 Job1 Completed True Localhost $env:COMPUTERNAME
-2 Job2 Completed True Localhost $env:COMPUTERNAME
-3 Job3 Completed True Localhost $env:COMPUTERNAME
+Id Name State HasMoreData Location Command
+-- ---- ----- ----------- -------- -------
+1 MyJob-Server01 Completed True Localhost (Get-Date).ToString()
+2 MyJob-Server02 Completed True Localhost (Get-Date).ToString()
+3 MyJob-Server03 Completed True Localhost (Get-Date).ToString()
``` ```powershell
-# Use Invoke-Command to run a Receive-Job command in each of the sessions in the $s variable and save the results in the $Results variable.
+# Use Invoke-Command to run a Receive-Job command in each of the sessions in the $s variable and save the results in the $results variable.
# The Receive-Job command must be run in each session because the jobs were run locally on each server.
-$results = Invoke-Command -Session $s -ScriptBlock {Receive-Job -Job $Using:j}
+$results = Invoke-Command -Session $s -ScriptBlock {ΓÇïReceive-Job -Name $('MyJob-' +$env:COMPUTERNAME)}
``` ```Output
-Server01
-Server02
-Server03
+3/22/2021 7:41:47 PM
+3/22/2021 7:41:47 PM
+3/22/2021 9:41:47 PM
``` This example shows how to get the results of background jobs run on three remote computers.
Unlike the previous example, using `Invoke-Command` to run the `Start-Job` comma
started three independent jobs on each of the three computers. As a result, the command returned three job objects representing three jobs run locally on three different computers.
-> [!NOTE]
-> In the last command, because `$j` is a local variable, the script block uses the **Using** scope
-> modifier to identify the `$j` variable. For more information about the **Using** scope modifier,
-> see [about_Remote_Variables](./About/about_Remote_Variables.md).
- ### Example 5: Access child jobs The `-Keep` parameter preserves the state of the aggregated streams of a job so that it
Microsoft.PowerShell.Utility Get Host (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Utility/Get-Host.md
--- external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 03/22/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-host?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-Host ---- # Get-Host ## SYNOPSIS
features of the host program user interface, such as the text and background col
### Example 1: Get information about the PowerShell console host ```
-PS C:\> Get-Host
+Get-Host
+ Name : ConsoleHost Version : 2.0 InstanceId : e4e0ab54-cc5e-4261-9117-4081f20ce7a2
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace ```
-This command displays information about the Windows PowerShell console, which is the current host
-program for Windows PowerShell in this example. It includes the name of the host, the version of
-Windows PowerShell that is running in the host, and current culture and UI culture.
+This command displays information about the PowerShell console, which is the current host program
+for PowerShell in this example. It includes the name of the host, the version of PowerShell that is
+running in the host, and current culture and UI culture.
-The Version, UI, CurrentCulture, CurrentUICulture, PrivateData, and Runspace properties each contain
-an object with very useful properties. Later examples examine these properties.
+The **Version**, **UI**, **CurrentCulture**, **CurrentUICulture**, **PrivateData**, and **Runspace**
+properties each contain an object with other useful properties. Later examples examine these
+properties.
### Example 2: Resize the PowerShell window ```powershell
-PS C:\> $H = Get-Host
-PS C:\> $Win = $H.UI.RawUI.WindowSize
-PS C:\> $Win.Height = 10
-PS C:\> $Win.Width = 10
-PS C:\> $H.UI.RawUI.Set_WindowSize($Win)
+$H = Get-Host
+$Win = $H.UI.RawUI.WindowSize
+$Win.Height = 10
+$Win.Width = 10
+$H.UI.RawUI.Set_WindowSize($Win)
```
-This command resizes the Windows PowerShell window to 10 pixels by 10 pixels.
+This command resizes the Windows PowerShell window to 10 lines by 10 characters.
### Example 3: Get the PowerShell version for the host ```powershell
-PS C:\> (Get-Host).Version | Format-List -Property *
+(Get-Host).Version | Format-List -Property *
+ Major : 2 Minor : 0 Build : -1
This command gets detailed information about the version of Windows PowerShell r
You can view, but not change, these values. The Version property of `Get-Host` contains a **System.Version** object. This command uses a
-pipeline operator (|) to send the version object to the `Format-List` cmdlet. The `Format-List`
-command uses the *Property* parameter with a value of all (*) to display all of the properties and
-property values of the version object.
+pipeline operator (`|`) to send the version object to the `Format-List` cmdlet. The `Format-List`
+command uses the **Property** parameter with a value of all (`*`) to display all of the properties
+and property values of the version object.
### Example 4: Get the current culture for the host ```powershell
-PS C:\> (Get-Host).CurrentCulture | Format-List -Property *
+(Get-Host).CurrentCulture | Format-List -Property *
+ Parent : en LCID : 1033 KeyboardLayoutId : 1033
in the host. This is the same information that is returned by the `Get-Culture`
Similarly, the **CurrentUICulture** property returns the same object that `Get-UICulture` returns. The **CurrentCulture** property of the host object contains a **System.Globalization.CultureInfo**
-object. This command uses a pipeline operator (|) to send the **CultureInfo** object to the
-`Format-List` cmdlet. The `Format-List` command uses the *Property* parameter with a value of all
-(*) to display all of the properties and property values of the **CultureInfo** object.
+object. This command uses a pipeline operator (`|`) to send the **CultureInfo** object to the
+`Format-List` cmdlet. The `Format-List` command uses the **Property** parameter with a value of all
+(`*`) to display all of the properties and property values of the **CultureInfo** object.
### Example 5: Get the DateTimeFormat for the current culture ```powershell
-PS C:\> (Get-Host).CurrentCulture.DateTimeFormat | Format-List -Property *
+(Get-Host).CurrentCulture.DateTimeFormat | Format-List -Property *
+ AMDesignator : AM Calendar : System.Globalization.GregorianCalendar DateSeparator : /
display the property values of the object, use the `Format-List` cmdlet.
### Example 6: Get the RawUI property for the host ```
-PS C:\> (Get-Host).UI.RawUI | Format-List -Property *
+(Get-Host).UI.RawUI | Format-List -Property *
+ ForegroundColor : DarkYellow BackgroundColor : DarkBlue CursorPosition : 0,390
values, you can change the appearance of the host program.
### Example 7: Set the background color for the PowerShell console ```powershell
-PS C:\> (Get-Host).UI.RawUI.BackgroundColor = "Black"
-PS C:\> cls
+(Get-Host).UI.RawUI.BackgroundColor = "Black"
+cls
``` These commands change the background color of the Windows PowerShell console to black. The **cls**
command is an alias for the `Clear-Host` function, which clears the screen and c
screen to the new color. This change is effective only in the current session. To change the background color of the console
-for all sessions, add the command to your Windows PowerShell profile.
+for all sessions, add the command to your PowerShell profile.
### Example 8: Set the background color for error messages
-```
-PS C:\> $Host.PrivateData.ErrorBackgroundColor = "white"
+```powershell
+$Host.PrivateData.ErrorBackgroundColor = "white"
``` This command changes the background color of error messages to white.
interchangeably.
This command uses the **PrivateData** property of `$Host` as its ErrorBackgroundColor property. To see all of the properties of the object in the `$Host`.PrivateData property, type
-`$host.privatedata | format-list *`.
+`$host.PrivateData | format-list *`.
## PARAMETERS
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## INPUTS ### None+ You cannot pipe input to this cmdlet. ## OUTPUTS
Microsoft.PowerShell.Core Receive Job (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/Receive-Job.md
external help file: System.Management.Automation.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Core Previously updated : 06/09/2017 Last updated : 03/22/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/receive-job?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Receive-Job
Running AppMgmt Application Management Server02
# Use the New-PSSession cmdlet to create three user-managed PSSessions on three servers, and save the sessions in the $s variable. $s = New-PSSession -ComputerName Server01, Server02, Server03 # Use Invoke-Command run a Start-Job command in each of the PSSessions in the $s variable.
-# The job outputs the ComputerName of each server.
+# The creates a new job with a custom name to each server
+# The job outputs the datetime from each server
# Save the job objects in the $j variable.
-$j = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {$env:COMPUTERNAME}}
+$j = Invoke-Command -Session $s -ScriptBlock {ΓÇïStart-Job -Name $('MyJob-' +$env:COMPUTERNAME) -ScriptBlock {(Get-Date).ToString()ΓÇï}ΓÇï}
# To confirm that these job objects are from the remote machines, run Get-Job to show no local jobs running.
-Get-Job
+Get-JobΓÇïΓÇï
``` ```Output
$j
``` ```Output
-Id Name State HasMoreData Location Command
-1 Job1 Completed True Localhost $env:COMPUTERNAME
-2 Job2 Completed True Localhost $env:COMPUTERNAME
-3 Job3 Completed True Localhost $env:COMPUTERNAME
+Id Name State HasMoreData Location Command
+-- ---- ----- ----------- -------- -------
+1 MyJob-Server01 Completed True Localhost (Get-Date).ToString()
+2 MyJob-Server02 Completed True Localhost (Get-Date).ToString()
+3 MyJob-Server03 Completed True Localhost (Get-Date).ToString()
``` ```powershell
-# Use Invoke-Command to run a Receive-Job command in each of the sessions in the $s variable and save the results in the $Results variable.
+# Use Invoke-Command to run a Receive-Job command in each of the sessions in the $s variable and save the results in the $results variable.
# The Receive-Job command must be run in each session because the jobs were run locally on each server.
-$results = Invoke-Command -Session $s -ScriptBlock {Receive-Job -Job $Using:j}
+$results = Invoke-Command -Session $s -ScriptBlock {ΓÇïReceive-Job -Name $('MyJob-' +$env:COMPUTERNAME)}
``` ```Output
-Server01
-Server02
-Server03
+3/22/2021 7:41:47 PM
+3/22/2021 7:41:47 PM
+3/22/2021 9:41:47 PM
``` This example shows how to get the results of background jobs run on three remote computers.
Unlike the previous example, using `Invoke-Command` to run the `Start-Job` comma
started three independent jobs on each of the three computers. As a result, the command returned three job objects representing three jobs run locally on three different computers.
-> [!NOTE]
-> In the last command, because `$j` is a local variable, the script block uses the **Using** scope
-> modifier to identify the `$j` variable. For more information about the **Using** scope modifier,
-> see [about_Remote_Variables](./About/about_Remote_Variables.md).
- ### Example 5: Access child jobs The `-Keep` parameter preserves the state of the aggregated streams of a job so that it
Microsoft.PowerShell.Utility Get Host (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Utility/Get-Host.md
--- external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 03/22/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-host?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-Host
features of the host program user interface, such as the text and background col
### Example 1: Get information about the PowerShell console host ```
-PS C:\> Get-Host
+Get-Host
+ Name : ConsoleHost Version : 2.0 InstanceId : e4e0ab54-cc5e-4261-9117-4081f20ce7a2
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace ```
-This command displays information about the Windows PowerShell console, which is the current host
-program for Windows PowerShell in this example. It includes the name of the host, the version of
-Windows PowerShell that is running in the host, and current culture and UI culture.
+This command displays information about the PowerShell console, which is the current host program
+for PowerShell in this example. It includes the name of the host, the version of PowerShell that is
+running in the host, and current culture and UI culture.
-The Version, UI, CurrentCulture, CurrentUICulture, PrivateData, and Runspace properties each contain
-an object with very useful properties. Later examples examine these properties.
+The **Version**, **UI**, **CurrentCulture**, **CurrentUICulture**, **PrivateData**, and **Runspace**
+properties each contain an object with other useful properties. Later examples examine these
+properties.
### Example 2: Resize the PowerShell window ```powershell
-PS C:\> $H = Get-Host
-PS C:\> $Win = $H.UI.RawUI.WindowSize
-PS C:\> $Win.Height = 10
-PS C:\> $Win.Width = 10
-PS C:\> $H.UI.RawUI.Set_WindowSize($Win)
+$H = Get-Host
+$Win = $H.UI.RawUI.WindowSize
+$Win.Height = 10
+$Win.Width = 10
+$H.UI.RawUI.Set_WindowSize($Win)
```
-This command resizes the Windows PowerShell window to 10 pixels by 10 pixels.
+This command resizes the Windows PowerShell window to 10 lines by 10 characters.
### Example 3: Get the PowerShell version for the host ```powershell
-PS C:\> (Get-Host).Version | Format-List -Property *
+(Get-Host).Version | Format-List -Property *
+ Major : 2 Minor : 0 Build : -1
This command gets detailed information about the version of Windows PowerShell r
You can view, but not change, these values. The Version property of `Get-Host` contains a **System.Version** object. This command uses a
-pipeline operator (|) to send the version object to the `Format-List` cmdlet. The `Format-List`
-command uses the *Property* parameter with a value of all (*) to display all of the properties and
-property values of the version object.
+pipeline operator (`|`) to send the version object to the `Format-List` cmdlet. The `Format-List`
+command uses the **Property** parameter with a value of all (`*`) to display all of the properties
+and property values of the version object.
### Example 4: Get the current culture for the host ```powershell
-PS C:\> (Get-Host).CurrentCulture | Format-List -Property *
+(Get-Host).CurrentCulture | Format-List -Property *
+ Parent : en LCID : 1033 KeyboardLayoutId : 1033
in the host. This is the same information that is returned by the `Get-Culture`
Similarly, the **CurrentUICulture** property returns the same object that `Get-UICulture` returns. The **CurrentCulture** property of the host object contains a **System.Globalization.CultureInfo**
-object. This command uses a pipeline operator (|) to send the **CultureInfo** object to the
-`Format-List` cmdlet. The `Format-List` command uses the *Property* parameter with a value of all
-(*) to display all of the properties and property values of the **CultureInfo** object.
+object. This command uses a pipeline operator (`|`) to send the **CultureInfo** object to the
+`Format-List` cmdlet. The `Format-List` command uses the **Property** parameter with a value of all
+(`*`) to display all of the properties and property values of the **CultureInfo** object.
### Example 5: Get the DateTimeFormat for the current culture ```powershell
-PS C:\> (Get-Host).CurrentCulture.DateTimeFormat | Format-List -Property *
+(Get-Host).CurrentCulture.DateTimeFormat | Format-List -Property *
+ AMDesignator : AM Calendar : System.Globalization.GregorianCalendar DateSeparator : /
display the property values of the object, use the `Format-List` cmdlet.
### Example 6: Get the RawUI property for the host ```
-PS C:\> (Get-Host).UI.RawUI | Format-List -Property *
+(Get-Host).UI.RawUI | Format-List -Property *
+ ForegroundColor : DarkYellow BackgroundColor : DarkBlue CursorPosition : 0,390
values, you can change the appearance of the host program.
### Example 7: Set the background color for the PowerShell console ```powershell
-PS C:\> (Get-Host).UI.RawUI.BackgroundColor = "Black"
-PS C:\> cls
+(Get-Host).UI.RawUI.BackgroundColor = "Black"
+cls
``` These commands change the background color of the Windows PowerShell console to black. The **cls**
command is an alias for the `Clear-Host` function, which clears the screen and c
screen to the new color. This change is effective only in the current session. To change the background color of the console
-for all sessions, add the command to your Windows PowerShell profile.
+for all sessions, add the command to your PowerShell profile.
### Example 8: Set the background color for error messages
-```
-PS C:\> $Host.PrivateData.ErrorBackgroundColor = "white"
+```powershell
+$Host.PrivateData.ErrorBackgroundColor = "white"
``` This command changes the background color of error messages to white.
interchangeably.
This command uses the **PrivateData** property of `$Host` as its ErrorBackgroundColor property. To see all of the properties of the object in the `$Host`.PrivateData property, type
-`$host.privatedata | format-list *`.
+`$host.PrivateData | format-list *`.
## PARAMETERS
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## INPUTS ### None+ You cannot pipe input to this cmdlet. ## OUTPUTS
Microsoft.PowerShell.Core Receive Job (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/Receive-Job.md
external help file: System.Management.Automation.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Core Previously updated : 06/09/2017 Last updated : 03/22/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/receive-job?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Receive-Job
Running AppMgmt Application Management Server02
# Use the New-PSSession cmdlet to create three user-managed PSSessions on three servers, and save the sessions in the $s variable. $s = New-PSSession -ComputerName Server01, Server02, Server03 # Use Invoke-Command run a Start-Job command in each of the PSSessions in the $s variable.
-# The job outputs the ComputerName of each server.
+# The creates a new job with a custom name to each server
+# The job outputs the datetime from each server
# Save the job objects in the $j variable.
-$j = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {$env:COMPUTERNAME}}
+$j = Invoke-Command -Session $s -ScriptBlock {ΓÇïStart-Job -Name $('MyJob-' +$env:COMPUTERNAME) -ScriptBlock {(Get-Date).ToString()ΓÇï}ΓÇï}
# To confirm that these job objects are from the remote machines, run Get-Job to show no local jobs running.
-Get-Job
+Get-JobΓÇïΓÇï
``` ```Output
$j
``` ```Output
-Id Name State HasMoreData Location Command
-1 Job1 Completed True Localhost $env:COMPUTERNAME
-2 Job2 Completed True Localhost $env:COMPUTERNAME
-3 Job3 Completed True Localhost $env:COMPUTERNAME
+Id Name State HasMoreData Location Command
+-- ---- ----- ----------- -------- -------
+1 MyJob-Server01 Completed True Localhost (Get-Date).ToString()
+2 MyJob-Server02 Completed True Localhost (Get-Date).ToString()
+3 MyJob-Server03 Completed True Localhost (Get-Date).ToString()
``` ```powershell
-# Use Invoke-Command to run a Receive-Job command in each of the sessions in the $s variable and save the results in the $Results variable.
+# Use Invoke-Command to run a Receive-Job command in each of the sessions in the $s variable and save the results in the $results variable.
# The Receive-Job command must be run in each session because the jobs were run locally on each server.
-$results = Invoke-Command -Session $s -ScriptBlock {Receive-Job -Job $Using:j}
+$results = Invoke-Command -Session $s -ScriptBlock {ΓÇïReceive-Job -Name $('MyJob-' +$env:COMPUTERNAME)}
``` ```Output
-Server01
-Server02
-Server03
+3/22/2021 7:41:47 PM
+3/22/2021 7:41:47 PM
+3/22/2021 9:41:47 PM
``` This example shows how to get the results of background jobs run on three remote computers.
Unlike the previous example, using `Invoke-Command` to run the `Start-Job` comma
started three independent jobs on each of the three computers. As a result, the command returned three job objects representing three jobs run locally on three different computers.
-> [!NOTE]
-> In the last command, because `$j` is a local variable, the script block uses the **Using** scope
-> modifier to identify the `$j` variable. For more information about the **Using** scope modifier,
-> see [about_Remote_Variables](./About/about_Remote_Variables.md).
- ### Example 5: Access child jobs The `-Keep` parameter preserves the state of the aggregated streams of a job so that it
Microsoft.PowerShell.Utility Get Host (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Utility/Get-Host.md
--- external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 03/22/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-host?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-Host
features of the host program user interface, such as the text and background col
### Example 1: Get information about the PowerShell console host ```
-PS C:\> Get-Host
+Get-Host
+ Name : ConsoleHost Version : 2.0 InstanceId : e4e0ab54-cc5e-4261-9117-4081f20ce7a2
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace ```
-This command displays information about the Windows PowerShell console, which is the current host
-program for Windows PowerShell in this example. It includes the name of the host, the version of
-Windows PowerShell that is running in the host, and current culture and UI culture.
+This command displays information about the PowerShell console, which is the current host program
+for PowerShell in this example. It includes the name of the host, the version of PowerShell that is
+running in the host, and current culture and UI culture.
-The Version, UI, CurrentCulture, CurrentUICulture, PrivateData, and Runspace properties each contain
-an object with very useful properties. Later examples examine these properties.
+The **Version**, **UI**, **CurrentCulture**, **CurrentUICulture**, **PrivateData**, and **Runspace**
+properties each contain an object with other useful properties. Later examples examine these
+properties.
### Example 2: Resize the PowerShell window ```powershell
-PS C:\> $H = Get-Host
-PS C:\> $Win = $H.UI.RawUI.WindowSize
-PS C:\> $Win.Height = 10
-PS C:\> $Win.Width = 10
-PS C:\> $H.UI.RawUI.Set_WindowSize($Win)
+$H = Get-Host
+$Win = $H.UI.RawUI.WindowSize
+$Win.Height = 10
+$Win.Width = 10
+$H.UI.RawUI.Set_WindowSize($Win)
```
-This command resizes the Windows PowerShell window to 10 pixels by 10 pixels.
+This command resizes the Windows PowerShell window to 10 lines by 10 characters.
### Example 3: Get the PowerShell version for the host ```powershell
-PS C:\> (Get-Host).Version | Format-List -Property *
+(Get-Host).Version | Format-List -Property *
+ Major : 2 Minor : 0 Build : -1
This command gets detailed information about the version of Windows PowerShell r
You can view, but not change, these values. The Version property of `Get-Host` contains a **System.Version** object. This command uses a
-pipeline operator (|) to send the version object to the `Format-List` cmdlet. The `Format-List`
-command uses the *Property* parameter with a value of all (*) to display all of the properties and
-property values of the version object.
+pipeline operator (`|`) to send the version object to the `Format-List` cmdlet. The `Format-List`
+command uses the **Property** parameter with a value of all (`*`) to display all of the properties
+and property values of the version object.
### Example 4: Get the current culture for the host ```powershell
-PS C:\> (Get-Host).CurrentCulture | Format-List -Property *
+(Get-Host).CurrentCulture | Format-List -Property *
+ Parent : en LCID : 1033 KeyboardLayoutId : 1033
in the host. This is the same information that is returned by the `Get-Culture`
Similarly, the **CurrentUICulture** property returns the same object that `Get-UICulture` returns. The **CurrentCulture** property of the host object contains a **System.Globalization.CultureInfo**
-object. This command uses a pipeline operator (|) to send the **CultureInfo** object to the
-`Format-List` cmdlet. The `Format-List` command uses the *Property* parameter with a value of all
-(*) to display all of the properties and property values of the **CultureInfo** object.
+object. This command uses a pipeline operator (`|`) to send the **CultureInfo** object to the
+`Format-List` cmdlet. The `Format-List` command uses the **Property** parameter with a value of all
+(`*`) to display all of the properties and property values of the **CultureInfo** object.
### Example 5: Get the DateTimeFormat for the current culture ```powershell
-PS C:\> (Get-Host).CurrentCulture.DateTimeFormat | Format-List -Property *
+(Get-Host).CurrentCulture.DateTimeFormat | Format-List -Property *
+ AMDesignator : AM Calendar : System.Globalization.GregorianCalendar DateSeparator : /
display the property values of the object, use the `Format-List` cmdlet.
### Example 6: Get the RawUI property for the host ```
-PS C:\> (Get-Host).UI.RawUI | Format-List -Property *
+(Get-Host).UI.RawUI | Format-List -Property *
+ ForegroundColor : DarkYellow BackgroundColor : DarkBlue CursorPosition : 0,390
values, you can change the appearance of the host program.
### Example 7: Set the background color for the PowerShell console ```powershell
-PS C:\> (Get-Host).UI.RawUI.BackgroundColor = "Black"
-PS C:\> cls
+(Get-Host).UI.RawUI.BackgroundColor = "Black"
+cls
``` These commands change the background color of the Windows PowerShell console to black. The **cls**
command is an alias for the `Clear-Host` function, which clears the screen and c
screen to the new color. This change is effective only in the current session. To change the background color of the console
-for all sessions, add the command to your Windows PowerShell profile.
+for all sessions, add the command to your PowerShell profile.
### Example 8: Set the background color for error messages
-```
-PS C:\> $Host.PrivateData.ErrorBackgroundColor = "white"
+```powershell
+$Host.PrivateData.ErrorBackgroundColor = "white"
``` This command changes the background color of error messages to white.
interchangeably.
This command uses the **PrivateData** property of `$Host` as its ErrorBackgroundColor property. To see all of the properties of the object in the `$Host`.PrivateData property, type
-`$host.privatedata | format-list *`.
+`$host.PrivateData | format-list *`.
## PARAMETERS
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## INPUTS ### None+ You cannot pipe input to this cmdlet. ## OUTPUTS
For more information, see [about_Automatic_Variables](../Microsoft.PowerShell.Co
[Read-Host](Read-Host.md) [Write-Host](Write-Host.md)-
Microsoft.PowerShell.Core Receive Job (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/Receive-Job.md
external help file: System.Management.Automation.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Core Previously updated : 06/09/2017 Last updated : 03/22/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/receive-job?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Receive-Job
Running AppMgmt Application Management Server02
# Use the New-PSSession cmdlet to create three user-managed PSSessions on three servers, and save the sessions in the $s variable. $s = New-PSSession -ComputerName Server01, Server02, Server03 # Use Invoke-Command run a Start-Job command in each of the PSSessions in the $s variable.
-# The job outputs the ComputerName of each server.
+# The creates a new job with a custom name to each server
+# The job outputs the datetime from each server
# Save the job objects in the $j variable.
-$j = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {$env:COMPUTERNAME}}
+$j = Invoke-Command -Session $s -ScriptBlock {ΓÇïStart-Job -Name $('MyJob-' +$env:COMPUTERNAME) -ScriptBlock {(Get-Date).ToString()ΓÇï}ΓÇï}
# To confirm that these job objects are from the remote machines, run Get-Job to show no local jobs running.
-Get-Job
+Get-JobΓÇïΓÇï
``` ```Output
$j
``` ```Output
-Id Name State HasMoreData Location Command
-1 Job1 Completed True Localhost $env:COMPUTERNAME
-2 Job2 Completed True Localhost $env:COMPUTERNAME
-3 Job3 Completed True Localhost $env:COMPUTERNAME
+Id Name State HasMoreData Location Command
+-- ---- ----- ----------- -------- -------
+1 MyJob-Server01 Completed True Localhost (Get-Date).ToString()
+2 MyJob-Server02 Completed True Localhost (Get-Date).ToString()
+3 MyJob-Server03 Completed True Localhost (Get-Date).ToString()
``` ```powershell
-# Use Invoke-Command to run a Receive-Job command in each of the sessions in the $s variable and save the results in the $Results variable.
+# Use Invoke-Command to run a Receive-Job command in each of the sessions in the $s variable and save the results in the $results variable.
# The Receive-Job command must be run in each session because the jobs were run locally on each server.
-$results = Invoke-Command -Session $s -ScriptBlock {Receive-Job -Job $Using:j}
+$results = Invoke-Command -Session $s -ScriptBlock {ΓÇïReceive-Job -Name $('MyJob-' +$env:COMPUTERNAME)}
``` ```Output
-Server01
-Server02
-Server03
+3/22/2021 7:41:47 PM
+3/22/2021 7:41:47 PM
+3/22/2021 9:41:47 PM
``` This example shows how to get the results of background jobs run on three remote computers.
Unlike the previous example, using `Invoke-Command` to run the `Start-Job` comma
started three independent jobs on each of the three computers. As a result, the command returned three job objects representing three jobs run locally on three different computers.
-> [!NOTE]
-> In the last command, because `$j` is a local variable, the script block uses the **Using** scope
-> modifier to identify the `$j` variable. For more information about the **Using** scope modifier,
-> see [about_Remote_Variables](./About/about_Remote_Variables.md).
- ### Example 5: Access child jobs The `-Keep` parameter preserves the state of the aggregated streams of a job so that it
Microsoft.PowerShell.Utility Get Host (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Utility/Get-Host.md
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 03/22/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-host?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-Host
features of the host program user interface, such as the text and background col
### Example 1: Get information about the PowerShell console host ```
-PS C:\> Get-Host
+Get-Host
+ Name : ConsoleHost Version : 2.0 InstanceId : e4e0ab54-cc5e-4261-9117-4081f20ce7a2
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace ```
-This command displays information about the Windows PowerShell console, which is the current host
-program for Windows PowerShell in this example. It includes the name of the host, the version of
-Windows PowerShell that is running in the host, and current culture and UI culture.
+This command displays information about the PowerShell console, which is the current host program
+for PowerShell in this example. It includes the name of the host, the version of PowerShell that is
+running in the host, and current culture and UI culture.
-The Version, UI, CurrentCulture, CurrentUICulture, PrivateData, and Runspace properties each contain
-an object with very useful properties. Later examples examine these properties.
+The **Version**, **UI**, **CurrentCulture**, **CurrentUICulture**, **PrivateData**, and **Runspace**
+properties each contain an object with other useful properties. Later examples examine these
+properties.
### Example 2: Resize the PowerShell window ```powershell
-PS C:\> $H = Get-Host
-PS C:\> $Win = $H.UI.RawUI.WindowSize
-PS C:\> $Win.Height = 10
-PS C:\> $Win.Width = 10
-PS C:\> $H.UI.RawUI.Set_WindowSize($Win)
+$H = Get-Host
+$Win = $H.UI.RawUI.WindowSize
+$Win.Height = 10
+$Win.Width = 10
+$H.UI.RawUI.Set_WindowSize($Win)
```
-This command resizes the Windows PowerShell window to 10 pixels by 10 pixels.
+This command resizes the Windows PowerShell window to 10 lines by 10 characters.
### Example 3: Get the PowerShell version for the host ```powershell
-PS C:\> (Get-Host).Version | Format-List -Property *
+(Get-Host).Version | Format-List -Property *
+ Major : 2 Minor : 0 Build : -1
This command gets detailed information about the version of Windows PowerShell r
You can view, but not change, these values. The Version property of `Get-Host` contains a **System.Version** object. This command uses a
-pipeline operator (|) to send the version object to the `Format-List` cmdlet. The `Format-List`
-command uses the *Property* parameter with a value of all (*) to display all of the properties and
-property values of the version object.
+pipeline operator (`|`) to send the version object to the `Format-List` cmdlet. The `Format-List`
+command uses the **Property** parameter with a value of all (`*`) to display all of the properties
+and property values of the version object.
### Example 4: Get the current culture for the host ```powershell
-PS C:\> (Get-Host).CurrentCulture | Format-List -Property *
+(Get-Host).CurrentCulture | Format-List -Property *
+ Parent : en LCID : 1033 KeyboardLayoutId : 1033
in the host. This is the same information that is returned by the `Get-Culture`
Similarly, the **CurrentUICulture** property returns the same object that `Get-UICulture` returns. The **CurrentCulture** property of the host object contains a **System.Globalization.CultureInfo**
-object. This command uses a pipeline operator (|) to send the **CultureInfo** object to the
-`Format-List` cmdlet. The `Format-List` command uses the *Property* parameter with a value of all
-(*) to display all of the properties and property values of the **CultureInfo** object.
+object. This command uses a pipeline operator (`|`) to send the **CultureInfo** object to the
+`Format-List` cmdlet. The `Format-List` command uses the **Property** parameter with a value of all
+(`*`) to display all of the properties and property values of the **CultureInfo** object.
### Example 5: Get the DateTimeFormat for the current culture ```powershell
-PS C:\> (Get-Host).CurrentCulture.DateTimeFormat | Format-List -Property *
+(Get-Host).CurrentCulture.DateTimeFormat | Format-List -Property *
+ AMDesignator : AM Calendar : System.Globalization.GregorianCalendar DateSeparator : /
display the property values of the object, use the `Format-List` cmdlet.
### Example 6: Get the RawUI property for the host ```
-PS C:\> (Get-Host).UI.RawUI | Format-List -Property *
+(Get-Host).UI.RawUI | Format-List -Property *
+ ForegroundColor : DarkYellow BackgroundColor : DarkBlue CursorPosition : 0,390
values, you can change the appearance of the host program.
### Example 7: Set the background color for the PowerShell console ```powershell
-PS C:\> (Get-Host).UI.RawUI.BackgroundColor = "Black"
-PS C:\> cls
+(Get-Host).UI.RawUI.BackgroundColor = "Black"
+cls
``` These commands change the background color of the Windows PowerShell console to black. The **cls**
command is an alias for the `Clear-Host` function, which clears the screen and c
screen to the new color. This change is effective only in the current session. To change the background color of the console
-for all sessions, add the command to your Windows PowerShell profile.
+for all sessions, add the command to your PowerShell profile.
### Example 8: Set the background color for error messages
-```
-PS C:\> $Host.PrivateData.ErrorBackgroundColor = "white"
+```powershell
+$Host.PrivateData.ErrorBackgroundColor = "white"
``` This command changes the background color of error messages to white.
interchangeably.
This command uses the **PrivateData** property of `$Host` as its ErrorBackgroundColor property. To see all of the properties of the object in the `$Host`.PrivateData property, type
-`$host.privatedata | format-list *`.
+`$host.PrivateData | format-list *`.
## PARAMETERS
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## INPUTS ### None+ You cannot pipe input to this cmdlet. ## OUTPUTS
For more information, see [about_Automatic_Variables](../Microsoft.PowerShell.Co
[Read-Host](Read-Host.md) [Write-Host](Write-Host.md)-