Remote instal vbs in Powershell.

Welcome Forums General PowerShell Q&A Remote instal vbs in Powershell.

Viewing 7 reply threads
  • Author
    Posts
    • #272425
      Participant
      Topics: 1
      Replies: 4
      Points: 24
      Rank: Member

      Hello guys, i recently started to learn powershell and this is kinda my first project. I am trying to automated remote instalation. I try to look for solution everywhere, but i cant find the right one. Here is the problem:

      I need to instal multiple applications that have multiple version on remote computers.

      I try few things but nothing worked so far 🙁

      This one worked for me, but only if i dont use variables. If i use them Powershell (or i guess cscript.exe) does not recognize them.

       

      $hostname = "yourPc"
      $app = "app_0001"
      $ver = "1.0.0"
      Invoke-Command -ComputerName $hostname -ScriptBlock {cscript.exe \\$hostname\directory\install.vbs /p:$app /v:$ver}

      Remove-PSSession $s

       

      So i basicly end up with \\$hostname\directory\install.vbs /p:$app /v:$ver does not exist. Is it possible to do this with cscript.exe? Can u help me with solution?

       

      Thanks for your time and answers.

      • This topic was modified 1 week, 6 days ago by Mergi29.
      • This topic was modified 1 week, 5 days ago by grokkit.
    • #272671
      Participant
      Topics: 5
      Replies: 170
      Points: 656
      Helping Hand
      Rank: Major Contributor

      Local variables are not accessible inside the invoke-command script block.  You must either pass them in as arguments or preface with $using.  i.e. $using.hostname.

      Get-Help about_remote_variables

    • #272866
      Participant
      Topics: 1
      Replies: 4
      Points: 24
      Rank: Member

      Local variables are not accessible inside the invoke-command script block. You must either pass them in as arguments or preface with $using. i.e. $using.hostname.

      Get-Help about_remote_variables

      Thank you! It works perfectly 🙂

    • #272977
      Participant
      Topics: 16
      Replies: 1855
      Points: 3,568
      Helping Hand
      Rank: Community Hero

      Also, the VBScript can and should be converted to Powershell (or something not VBScript). VBScript is being deprecated. From first glance of the params, you should look at Get-ChildItem and Start-Process. Not sure if those params are building a path and how it knows what to execute in the directory. Re-writing the vbScript wrapper would be a good next project. 🙂

    • #273031
      Participant
      Topics: 1
      Replies: 4
      Points: 24
      Rank: Member

      Also, the VBScript can and should be converted to Powershell (or something not VBScript). VBScript is being deprecated. From first glance of the params, you should look at Get-ChildItem and Start-Process. Not sure if those params are building a path and how it knows what to execute in the directory. Re-writing the vbScript wrapper would be a good next project. 🙂

      Thanks for tip. After i finish this one i might look at it. But after first look just from the lenght/structure of the scripts it will take me some time to get this level of knowledge 🙂 I am currenty at IT Service Desk position and all those scripts always make our Desktop support or sys admins.

    • #273526
      Participant
      Topics: 1
      Replies: 4
      Points: 24
      Rank: Member

      I got one more question. Now i finished my whole script and i have a issue with this way of remote instalation. This part of script i posted works by its self… But… It doesnt work with combination with read-host in it. I need some user input, like that application number and his version, but  it always ends, before user can give any input…

      I tried to experiment with New-PSSession but its ends the same way… I could completely overwrith the script and use this method that Mike suggest just for the instlation, but there must be a better way… Any other tip please?

       

    • #273550
      Participant
      Topics: 5
      Replies: 170
      Points: 656
      Helping Hand
      Rank: Major Contributor

      Where are you putting Read-Host in your script?  Anything in the script block of Invoke-Command happens on the remote machine not the one running the command.  Can you post your script?

    • #274410
      Participant
      Topics: 1
      Replies: 4
      Points: 24
      Rank: Member

      Thanks for your reply. I had it in invoke-command block. I rebuild it outsite it turns out its not that many changes…

Viewing 7 reply threads
  • You must be logged in to reply to this topic.