Category Archives: Write

Write-Progress

NAME
    Write-Progress

SYNOPSIS
    Displays a progress bar within a Windows PowerShell command window.

SYNTAX
    Write-Progress [-Activity] <string> [-Status] <string> [[-Id] <int>] [-Completed] [-CurrentOperation <string>] [-ParentId <int>] [-PercentComplete <int>] [-SecondsRemaining <int>] [-SourceId <int>] [<CommonParameters>]

DESCRIPTION
    The Write-Progress cmdlet displays a progress bar in a Windows PowerShell command window that depicts the status of a running command or script. You can select the indicators that the bar reflects and the text that appears above and below the progress bar.

PARAMETERS
    -Activity <string>
        Specifies the first line of text in the heading above the status bar. This text describes the activity whose progress is being reported.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Completed [<SwitchParameter>]
        Indicates whether the progress bar is visible. If this parameter is omitted, Write-Progress displays progress information.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -CurrentOperation <string>
        Specifies the line of text below the progress bar. This text describes the operation that is currently taking place.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Id <int>
        Specifies an ID that distinguishes each progress bar from the others. Use this parameter when you are creating more than one progress bar in a single command. If the progress bars do not have different IDs, they are superimposed instead of being displayed in a series.

        Required?                    false
        Position?                    3
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -ParentId <int>
        Identifies the parent activity of the current activity. Use the value -1 if the current activity has no parent activity.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -PercentComplete <int>
        Specifies the percentage of the activity that is completed. Use the value -1 if the percentage complete is unknown or not applicable.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -SecondsRemaining <int>
        Specifies the projected number of seconds remaining until the activity is completed. Use the value -1 if the number of seconds remaining is unknown or not applicable.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -SourceId <int>
        Identifies the source of the record.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Status <string>
        Specifies the second line of text in the heading above the status bar. This text describes current state of the activity.

        Required?                    true
        Position?                    2
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    None
        You cannot pipe input to this cmdlet.

OUTPUTS
    None
        Write-Progress does not generate any output.

NOTES

        If the progress bar does not appear, check the value of the $ProgressPreference Variable. If the value is set to SilentlyContinue, the progress bar is not displayed. For more information about Windows PowerShell preferences, see about_preference_variables.

        The parameters of the cmdlet correspond to the properties of the ProgressRecord class (System.Management.Automation.ProgressRecord). For more information, see the ProgressRecord topic in the Windows PowerShell Software Development Kit (SDK).

    ————————– EXAMPLE 1 ————————–

    C:\PS>for ($i = 1; $i -lt 101; $i++ )
    {for ($j=0;$j -lt 10000;$j++) {} Write-Progress -Activity “Search in Progress” -Status “% Complete:” -PercentComplete $i;}

    Description
    ———–
    This command displays the progress of two nested For loops. The first loop counts to 100. For each increment of that loop, the second loop counts to 10,000.
    The Write-Progress command includes a status bar heading (“activity”), a status line, and the Variable $i (the counter in the For loop), which indicates the relative completeness of the task.

    ————————– EXAMPLE 2 ————————–

    C:\PS>for($i = 1; $i -lt 101; $i++ ) {Write-Progress -Activity Updating -Status progress-> -PercentComplete $i -CurrentOperation OuterLoop} for($i = 1; $i -lt 101; $i++ ) {Write-Progress -Activity Updating -Status progress -PercentComplete $i -Id 1 -CurrentOperation InnerLoop}

    Updating
     progress ->
     [oooooooooooooooooo                                                 ]

     OutsideLoop

    Updating
     progress
     [oooooooooooooooooo                                                    ]

     InnerLoop

    Description
    ———–
    This example displays the progress of two nested For loops, each of which is represented by a progress bar.

    The Write-Progress command for the second progress bar includes the Id parameter that distinguishes it from the first progress bar. Without the Id parameter, the progress bars would be superimposed on each other instead of being displayed one below the other.

    ————————– EXAMPLE 3 ————————–

    C:\PS>$events = Get-Eventlog -logname system

    C:\PS> $events | ForEach-Object -begin {clear-host;$i=0;$out=””} `
    -process {if($_.message -like “*bios*”) {$out=$out + $_.Message};
    $i = $i+1;`
    Write-Progress -Activity “Searching Events” `
    -Status “Progress:” -PercentComplete ($i/$events.count*100)} `
    -end {$out}

    Description
    ———–
    This command displays the progress of a command to find the string “bios” in the System event log.

    In the first line of the command, the Get-EventLog cmdlet gets the events in the System log and stores them in the $events Variable.

    In the second line, the events are piped to the ForEach-Object cmdlet. Before processing begins, the Clear-Host cmdlet is used to clear the screen, the $i counter Variable is set to zero, and the $out output Variable is set to the empty string.

    In the third line, which is the Process script block of the ForEach-Object cmdlet, the cmdlet searches the message property of each incoming object for “bios”. If the string is found, the message is added to $out.

    In the fourth line, the $i counter Variable is incremented to record that another event has been examined.

    The fifth line uses the Write-Progress cmdlet with values for the Activity and Status text fields that create the first and second lines of the progress bar heading, respectively. The PercentComplete parameter value is calculated by dividing the number of events that have been processed ($i) by the total number of events retrieved ($events.count) and then multiplying that result by 100.

    In the last line, the End parameter of the ForEach-Object cmdlet is used to display the messages that are stored in the $out Variable.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113428
    Write-Verbose
    Write-Error
    Write-Host
    Write-Debug
    Write-Output
    Write-Warning

