Skip to end of metadata
Go to start of metadata

NAME

Start-JobSchedulerExecutableFile

SYNOPSIS

Starts the specified executable file with parameters optionally for a different user account.

SYNTAX

Start-JobSchedulerExecutableFile -Path <String> [-Argumentlist <String>] [-TargetName <String>] [-NoStandardOutpu
t] -NoStandardError -NoLoadUserProfile <CommonParameters>

DESCRIPTION

Runs the specified executable file in the context of a different user account.
The cmdlet reads credentials from the Windows Credential Manager, i.e. credentials
that have previously been added by the Windows command "cmdkey" or any other credential management tools.
Credentials are indicated by their "target name" which represents the identifier by which
credentials are retrieved.

By default a user profile is considered. The -NoLoadUserProfile parameter prevents using a profile.

The cmdlet returns a System.Diagnostics.Process object that includes additional properties:

  • By default
    • output to stdout is available with the "StandardOutputContent" property.
    • output to stderr is available with the "StandardErrorContent" property.
  • With the parameters -NoStandardOutput and -NoStandardError respectively being used
    • output to stdout is available from a temporary file that is indicated with the "StandardOutputFile" property.
    • output to stderr is available from a temporary file that is indicated with the "StandardErrorFile" property.

PARAMETERS

Path

-Path <String>
Specifies the full path and name of the executable file to be started. Executable files includes binary files (.com
, .exe)
and command scripts (.cmd, .bat).

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

Argumentlist

-Argumentlist <String>
Specifies the arguments for starting the executable file.

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

TargetName

-TargetName <String>
Specifies the target name for credentials that have been added prior to execution of the file.

Target names for credentials can be added e.g. by use of the "cmdkey" command with the account that JobScheduler is
operated for:

C:\> cmdkey /add:run_as_ap /user:ap /pass:ap

The command adds credentials for the account "ap" with password "ap" and specifies the target name "run_as_ap".
In addition to built-in Windows commands a vast number of tools is available for credentials management.

Using the target name "run_as_ap" allows to run the executable file for the specified user account.

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

NoStandardOutput

-NoStandardOutput <SwitchParameter>
Specifies that the output of the executable file is not returned with the resulting process object.
Instead the name of a temporary file is returned.

The resulting process object includes the "StandardOutputFile" property
that indicates the temporary file that contains the output to stdout.

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

NoStandardError

-NoStandardError <SwitchParameter>
Specifies that the output of the executable file is not returned with the resulting process object.
Instead the name of a temporary file is returned.

The resulting process object includes the "StandardErrorFile" property
that indicates the temporary file that contains the output to stderr.

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

NoLoadUserProfile

-NoLoadUserProfile <SwitchParameter>
Specifies that the profile of the user account that the executable file is running for should not be executed.
This includes that environment variables at user level are not available for the executable file.

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

EXAMPLES

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$process = Start-JobSchedulerExecutableFile -Path 'c:/tmp/powershell/sample_script.cmd' -TargetName 'localhost'

Runs the command script for the account that is specified with the credentials identified by the target name.

The resulting process object includes the properties

  • $process.StandardOutputContent
  • $process.StandardErrorContent

that contain the output that is created to stdout and stderr.

-------------------------- EXAMPLE 2 --------------------------

C:\PS>$process = Start-JobSchedulerExecutableFile -Path 'c:/tmp/powershell/sample_script.cmd' -TargetName 'localhost' -
NoStandardOutput -NoStandardError

Runs the command script for the account that is specified with the credentials identified by the target name.

The resulting process object includes the properties

  • $process.StandardOutputFile
  • $process.StandardErrorFile

that indicate temporary files that contain the output that is created to stdout and stderr.

  • No labels
Write a comment…