Dialogs do not show up when run by Lansweeper / PsExec

I want to deploy some packages with lansweeper. There I created a new step which copies my PSADT data from the fileserver to the local machine. In the next step I start Deploy-Application.exe with the help of PsExec.

"C:\LSDeployment\Affinity Designer\PsExec.exe" -s -i -accepteula "C:\LSDeployment\Affinity Designer\Deploy-Application.exe"

The Deploy-Application.exe was started on the remote machine, but I do not get any Dialogs.

Here is the log:

<![LOG[[Initialization] :: *******************************************************************************]LOG]!><time="10:58:42.91260" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: *******************************************************************************]LOG]!><time="10:58:42.91260" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: [Serif_AffinityDesigner_DE_01] setup started.]LOG]!><time="10:58:42.94360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Script [C:\LSDeployment\Affinity Designer\AppDeployToolkit\AppDeployToolkitMain.ps1] dot-source invoked by [C:\LSDeployment\Affinity Designer\Deploy-Application.ps1]]LOG]!><time="10:58:43.00660" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Script [C:\LSDeployment\Affinity Designer\AppDeployToolkit\AppDeployToolkitExtensions.ps1] dot-source invoked by [C:\LSDeployment\Affinity Designer\AppDeployToolkit\AppDeployToolkitMain.ps1]]LOG]!><time="10:58:43.02160" date="03-04-2021" component="PSAppDeployToolkitExt" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitExtensions.ps1">
<![LOG[[Initialization] :: [Serif_AffinityDesigner_DE_01] script version is [1.0.0]]LOG]!><time="10:58:43.03960" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: [Serif_AffinityDesigner_DE_01] script date is [26/01/2021]]LOG]!><time="10:58:43.03960" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: [Serif_AffinityDesigner_DE_01] script author is [First Last - Company]]LOG]!><time="10:58:43.03960" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: [Deploy Application] script version is [3.8.4]]LOG]!><time="10:58:43.05360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: [App Deploy Toolkit Main] script version is [3.8.4]]LOG]!><time="10:58:43.05360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: [App Deploy Toolkit Extensions] version is [3.8.4]]LOG]!><time="10:58:43.05360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Computer Name is [DT-A8E4A207.lan.domain.tld]]LOG]!><time="10:58:43.05360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Current User is [NT-AUTORITÄT\SYSTEM]]LOG]!><time="10:58:43.06860" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: OS Version is [Microsoft Windows 10 Pro 64-bit 10.0.19041.804]]LOG]!><time="10:58:43.06860" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: OS Type is [Workstation]]LOG]!><time="10:58:43.06860" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Current Culture is [de-DE], language is [DE] and UI language is [DE]]LOG]!><time="10:58:43.06860" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Hardware Platform is [Virtual:Hyper-V]]LOG]!><time="10:58:43.19360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: PowerShell Host is [ConsoleHost] with version [5.1.19041.610]]LOG]!><time="10:58:43.19360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: PowerShell Version is [5.1.19041.610 x64]]LOG]!><time="10:58:43.19360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: PowerShell CLR (.NET) version is [4.0.30319.42000]]LOG]!><time="10:58:43.20960" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: *******************************************************************************]LOG]!><time="10:58:43.20960" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Display session information for all logged on users: 