Write-Verbose

NAME
    Write-Verbose

SYNOPSIS
    Writes text to the verbose message stream.

SYNTAX
    Write-Verbose [-Message] <string> [<CommonParameters>]

DESCRIPTION
    The Write-Verbose cmdlet writes text to the verbose message stream in Windows PowerShell. Typically, the verbose message stream is used to deliver information about command processing that is used for debugging a command.

    By default, the verbose message stream is not displayed, but you can display it by changing the value of the $VerbosePreference Variable or using the Verbose common parameter in any command.

PARAMETERS
    -Message <string>
        Specifies the message to display. This parameter is required. You can also pipe a message string to Verbose-Message.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe a string that contains the message to Write-Verbose.

OUTPUTS
    None
        Write-Verbose writes only to the verbose message stream.

NOTES

    ————————– EXAMPLE 1 ————————–

    C:\PS>Write-Verbose -Message “Searching the Application Event Log.”

    C:\PS> Write-Verbose -Message “Searching the Application Event Log.” -Verbose

    Description
    ———–
    These commands use the Write-Verbose cmdlet to display a status message. By default, the message is not displayed.

    The second command uses the Verbose common parameter, which displays any verbose messages, regardless of the value of the $VerbosePreference Variable.

    ————————– EXAMPLE 2 ————————–

    C:\PS>$VerbosePreference = “Continue”

    C:\PS> Write-Verbose “Copying file $filename”

    Description
    ———–
    These commands use the Write-Verbose cmdlet to display a status message. By default, the message is not displayed.

    The first command assigns a value of “Continue” to the $VerbosePreference preference Variable. The default value, “SilentlyContinue”, suppresses verbose messages.

    The second command writes a verbose message.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113429
    Write-Error
    Write-Warning
    about_preference_variables

Write-Warning

NAME
    Write-Warning

SYNOPSIS
    Writes a warning message.

SYNTAX
    Write-Warning [-Message] <string> [<CommonParameters>]

DESCRIPTION
    The Write-Warning cmdlet writes a warning message to the Windows PowerShell host. The response to the warning depends on the value of the user’s $WarningPreference Variable and the use of the WarningAction common parameter.

PARAMETERS
    -Message <string>
        Specifies the warning message.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe a string that contains the warning to Write-Warning.

OUTPUTS
    None
        Write-Warning writes only to the warning stream. It does not generate any other output.

