A Edwards
asked on
PowerShell - Remote Software Install
Hello,
Here is what I have to do manually every time. Log into every computer and connect to a "Share" on my network that has a shortcut to run this "MSI" file.
1. I log in and I run the MSI file
2. log off and let the user log back in to run the program
I want to automate this process using PowerShell.
here is the location to the file - "\\10.0.2.10\Production\TB A Client\TBA client Update.msi"
I have my computer names in a txt file. So I can use "Get-Content" command.
HELPPP!!!
Here is what I have to do manually every time. Log into every computer and connect to a "Share" on my network that has a shortcut to run this "MSI" file.
1. I log in and I run the MSI file
2. log off and let the user log back in to run the program
I want to automate this process using PowerShell.
here is the location to the file - "\\10.0.2.10\Production\TB
I have my computer names in a txt file. So I can use "Get-Content" command.
HELPPP!!!
ASKER
Thanks for the info,
Now will the "Invoke-Command work on a ShortCut to the MSI file on the server"?
Also with your code I do not see the path to where compters or the msi is being stored.
I can store it in c:\Temp\
then it would look like this
$computers = Get-Content 'c:\Temp\computers.txt'
$m = "c:\temp\software install.lnk'
can you make it a little more clear?
Now will the "Invoke-Command work on a ShortCut to the MSI file on the server"?
Also with your code I do not see the path to where compters or the msi is being stored.
I can store it in c:\Temp\
then it would look like this
$computers = Get-Content 'c:\Temp\computers.txt'
$m = "c:\temp\software install.lnk'
can you make it a little more clear?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay so here is what works for me.
$computers = Get-Content "c:\temp\computers.txt"
foreach ($comp in $computers)
{
Copy-Item -path "T:\TBA Client\TBA Client Update.msi" -Destination \\$comp\c$\temp
{
That part actually does what I want. Which is copy the files to the TEMP directory.
Now I want to Establish a PSSession with all those computers in my $computers variable.
I want to (invoke-item "c:\temp\*msi") on all those computers to run the msiexe.exe
I have tested it out on one machine PSSession and it works. I just do not know how to get multiple PSSessions to execute the (invoke-item)
$computers = Get-Content "c:\temp\computers.txt"
foreach ($comp in $computers)
{
Copy-Item -path "T:\TBA Client\TBA Client Update.msi" -Destination \\$comp\c$\temp
{
That part actually does what I want. Which is copy the files to the TEMP directory.
Now I want to Establish a PSSession with all those computers in my $computers variable.
I want to (invoke-item "c:\temp\*msi") on all those computers to run the msiexe.exe
I have tested it out on one machine PSSession and it works. I just do not know how to get multiple PSSessions to execute the (invoke-item)
If Invoke-Item works for you, then you can just substitute that for line 3 in my post above. The code I posted creates a new session and then uses that with Invoke-Command to run all the commands that are stored in the $deploy variable.
ASKER
I will test it on Monday as my Day is done here at work!
Thank you, and I will keep you posted.
Thank you, and I will keep you posted.
No problem. If you have any issues I may not be able to respond until the following week.
Happy Holidays!
Happy Holidays!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
_
ASKER
I did some reading and found what I was looking for by using the PowerShell Help.
Steps are:
- create new pssession for target machine
- If needed by the installation process, copy the file(s) to the target machine via UNC path
- Run the .MSI file.
- You may want/need to perform some cleanup of files, and/or unneeded pssessions.
Here's the core code that would actually run the .MSI.
Open in new window