Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Name

Start-JS7ExecutableFile

SYNOPSIS

Starts an executable file in a Windows OS with parameters optionally for a different user account.

SYNTAX

Start-JS7ExecutableFile [-Path] <String> [[-Argumentlist] <String>] [[-TargetName] <String>] [-NoStandardOutput] [-NoStandardError] [-NoLoadUserProfile] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

Runs the specified executable file in the context of a different user account for a Windows OS.
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.

* An exit code is not reliably reported if the cmdlet is used from an unprivileged account
to start a process for a different user

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) etc..

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

Argumentlist

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

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

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?true (ByPropertyName)
Accept wildcard characters?false

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 valueFalse
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

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 valueFalse
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

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 valueFalse
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

WhatIf

-WhatIf <SwitchParameter>

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

Confirm

-Confirm <SwitchParameter>

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

about_JS7

EXAMPLES

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

PS > $process = Start-JS7ExecutableFile -Path 'c:/tmp/powershell/sample_script.cmd' -TargetName 'run_as_ap'

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 --------------------------

PS > $process = Start-JS7ExecutableFile -Path 'c:/tmp/powershell/sample_script.cmd' -TargetName 'run_as_ap' -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.