NOTES

        The default value for the $WarningPreference Variable is “Continue”, which displays the warning and then continues executing the command. To determine valid values for a preference Variable such as $WarningPreference, set it to a string of random characters, such as “abc”. The resulting error message will list the valid values.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Write-Warning “This is only a test warning.”

    Description
    ———–
    This command displays the message “WARNING: This is only a test warning.”

    ————————– EXAMPLE 2 ————————–

    C:\PS>$w = “This is only a test warning.”

    C:\PS> $w | Write-Warning

    Description
    ———–
    This example shows that you can use a pipeline operator (|) to send a string to Write-Warning. You can save the string in a Variable, as shown in this command, or pipe the string directly to Write-Warning.

    ————————– EXAMPLE 3 ————————–

    C:\PS>$warningpreference

    Continue

    C:\PS> Write-Warning “This is only a test warning.”
    This is only a test warning.

    C:\PS> $warningpreference = “SilentlyContinue”

    C:\PS> Write-Warning “This is only a test warning.”
    C:\PS>

    C:\PS> $warningpreference = “Stop”

    C:\PS> Write-Warning “This is only a test warning.”
    WARNING: This is only a test message.
    Write-Warning : Command execution stopped because the shell Variable “WarningPreference” is set to Stop.
    At line:1 char:14
    + Write-Warning <<<< “This is only a test message.”

    Description
    ———–
    This example shows the effect of the value of the $WarningPreference Variable on a Write-Warning command.

    The first command displays the default value of the $WarningPreference Variable, which is “Continue”. As a result, when you write a warning, the warning message is displayed and execution continues.

    When you change the value of the $WarningPreference Variable, the effect of the Write-Warning command changes again. A value of “SilentlyContinue” suppresses the warning. A value of “Stop” displays the warning and then stops execution of the command.

    For more information about the $WarningPreference Variable, see about_preference_variables.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Write-Warning “This is only a test warning.” -WarningAction Inquire

    WARNING: This is only a test warning.

    Confirm
    Continue with this operation?
    [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is “Y”):

    Description
    ———–
    This example shows the effect of the WarningAction common parameter on a Write-Warning command. You can use the WarningAction common parameter with any cmdlet to determine how Windows PowerShell responds to warnings resulting from that command. The WarningAction common parameter overrides the value of the $WarningPreference only for that particular command.

    This command uses the Write-Warning cmdlet to display a warning. The WarningAction common parameter with a value of “Inquire” directs the system to prompt the user when the command displays a warning.

    For more information about the WarningAction common parameter, see about_CommonParameters.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113430
    about_preference_variables
    about_CommonParameters
    Write-Debug
    Write-Error
    Write-Host
    Write-Output
    Write-Progress
    Write-Verbose

Write-Debug

NAME
    Write-Debug

SYNOPSIS
    Writes a debug message to the console.

SYNTAX
    Write-Debug [-Message] <string> [<CommonParameters>]

DESCRIPTION
    The Write-Debug cmdlet writes debug messages to the console from a script or command.

    By default, debug messages are not displayed in the console, but you can display them by using the Debug parameter or the $DebugPreference Variable.

PARAMETERS
    -Message <string>
        Specifies the debug message to send to the console.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe a string that contains a debug message to Write-Debug.

OUTPUTS
    None
        Write-Debug writes only to the debug stream. It does not return any output.

NOTES

    ————————– EXAMPLE 1 ————————–

    C:\PS>Write-Debug “Cannot open file.”

    Description
    ———–
    This command writes a debug message. Because the value of $DebugPreference is “SilentlyContinue”, the message is not displayed in the console.

    ————————– EXAMPLE 2 ————————–

    C:\PS>$DebugPreference

    SilentlyContinue

    C:\PS> Write-Debug “Cannot open file.”
    C:\PS>

    C:\PS> Write-Debug “Cannot open file.” -Debug
    DEBUG: Cannot open file.

    Description
    ———–
    This example shows how to use the Debug common parameter to override the value of the $DebugPreference Variable for a particular command.

    The first command displays the value of the $DebugPreference Variable, which is “SilentlyContinue”, the default.

    The second command writes a debug message but, because of the value of $DebugPreference, the message does not appear.

    The third command writes a debug message. It uses the Debug common parameter to override the value of $DebugPreference and to display the debug messages resulting from this command.

    As a result, even though the value of $DebugPreference is “SilentlyContinue”, the debug message appears.

    For more information about the Debug common parameter, see about_CommonParameters.

    ————————– EXAMPLE 3 ————————–

    C:\PS>$DebugPreference

    SilentlyContinue

    C:\PS> Write-Debug “Cannot open file.”
    C:\PS>

    C:\PS> $DebugPreference = “Continue”

    C:\PS> Write-Debug “Cannot open file.”
    DEBUG: Cannot open file.

    Description
    ———–
    This command shows the effect of changing the value of the $DebugPreference Variable on the display of debug messages.

    The first command displays the value of the $DebugPreference Variable, which is “SilentlyContinue”, the default.

    The second command writes a debug message but, because of the value of $DebugPreference, the message does not appear.

    The third command assigns a value of “Continue” to the $DebugPreference Variable.

    The fourth command writes a debug message, which appears on the console.

    For more information about $DebugPreference, see about_preference_variables.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113424
    Write-Verbose
    Write-Error
    Write-Host
    Write-Progress
    Write-Output
    Write-Warning

