Execute .exe file thr remote in windows server

$s = New-PSSession -ComputerName local -Credential $creds

Invoke-Command -Session $s -ScriptBlock{
write-host "Service status"
get-service -name WwanSvc
&dci.exe

}

Invoke-command $s -ScriptBlock{dci.exe}

output:(without this line Invoke-command $s -ScriptBlock{dci.exe})

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

When I try to execute the above script I could able to hit the remote server and get the status of the services running but unable to execute dci.exe in it.Getting errored out saying 

output:(when Invoke-command $s -ScriptBlock{dci.exe} is present)

NotSpecified: (:String) [], RemoteException
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

can someone please let me know what I am  doing wrong.

Thanks in advance

  • I have no idea what dci.exe is. Yet, using another executable is a quick test in my lab, works as expected.

        $s = New-PSSession -ComputerName $env:COMPUTERNAME
        Invoke-Command -Session $s -ScriptBlock{
                                                    "Service status"
                                                    Get-Service -name was
                                                    &notepad.exe
                                                    Get-Process -Name Notepad
                                               }

        Status   Name               DisplayName                            PSComputerName                                                                             
        ------   ----               -----------                            --------------                                                                             
        Running  was                Windows Process Activation Service     ws01                                                                                   

        Id             : 3496
        Handles        : 86
        CPU            : 0.015625
        Name           : notepad
        PSComputerName : ws01

    Is this dci.exe in the system environment path?

    Note: if not, then you have to use the fully qualified path to the dci.exe

    Does this dci.exe pop up a interactive UI?

    Are you tryin to start this in the context of the currently logged on user?

    Note: if you are. This cannot be done natively with PoSH. This is a Windows security restriction.

    If you need to do this, look to SysInternals, psexec or other tools like AutoIt.