Cmdlets > Test-DtScript

Test-DtScript

Tests the specified script

Syntax

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

Detailed Description

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.

Parameters

Name Type Description Required Pipeline Input
Service
Host
Server

Specify the server object returned from the New-DtServer cmdlet. For this cmdlet, the -ServiceHost could be your source or target server.

true false
Path String

Specify the full path and script name

true false
Arguments String

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

false false
Interaction
Mode
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.

false false

Outputs

Int32

Examples

$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

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

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.