Skip to content
dscbot edited this page Nov 11, 2023 · 1 revision

xProcessSet

Parameters

Parameter Attribute DataType Description Allowed Values
Path Required System.String[] The file paths to the executables of the processes to start or stop. Only the names of the
files may be specified if they are all accessible through the environment path. Relative
paths are not supported.
Ensure Write System.String Specifies whether or not the processes should exist.

To start processes, set this property to Present. To stop processes, set this property to Absent. | Present, Absent | | Credential | Write | System.Management.Automation.PSCredential | The credential of the user account to start the processes under. | | | StandardOutputPath | Write | System.String | The file path to write the standard output to. Any existing file at this path will be overwritten.This property cannot be specified at the same time as Credential when running the processes as a local user. | | | StandardErrorPath | Write | System.String | The file path to write the standard error output to. Any existing file at this path will be overwritten. | | | StandardInputPath | Write | System.String | The file path to get standard input from. This property cannot be specified at the same time as Credential when running the processes as a local user. | | | WorkingDirectory | Write | System.String | The file path to use as the working directory for the processes. Any existing file at this path will be overwritten. This property cannot be specified at the same time as Credential when running the processes as a local user. | |

Description

Provides a mechanism to configure and manage multiple xWindowsProcess resources on a target node.

Examples

Example 1

#Requires -Module xPSDesiredStateConfiguration

<#
    .DESCRIPTION
        Configuration that starts one or more processes, without any arguments.

    .PARAMETER Path
        One or more paths to the executable to start a process for.

    .EXAMPLE
        xProcessSet_StartProcess_Config -Path @('C:\Windows\System32\cmd.exe', 'C:\TestPath\TestProcess.exe')

        Compiles a configuration that starts the processes with the executable
        with no arguments at the file paths 'C:\Windows\cmd.exe' and
        'C:\TestPath\TestProcess.exe'.

    .EXAMPLE
        Start-AzureRmAutomationDscCompilationJob -ResourceGroupName '<resource-group>' -AutomationAccountName '<automation-account>' -ConfigurationName 'xProcessSet_StartProcessConfig' -Parameters @{ Path = @('C:\Windows\System32\cmd.exe', 'C:\TestPath\TestProcess.exe') }

        Compiles a configuration in Azure Automation that starts the processes
        with the executable with no arguments at the file paths 'C:\Windows\cmd.exe'
        and 'C:\TestPath\TestProcess.exe'.

        Replace the <resource-group> and <automation-account> with correct values.
#>
Configuration xProcessSet_StartProcess_Config
{
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory = $true)]
        [System.String[]]
        $Path
    )

    Import-DscResource -ModuleName xPSDesiredStateConfiguration

    Node localhost
    {
        xProcessSet StartProcess
        {
            Path = $Path
            Ensure = 'Present'
        }
    }
}

Example 2

#Requires -Module xPSDesiredStateConfiguration

<#
    .DESCRIPTION
        Configuration that stop one or more processes. Logs any output to the
        path 'C:\Output.log'.

    .PARAMETER Path
        One or more paths to the executable to stop the process for.

    .EXAMPLE
        xProcessSet_StopProcess_Config -Path @('C:\Windows\System32\cmd.exe', 'C:\TestPath\TestProcess.exe')

        Compiles a configuration that stops the processes with the executable
        at the file paths 'C:\Windows\cmd.exe' and 'C:\TestPath\TestProcess.exe'.

    .EXAMPLE
        Start-AzureRmAutomationDscCompilationJob -ResourceGroupName '<resource-group>' -AutomationAccountName '<automation-account>' -ConfigurationName 'xProcessSet_StopProcessConfig' -Parameters @{ Path = @('C:\Windows\System32\cmd.exe', 'C:\TestPath\TestProcess.exe') }

        Compiles a configuration in Azure Automation that stop the processes
        with the executable at the file paths 'C:\Windows\cmd.exe'
        and 'C:\TestPath\TestProcess.exe'.

        Replace the <resource-group> and <automation-account> with correct values.
#>
Configuration xProcessSet_StopProcess_Config
{
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory = $true)]
        [System.String[]]
        $Path
    )

    Import-DscResource -ModuleName xPSDesiredStateConfiguration

    Node localhost
    {
        xProcessSet StartProcess
        {
            Path = $Path
            Ensure = 'Absent'
            StandardOutputPath = 'C:\Output.log'
        }
    }
}