< Back

Invoke-ExternalCommand

Mon Jan 13, 2020 6:58 pm

NAME Invoke-ExternalCommand



SYNOPSIS

Invokes (executes) an external executable via the command-line





SYNTAX

Invoke-ExternalCommand [-Command] <String> [-Arguments] <String[]> [[-PipeOutNull] <Boolean>] [<CommonParameters>]





DESCRIPTION

Invokes (executes) an external executable via the command-line





PARAMETERS

-Command <String>

The command-line or windows executable you wish to execute. Should be a full path to the file if the

executable is not in the PATH.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Arguments <String[]>

An array of parameters to the passed on the command-line



Required? true

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-PipeOutNull <Boolean>

Windows executables are started in thier own process, so we stop this by piping the output to Out-Null;



Required? false

Position? 3

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



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



PS C:\\>Invoke-ExternalCommand -Command bcp.exe -Arguments $myStringArray



Invokes bcp (SQL Bulk Copy) with the parameters stored in $myStringArray.

Note that the above will only work if bcp.exe is in your PATH. Otherwise, use the full path to bcp.exe











RELATED LINKS

https://github.com/DrJohnT/DeployCube