![]() |
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.
Test-DtScript [-Path] <String> [-Arguments] <String> [-InteractionMode] <DesktopInteractionMode> [-ServiceHost] <Server> [<CommonParameters>]
Required? |
true |
Position? |
2 |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
Required? |
false |
Position? |
3 |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
Required? |
false |
Position? |
4 |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
Required? |
true |
Position? |
1 |
Accept Pipeline Input? |
true (ByPropertyName) |
Accept Wildcard Characters? |
false |
This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters. |
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
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