hi all,<\/p>\n
made a powershell script to install msi/exe’s (havnt done the exe’s yet)<\/p>\n
get-childitem -path C:\\remoteinstalls\\ -filter \"*.msi\" | select-object -expandproperty name > C:\\remoteinstalls\\msi.txt\nget-childitem -path C:\\remoteinstalls\\ -filter \"*.exe\" | select-object -expandproperty name > C:\\remoteinstalls\\exe.txt\n$msi = get-content -path C:\\remoteinstalls\\msi.txt\n$exe = get-content -path C:\\remoteinstalls\\exe.txt\n$Session = New-PSSession -ComputerName (get-content C:\\remoteinstalls\\hosts.txt)\nCopy-Item c:\\remoteinstalls -Destination c:\\ -ToSession $Session -Recurse -force\nforeach ($m in $msi) {\ninvoke-command -session $Session -ScriptBlock {start-process -filepath msiexec -argumentlist \"/i \"\"C:\\remoteinstalls\\$using:m\"\" /norestart /qb!\" -passthru -wait}\n}\n<\/code><\/pre>\n
Advertisement
but when i do passthru it doesnt state that the msi has been successfully installed or not, i just get this<\/p>\n
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName PSComputerName\n------- ------ ----- ----- ------ -- -- ----------- --------------\n 134 9 5884 7864 0.00 6240 0 msiexec 172.17.1.3\n 134 9 5892 7868 0.02 8188 0 msiexec 172.17.1.3\n 137 9 6004 8516 0.02 3212 0 msiexec 172.17.1.3\n 134 9 5888 7872 0.00 4664 0 msiexec 172.17.1.3\n 137 9 6080 8584 0.02 1804 0 msiexec 172.17.1.3\n<\/code><\/pre>\ni know i could do an if $? after my start process command but what do the above mean please<\/p>\n
thanks,<\/p>\n
rob<\/p>","upvoteCount":9,"answerCount":6,"datePublished":"2024-01-02T19:30:42.000Z","author":{"@type":"Person","name":"robertkwild","url":"https://community.spiceworks.com/u/robertkwild"},"suggestedAnswer":[{"@type":"Answer","text":"
hi all,<\/p>\n
made a powershell script to install msi/exe’s (havnt done the exe’s yet)<\/p>\n
get-childitem -path C:\\remoteinstalls\\ -filter \"*.msi\" | select-object -expandproperty name > C:\\remoteinstalls\\msi.txt\nget-childitem -path C:\\remoteinstalls\\ -filter \"*.exe\" | select-object -expandproperty name > C:\\remoteinstalls\\exe.txt\n$msi = get-content -path C:\\remoteinstalls\\msi.txt\n$exe = get-content -path C:\\remoteinstalls\\exe.txt\n$Session = New-PSSession -ComputerName (get-content C:\\remoteinstalls\\hosts.txt)\nCopy-Item c:\\remoteinstalls -Destination c:\\ -ToSession $Session -Recurse -force\nforeach ($m in $msi) {\ninvoke-command -session $Session -ScriptBlock {start-process -filepath msiexec -argumentlist \"/i \"\"C:\\remoteinstalls\\$using:m\"\" /norestart /qb!\" -passthru -wait}\n}\n<\/code><\/pre>\nbut when i do passthru it doesnt state that the msi has been successfully installed or not, i just get this<\/p>\n
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName PSComputerName\n------- ------ ----- ----- ------ -- -- ----------- --------------\n 134 9 5884 7864 0.00 6240 0 msiexec 172.17.1.3\n 134 9 5892 7868 0.02 8188 0 msiexec 172.17.1.3\n 137 9 6004 8516 0.02 3212 0 msiexec 172.17.1.3\n 134 9 5888 7872 0.00 4664 0 msiexec 172.17.1.3\n 137 9 6080 8584 0.02 1804 0 msiexec 172.17.1.3\n<\/code><\/pre>\ni know i could do an if $? after my start process command but what do the above mean please<\/p>\n
thanks,<\/p>\n
rob<\/p>","upvoteCount":9,"datePublished":"2024-01-02T19:30:42.000Z","url":"https://community.spiceworks.com/t/powershell-install-msi-exe/964628/1","author":{"@type":"Person","name":"robertkwild","url":"https://community.spiceworks.com/u/robertkwild"}},{"@type":"Answer","text":"
In the Invoke Command line, you have a bunch of double quotes. You have to stagger between the double and single quotes or they will cancel each other out. maybe try using this line instead<\/p>\n
Invoke-Command -Session $Session -ScriptBlock {Start-Process -FilePath msiexec -ArgumentList \"/i C:\\remoteinstalls\\$using:m /norestart /qb!\" -PassThru -Wait}\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2024-01-02T20:08:37.000Z","url":"https://community.spiceworks.com/t/powershell-install-msi-exe/964628/2","author":{"@type":"Person","name":"titusovermyer","url":"https://community.spiceworks.com/u/titusovermyer"}},{"@type":"Answer","text":"the reason why i have put 2 double quotes is to escape it as this document says<\/p>\n