Write-Error

NAME
    Write-Error

SYNOPSIS
    Writes an object to the error stream.

SYNTAX
    Write-Error -ErrorRecord <ErrorRecord> [-CategoryActivity <string>] [-CategoryReason <string>] [-CategoryTargetName <string>] [-CategoryTargetType <string>] [-RecommendedAction <string>] [<CommonParameters>]

    Write-Error [-Message] <string> [-Category {NotSpecified | OpenError | CloseError | DeviceError | DeadlockDetected | InvalidArgument | InvalidData | InvalidOperation | InvalidResult | InvalidType | MetadataError | NotImplemented | NotInstalled | ObjectNotFound | OperationStopped | OperationTimeout | SyntaxError | ParserError | PermissionDenied | ResourceBusy | ResourceExists | ResourceUnavailable | ReadError | WriteError | FromStdErr | SecurityError}] [-ErrorId <string>] [-TargetObject <Object>] [-CategoryActivity <string>] [-CategoryReason <string>] [-CategoryTargetName <string>] [-CategoryTargetType <string>] [-RecommendedAction <string>] [<CommonParameters>]

    Write-Error -Exception <Exception> [-Category {NotSpecified | OpenError | CloseError | DeviceError | DeadlockDetected | InvalidArgument | InvalidData | InvalidOperation | InvalidResult | InvalidType | MetadataError | NotImplemented | NotInstalled | ObjectNotFound | OperationStopped | OperationTimeout | SyntaxError | ParserError | PermissionDenied | ResourceBusy | ResourceExists | ResourceUnavailable | ReadError | WriteError | FromStdErr | SecurityError}] [-ErrorId <string>] [-Message <string>] [-TargetObject <Object>] [-CategoryActivity <string>] [-CategoryReason <string>] [-CategoryTargetName <string>] [-CategoryTargetType <string>] [-RecommendedAction <string>] [<CommonParameters>]

DESCRIPTION
    The Write-Error cmdlet writes an error to the Windows PowerShell error stream. By default, errors are sent to the host program to be displayed, along with output.

    You can write an error by submitting an error message string, an ErrorRecord object, or an Exception object. Use the other parameters of Write-Error to populate the error record.

PARAMETERS
    -Category <ErrorCategory>
        Specifies the category of the error. The default value is NotSpecified.

        For information about the error categories, see “ErrorCategory Enumeration” in the MSDN (Microsoft Developer Network) library at http://go.microsoft.com/fwlink/?LinkId=143600.

        Required?                    false
        Position?                    named
        Default value                NotSpecified
        Accept pipeline input?     false
        Accept wildcard characters? false

    -CategoryActivity <string>
        Describes the action that caused the error.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -CategoryReason <string>
        Explains how or why the activity caused the error.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -CategoryTargetName <string>
        Specifies the name of the object that was being processed when the error occurred.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -CategoryTargetType <string>
        Specifies the .NET type of the object that was being processed when the error occurred.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -ErrorId <string>
        Specifies an ID string to identify the error. The string should be unique to the error.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -ErrorRecord <ErrorRecord>
        Specifies an error record object that includes properties that describe the error.

        To get an error record object, use the New-Object cmdlet or take an error record object from the array in the $Error automatic Variable.

        Required?                    true
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Exception <Exception>
        Specifies an exception that represents the error.

        You can use an exception instead of specifying message text or an exception record.

        Required?                    true
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Message <string>
        Specifies the message text of the error. If the text includes spaces or special characters, enclose it in quotation marks. You can also pipe a message string to Write-Error.

        Required?                    true
        Position?                    1
        Default value                None
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    -RecommendedAction <string>
        Describes the action that the user should take to resolve or prevent the error.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -TargetObject <Object>
        Specifies the object that was being processed when the error occurred. Enter the object (such as a string), a Variable that contains the object, or a command that gets the object.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe a string that contains an error message to Write-Error.

OUTPUTS
    Error object
        Write-Error writes only to the error stream. It does not return any objects.