NTAccount           : DOMAIN\user.name
SID                 : S-1-5-21-1111111111-222222222-333333333-4444
UserName            : user.name
DomainName          : DOMAIN
SessionId           : 2
SessionName         : RDP-Tcp#0
ConnectState        : Active
IsCurrentSession    : False
IsConsoleSession    : False
IsActiveUserSession : True
IsUserSession       : True
IsRdpSession        : True
IsLocalAdmin        : False
LogonTime           : 04.03.2021 10:04:50
IdleTime            : 00:20:44.3375022
DisconnectTime      : 
ClientName          : LT-822F9633
ClientProtocolType  : RDP
ClientDirectory     : C:\WINDOWS\system32\mstscax.dll
ClientBuildNumber   : 19041



]LOG]!><time="10:58:43.41260" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: The following users are logged on to the system: [DOMAIN\user.name].]LOG]!><time="10:58:43.41260" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Current process is running under a system account [NT-AUTORITÄT\SYSTEM].]LOG]!><time="10:58:43.42860" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: There is no console user logged in (user with control of physical monitor, keyboard, and mouse).]LOG]!><time="10:58:43.42860" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: The active logged on user is [DOMAIN\user.name].]LOG]!><time="10:58:43.42860" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: The active logged on user [DOMAIN\user.name] has a primary UI language of [DE].]LOG]!><time="10:58:43.42860" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: The following UI messages were imported from the config XML file: [UI_Messages_DE].]LOG]!><time="10:58:43.44360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: The active logged on user [DOMAIN\user.name] has a DPI scale factor of [100] with DPI pixels [96].]LOG]!><time="10:58:43.44360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Unable to load COM Object [Microsoft.SMS.TSEnvironment]. Therefore, script is not currently running from a SCCM Task Sequence.]LOG]!><time="10:58:43.44360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Service [Schedule] exists.]LOG]!><time="10:58:43.63160" date="03-04-2021" component="Test-ServiceExists" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Get the service [Schedule] startup mode.]LOG]!><time="10:58:43.64660" date="03-04-2021" component="Get-ServiceStartMode" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Service [Schedule] startup mode is set to [Automatic].]LOG]!><time="10:58:43.75660" date="03-04-2021" component="Get-ServiceStartMode" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Get the service object for service [Schedule].]LOG]!><time="10:58:43.78760" date="03-04-2021" component="Start-ServiceAndDependencies" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Service [Schedule] with display name [Aufgabenplanung] has a status of [Running].]LOG]!><time="10:58:43.80360" date="03-04-2021" component="Start-ServiceAndDependencies" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: The task scheduler service is in a healthy state: True.]LOG]!><time="10:58:43.80360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Session 0 detected, process running in user interactive mode, user(s) logged in.]LOG]!><time="10:58:43.80360" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Installation is running in [Interactive] mode.]LOG]!><time="10:58:43.81860" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Deployment type is [Installation].]LOG]!><time="10:58:43.81860" date="03-04-2021" component="PSAppDeployToolkit" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="AppDeployToolkitMain.ps1">
<![LOG[[Pre-Installation] :: Evaluate disk space requirements.]LOG]!><time="10:58:43.83460" date="03-04-2021" component="Show-InstallationWelcome" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: Retrieve free disk space for drive [C:].]LOG]!><time="10:58:43.85060" date="03-04-2021" component="Get-FreeDiskSpace" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: Free disk space for drive [C:]: [85460 MB].]LOG]!><time="10:58:43.86560" date="03-04-2021" component="Get-FreeDiskSpace" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: Successfully passed minimum disk space requirement check.]LOG]!><time="10:58:43.88160" date="03-04-2021" component="Show-InstallationWelcome" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: Get deferral history...]LOG]!><time="10:58:43.89660" date="03-04-2021" component="Get-DeferHistory" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: Get registry key [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\PSAppDeployToolkit\DeferHistory\Serif_AffinityDesigner_DE_01] and all property values.]LOG]!><time="10:58:43.89660" date="03-04-2021" component="Get-RegistryKey" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: Defer history shows [998] deferrals remaining.]LOG]!><time="10:58:43.91260" date="03-04-2021" component="Show-InstallationWelcome" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: User has [997] deferrals remaining.]LOG]!><time="10:58:43.91260" date="03-04-2021" component="Show-InstallationWelcome" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: Check for running applications: [Designer]]LOG]!><time="10:58:43.94360" date="03-04-2021" component="Get-RunningProcesses" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: Specified applications are not running.]LOG]!><time="10:58:43.95960" date="03-04-2021" component="Get-RunningProcesses" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: User has the option to defer.]LOG]!><time="10:58:44.00660" date="03-04-2021" component="Show-WelcomePrompt" context="NT-AUTORITÄT\SYSTEM" type="1" thread="8044" file="Deploy-Application.ps1">

If I connect to the remote machine, start CMD with admin priviliges and run the command from above, then everything works fine.

I hope someone has an idea how to solve the problem :slight_smile:

Edit:

It seems the problem is the session id. If I use psexec -i 2 it works fine. So has someone a good way to get the session id of the active user?

You can get session ID from a process running under that user.

$ProcessName = "explorer.exe"
$UserName = "John.Smith"
$SessionID = Get-ciminstance win32_process -filter "name = '$ProcessName'" | ForEach-Object {$info = $_ | Invoke-CimMethod -MethodName "GetOwner"; if ($info.User -eq $UserName) {$_.SessionID}} | Select-Object -First 1
#SessionID will be empty if the process you specified is not running or not under that user.

But then again you will need to know the username. There can be multiple active users on a server.
So finding that might be harder. You can also get sessionID from the current process:

$SessionID = [System.Diagnostics.Process]::GetCurrentProcess().SessionId

I run psadt under psexec -s just fine so not sure whats different on your end.

Hi @luki1412 ,

thank you for your tip. While searching to find a solution I found this nice function to get all active sessions on a system. So I use the data returned by the function to call psexec with -i $SessionID.

Best regards