none
PSSessions Running exes RRS feed

  • Question

  • os 2008 R2 sp2

    I have disabled UAC completely , confirmed this by launching a standard cmd prompt and cd C:\Windows\SysWOW64\config

    as per http://blog.pythonaro.com/2013/05/fully-disable-user-access-control-uac.html

    When i run the following , nothing happens , as i am running psexec , this is not the double hop issue , the files make it to the server.

    I am attempting to run a local exe on the target server , the psexec is simply to run the copy command , the double hop has been sorted and the files make it to the local server

    the exe does not kick off but does when i enter the session interactive and run the exe call and arg

    $complist =@("server1","server2")
    $server = "sourcefileserver"
    
    
    	function NewLogin($computer)
    	{
    		$session = new-pssession -computername $computer  -Authentication Kerberos
    		return $session
    	}
    	Function Func_installSoft($Computer)
    	{
    		$session = NewLogin $Computer
    		$scriptblock={
    		c:\install\vcredist_x64.exe /passive
    		}
    	Invoke-Command -session $session -ScriptBlock $scriptblock
    	Remove-PSSession -session $session
    }
    foreach($element in $complist)
    {
    psexec \\$element -s robocopy "\\$server\Documents\install\" "c:\Install"
    Func_installSoft $element
    }


    If i run the following interactively , the install runs fine ,  Logically i am doing exactly the same thing right?

    $comp = "qual29web001"
    $session = new-pssession -computername $comp -Authentication Kerberos
    $sessions = get-pssession
    $sessionid = $sessions.ID[0]
    enter-pssession $sessionid 
    c:\install\vcredist_x64.exe /passive
    exit
    remove-pssession *



    Any help is much appreciated  , the install is a rollup for visual studio





    • Edited by RobMDD Friday, March 20, 2015 11:15 PM
    Friday, March 20, 2015 9:13 PM

Answers

  • in the interest of fixing this issue for other users

    context: install executables and windows hotfix's

    dependancies: psexec , uac disabled as per , enable psremoting

    http://blog.pythonaro.com/2013/05/fully-disable-user-access-control-uac.html

    regards

    A person who cobbles together "WORKING SCRIPTS"

    $complist =@("server1","server2")
    
    Function New-RemoteProcess {
        Param([string]$computername=$env:computername,
            [string]$cmd=$(Throw "You must enter the full path to the command which will create the process.")
        )
    
        $ErrorActionPreference="SilentlyContinue"
    
        Trap {
            Write-Warning "There was an error connecting to the remote computer or creating the process"
            Continue
        }    
    
        Write-Host "Connecting to $computername" -ForegroundColor CYAN
        Write-Host "Process to create is $cmd" -ForegroundColor CYAN
    
        [wmiclass]$wmi="\\$computername\root\cimv2:win32_process"
    
        #bail out if the object didn't get created
        if (!$wmi) {return}
    
        $remote=$wmi.Create($cmd)
    
        if ($remote.returnvalue -eq 0) {
            Write-Host "Successfully launched $cmd on $computername with a process id of" $remote.processid -ForegroundColor GREEN
        }
        else {
            Write-Host "Failed to launch $cmd on $computername. ReturnValue is" $remote.ReturnValue -ForegroundColor RED
        }
    }
    
    foreach($element in $complist)
    {
    psexec \\$element -s robocopy "\\filelocationserver\Documents\install\" "c:\Install"
    Start-Sleep -s 10
    psexec \\$element  -u domain\user -p password Expand –F:* c:\install\Windows6.1-KB2554746-v2-x64.msu  c:\install\
    psexec \\$element  -u domain\user -p password  DISM.exe /Online /Add-Package /PackagePath:c:\install\Windows6.1-KB2554746-v2-x64.cab /Quiet /NoRestart
    New-RemoteProcess -comp $element -cmd "c:\install\vcredist_x64.exe /passive"
    New-RemoteProcess -comp $element -cmd "c:\install\vcredist_x86.exe /passive"
    }
    



    • Marked as answer by RobMDD Saturday, March 21, 2015 12:24 AM
    • Edited by RobMDD Saturday, March 21, 2015 12:25 AM
    Saturday, March 21, 2015 12:23 AM

All replies

  • know what invoke command is? , scriptblock is a way of passing commands to a remote machine not using psexec.......

    research before you post

    Friday, March 20, 2015 10:39 PM
  • i rewrote the info above to be a little more clear , apologise if it was a little confusing ..



    • Edited by RobMDD Friday, March 20, 2015 11:16 PM
    Friday, March 20, 2015 11:10 PM
  • oh so you admit you're wrong but then attempt to pick another area to have an issue with? 

    exp programmer?..... right ...ive fixed the issue without the help of "us old programmers" . I would retort with a response you deserve .....but whats the point. Try do a little better with the responses you cobble together mate


    • Edited by RobMDD Friday, March 20, 2015 11:48 PM
    Friday, March 20, 2015 11:47 PM
  • in the interest of fixing this issue for other users

    context: install executables and windows hotfix's

    dependancies: psexec , uac disabled as per , enable psremoting

    http://blog.pythonaro.com/2013/05/fully-disable-user-access-control-uac.html

    regards

    A person who cobbles together "WORKING SCRIPTS"

    $complist =@("server1","server2")
    
    Function New-RemoteProcess {
        Param([string]$computername=$env:computername,
            [string]$cmd=$(Throw "You must enter the full path to the command which will create the process.")
        )
    
        $ErrorActionPreference="SilentlyContinue"
    
        Trap {
            Write-Warning "There was an error connecting to the remote computer or creating the process"
            Continue
        }    
    
        Write-Host "Connecting to $computername" -ForegroundColor CYAN
        Write-Host "Process to create is $cmd" -ForegroundColor CYAN
    
        [wmiclass]$wmi="\\$computername\root\cimv2:win32_process"
    
        #bail out if the object didn't get created
        if (!$wmi) {return}
    
        $remote=$wmi.Create($cmd)
    
        if ($remote.returnvalue -eq 0) {
            Write-Host "Successfully launched $cmd on $computername with a process id of" $remote.processid -ForegroundColor GREEN
        }
        else {
            Write-Host "Failed to launch $cmd on $computername. ReturnValue is" $remote.ReturnValue -ForegroundColor RED
        }
    }
    
    foreach($element in $complist)
    {
    psexec \\$element -s robocopy "\\filelocationserver\Documents\install\" "c:\Install"
    Start-Sleep -s 10
    psexec \\$element  -u domain\user -p password Expand –F:* c:\install\Windows6.1-KB2554746-v2-x64.msu  c:\install\
    psexec \\$element  -u domain\user -p password  DISM.exe /Online /Add-Package /PackagePath:c:\install\Windows6.1-KB2554746-v2-x64.cab /Quiet /NoRestart
    New-RemoteProcess -comp $element -cmd "c:\install\vcredist_x64.exe /passive"
    New-RemoteProcess -comp $element -cmd "c:\install\vcredist_x86.exe /passive"
    }
    



    • Marked as answer by RobMDD Saturday, March 21, 2015 12:24 AM
    • Edited by RobMDD Saturday, March 21, 2015 12:25 AM
    Saturday, March 21, 2015 12:23 AM
  • I definitely would not recommend disabling UAC. That is a very bad idea.

    -- Bill Stewart [Bill_Stewart]

    Saturday, March 21, 2015 2:47 PM
    Moderator