invoke-command to run .exe install [resolved]

This topic contains 0 replies, has 1 voice, and was last updated by  Laurent Maene 7 months, 1 week ago.

  • Author
    Posts
  • #66357

    Laurent Maene
    Participant

    Hello, this is my first post to the community! PowerShell is awesome!
    When I was typing this post , I was still testing for a solution and I found it. So I decided to share it.

    ==> original post

    Any idea why this code doesn't work?

    $computer='S1'
    $server='S2'
    Copy-Item \\$server\msi$\SAP_Outlook_Add-In.exe -Destination \\$computer\c$\temp
    Invoke-Command -ComputerName $computer -ScriptBlock {set-location c:\temp ; .\SAP_Outlook_Add-In.exe /q}
    

    By the way, this is working.

    $computer='S1'
    Enter-PSSession -ComputerName $computer
    set-location c:\temp
    .\SAP_Outlook_Add-In.exe /q
    exit
    

    ==> solution

    So I mixed it to this and it is working.

    $computer='S1'
    $s = New-PSSession -ComputerName $computer
    Invoke-Command -Session $s -ScriptBlock {set-location c:\temp ; .\SAP_SOD_Outlook_Add-In.exe /q}
    

The topic ‘invoke-command to run .exe install [resolved]’ is closed to new replies.