Click or drag to resize
Test-DtScript

This cmdlet tests the specified script on the specified server using the credentials from Set-DtScriptCredentials. If necessary, manually undo any changes that you do not want after testing the script. For this cmdlet, the -ServiceHost could be your source or target server.

Syntax

Test-DtScript [-Path] <String> [-Arguments] <String> [-InteractionMode] <DesktopInteractionMode> [-ServiceHost] <Server> [<CommonParameters>]

Parameters
-Path<String>

Specify the full path and script name.

Required?

true

Position?

2

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Arguments<String>

Specify any arguments that need to be passed to the script.

Required?

false

Position?

3

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-InteractionMode<DesktopInteractionMode>

Specify if the script processing will be displayed on the screen, by using the value Interact, or if the script will execute silently in the background, by using the value None.

Required?

false

Position?

4

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ServiceHost<Server>

Specify the server object returned from the New-DtServer cmdlet.

Required?

true

Position?

1

Accept Pipeline Input?

true (ByPropertyName)

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.

Examples

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

A server object is created for the server alpha using the domain\administrator and password credentials. It assigns the server object to the variable called DtServerObjectAlpha. Then the script called ScriptName (located in C:\PathDir) is run, using the arguments arg1 and arg2. The script will display on screen. The connections for the server object are then closed.

$DtServerObjectAlpha= New-DtServer -Name alpha -UserName domain\administrator -Password password

Test-DtScript -ServiceHost $DtServerObjectAlpha -Path "C:\PathDir\ScriptName" -Arguments "arg1 arg2" -InteractionMode Interact

Disconnect-DtServer -ServiceHost $DtServerObjectAlpha

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

A server object is created for the server alpha using the domain\administrator and password credentials. It assigns the server object to the variable called DtServerObjectAlpha. Then PowerShell is launched and the arguments passed to PowerShell are the PowerShell script myscript.ps1 (located in C:\my scripts) and the arguments ars1 and arg2. The PowerShell execution policy is set to RemoteSigned so the PowerShell script will execute. The script is set to run silently in the background. The connections for the server object are then closed.

$DtServerObjectAlpha= New-DtServer -Name alpha -UserName domain\administrator -Password password

Test-DtScript -ServiceHost $DtServerObjectAlpha -Path "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Arguments "-File ""C:\my scripts\myscript.ps1"" ""-Arg1 arg1 -Arg2 arg2"" -ExecutionPolicy RemoteSigned" -InteractionMode None

Disconnect-DtServer -ServiceHost $DtServerObjectAlpha