NOTES

    ————————– EXAMPLE 1 ————————–

    C:\PS>Get-ChildItem | ForEach-Object { if ($_.gettype().tostring() -eq “Microsoft.Win32.RegistryKey”) {Write-Error “Out-of-band object” -ErrorId B1 -TargetObject $_ } else {$_ } }

    Description
    ———–
    This command writes an error when the Get-ChildItem cmdlet returns a Microsoft.Win32.RegistryKey object, such as the objects in the HKLM: or HKCU drives of the Windows PowerShell Registry provider.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Write-Error “Access denied.”

    Description
    ———–
    This command writes an “Access denied” error. The command uses the Message parameter to specify the message, but omits the optional Message parameter name.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Write-Error -Message “Error: Too many input values.” -Category InvalidArgument

    Description
    ———–
    This command writes a error and specifies an error category.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113425
    Write-Debug
    Write-Verbose
    Write-Output
    Write-Host
    Write-Progress
    Write-Warning

Write-EventLog

NAME
    Write-EventLog

SYNOPSIS
    Writes an event to an event log.

SYNTAX
    Write-EventLog [-LogName] <string> [-Source] <string> [-EventId] <int> [-Message] <string> [[-EntryType] {Error | Warning | Information | SuccessAudit | FailureAudit}] [-Category <Int16>] [-ComputerName <string>] [-RawData <Byte[]>] [<CommonParameters>]

DESCRIPTION
    The Write-EventLog cmdlet writes an event to an event log.

    To write an event to an event log, the event log must exist on the computer and the source must be registered for the event log.

    The cmdlets that contain the EventLog noun (the EventLog cmdlets) work only on classic event logs. To get events from logs that use the Windows Event Log technology in Windows Vista and later versions of Windows, use Get-WinEvent.

PARAMETERS
    -Category <Int16>
        Specifies a task category for the event. Enter an integer that is associated with the strings in the category message file for the event log.

        Required?                    false
        Position?                    named
        Default value                1
        Accept pipeline input?     false
        Accept wildcard characters? false

    -ComputerName <string>
        Specifies a remote computer. The default is the local computer.

        Type the NetBIOS name, an Internet Protocol (IP) address, or a fully qualified domain name of a remote computer.

        This parameter does not rely on Windows PowerShell remoting. You can use the ComputerName parameter of Get-EventLog even if your computer is not configured to run remote commands.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -EntryType <EventLogEntryType>
        Specifies the entry type of the event. Valid values are Error, Warning, Information, SuccessAudit, and FailureAudit. The default value is Information.

        For a description of the values, see System.Diagnostics.EventLogEntryType in the MSDN (Microsoft Developer Network) library at http://go.microsoft.com/fwlink/?LinkId=143599.

        Required?                    false
        Position?                    4
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -EventId <int>
        Specifies the event identifier. This parameter is required.

        Required?                    true
        Position?                    3
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -LogName <string>
        Specifies the name of the log to which the event is written. Enter the log name (the value of the Log property, not the LogDisplayName). Wildcard characters are not permitted. This parameter is required.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Message <string>
        Specifies the event message. This parameter is required.

        Required?                    true
        Position?                    5
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -RawData <Byte[]>
        Specifies the binary data that is associated with the event, in bytes.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Source <string>
        Specifies the event source, which is typically the name of the application that is writing the event to the log.

        Required?                    true
        Position?                    2
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    None
        You cannot pipe input to this cmdlet.

OUTPUTS
    System.Diagnostics.EventLogEntry
        Write-EventLog returns objects that represents the events in the logs.

NOTES

        To use Write-EventLog on Windows Vista and later versions of Windows, start Windows PowerShell with the “Run as administrator” option.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Write-EventLog -LogName Application -Source MyApp -EventId 3001 -EntryType Information -Message “MyApp added a user-requested feature to the display.” -Category 1 -RawData 10,20

    Description
    ———–
    This command writes an event from the MyApp source to the Application event log.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Write-EventLog -ComputerName Server01 -LogName Application -Source MyApp -EventId 3001 -Message “MyApp added a user-requested feature to the display.”

    Description
    ———–
    This command writes an event from the MyApp source to the Application event log on the Server01 remote computer.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=135281
    Clear-EventLog
    Get-EventLog
    Limit-EventLog
    New-EventLog
    Remove-EventLog
    Show-EventLog
    Write-EventLog
    Get-WinEvent

Write-Host

NAME
    Write-Host

SYNOPSIS
    Writes customized output to a host.

SYNTAX
    Write-Host [[-Object] <Object>] [-BackgroundColor {Black | DarkBlue | DarkGreen | DarkCyan | DarkRed | DarkMagenta | DarkYellow | Gray | DarkGray | Blue | Green | Cyan | Red | Magenta | Yellow | White}] [-ForegroundColor {Black | DarkBlue | DarkGreen | DarkCyan | DarkRed | DarkMagenta | DarkYellow | Gray | DarkGray | Blue | Green | Cyan | Red | Magenta | Yellow | White}] [-NoNewline] [-Separator <Object>] [<CommonParameters>]

DESCRIPTION
    The Write-Host cmdlet customizes output. You can specify the color of text by using the ForegroundColor parameter, and you can specify the background color by using the BackgroundColor parameter. The Separator parameter lets you specify a string to use to separate displayed objects. The particular result depends on the program that is hosting Windows PowerShell.

PARAMETERS
    -BackgroundColor <ConsoleColor>
        Specifies the background color. There is no default.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -ForegroundColor <ConsoleColor>
        Specifies the text color. There is no default.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -NoNewline [<SwitchParameter>]
        Specifies that the content displayed in the console does not end with a newline character.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Object <Object>
        Objects to display in the console.

        Required?                    false
        Position?                    1
        Default value                None
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    -Separator <Object>
        String to the output between objects displayed on the console.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.Object
        You can pipe objects to be written to the host.

OUTPUTS
    None
        Write-Host sends the objects to the host. It does not return any objects. However, the host might display the objects that Write-Host sends to it.

NOTES

    ————————– EXAMPLE 1 ————————–

    C:\PS>Write-Host “no newline test ” -NoNewline

    no newline test C:\PS>

    Description
    ———–
    This command displays the input to the console, but because of the NoNewline parameter, the output is followed directly by the prompt.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Write-Host (2,4,6,8,10,12) -Separator “, +2= ”

    2, +2= 4, +2= 6, +2= 8, +2= 10, +2= 12

    Description
    ———–
    This command displays the even numbers from 2 through 12. The Separator parameter is used to add the string , +2= (comma, space, +, 2, =, space).

    ————————– EXAMPLE 3 ————————–

    C:\PS>Write-Host (2,4,6,8,10,12) -Separator “, -> ” -ForegroundColor DarkGreen -BackgroundColor white

    Description
    ———–
    This command displays the even numbers from 2 through 12. It uses the ForegroundColor parameter to output dark green text and the BackgroundColor parameter to display a white background.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Write-Host “Red on white text.” -ForegroundColor red -BackgroundColor white

    Red on white text.

    Description
    ———–
    This command displays the string “Red on white text.” The text is red, as defined by the ForegroundColor parameter. The background is white, as defined by the BackgroundColor parameter.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113426
    Write-Verbose
    Write-Error
    Write-Progress
    Write-Debug
    Write-Output
    Write-Warning
    Out-Host

Write-Output

NAME
    Write-Output

SYNOPSIS
    Sends the specified objects to the next command in the pipeline. If the command is the last command in the pipeline, the objects are displayed in the console.

SYNTAX
    Write-Output [-InputObject] <PSObject[]> [<CommonParameters>]

DESCRIPTION
    The Write-Output cmdlet sends the specified object down the pipeline to the next command. If the command is the last command in the pipeline, the object is displayed in the console.

    Write-Output sends objects down the primary pipeline, also known as the “output stream” or the “success pipeline.” To send error objects down the error pipeline, use Write-Error.

    This cmdlet is typically used in scripts to display strings and other objects on the console. However, because the default behavior is to display the objects at the end of a pipeline, it is generally not necessary to use the cmdlet. For example, “Get-Process | Write-Output” is equivalent to “Get-Process“.

PARAMETERS
    -InputObject <PSObject[]>
        Specifies the objects to send down the pipeline. Enter a Variable that contains the objects, or type a command or expression that gets the objects.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.Management.Automation.PSObject
        You can pipe objects to Write-Output.

OUTPUTS
    System.Management.Automation.PSObject
        Write-Output returns the objects that are submitted as input.

NOTES

    ————————– EXAMPLE 1 ————————–

    C:\PS>$p = Get-Process

    c:\PS> Write-Output $p

    c:\PS> $p

    Description
    ———–
    These commands get objects representing the processes running on the computer and display the objects on the console.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Write-Output “test output” | Get-Member

    Description
    ———–
    This command pipes the “test output” string to the Get-Member cmdlet, which displays the members of the String class, demonstrating that the string was passed along the pipeline.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113427
    Write-Debug
    Write-Verbose
    Write-Error
    Write-Progress
    Write-Host
    Write-Warning
    Tee-Object