Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Installing .MSU Via Powershell & PSexec

$
0
0

Hey Peter

Well I definitely don’t have any issues with my connection to these machines :) however I did all what you said and connected via RDP to the machine and ran the command locally from PS session and it did work perfectly and installed the package then I had to remove it to continue on with my script. I even put 1 single computer only in the “test list” and I removed the “AMD64″ line to make sure it’ll rung against this single machine and this only architecture, and when I ran it remotely it didn’t work I gave it few minutes then I’ve checked the update, it wasn’t installed, restarted the computer then did one more check and still the update didn’t exist.

The Script I ran


 $cmd={

  Switch ($env:PROCESSOR_ARCHITECTURE){

      "x86" {Start-Process -FilePath wusa.exe -ArgumentList "\\rrg.local\dfs\setup\update\Windows6.1-KB2819745-x86-MultiPkg.msu /quiet" -Wait}
  }

}

Invoke-Command -ComputerName $(Get-Content "F:\WindowsManagementFramework4.0\Computer Lists\Test List.txt") -ScriptBlock $cmd

This was the outcome


 PS C:\> $cmd={

  Switch ($env:PROCESSOR_ARCHITECTURE){

      "x86" {Start-Process -FilePath wusa.exe -ArgumentList "\\rrg.local\dfs\setup\update\Windows6.1-KB2819745-x86-MultiPkg.msu /quiet" -Wait}
  }

}

Invoke-Command -ComputerName $(Get-Content "F:\WindowsManagementFramework4.0\Computer Lists\Test List.txt") -ScriptBlock $cmd

PS C:\> 

So I don’t really know what is the problem and as I mentioned before I ran it perfectly with the PSEXEC.exe against 1 single machine and it did execute the “.cmd” file and all of that without using conditional “if” in the script. The problem is that it doesn’t work on multiple machines. Another thing is when I use conditional “if” in simple script still doesn’t work.

This simple script to create a new folder and copy couple of files based on the Architecture.


#Variables
$Computers = Get-Content "F:\WindowsManagementFramework4.0\Computer Lists\test list.txt"
$HotFix_32bit = "F:\WindowsManagementFramework4.0\Update\Windows6.1-KB2819745-x86-MultiPkg.msu"
$HotFix_64bit = "F:\WindowsManagementFramework4.0\Update\Windows6.1-KB2819745-x64-MultiPkg.msu"
$BatchFile_32bit = "F:\WindowsManagementFramework4.0\Update\WUSA-32Bit.cmd"
$BatchFile_64bit = "F:\WindowsManagementFramework4.0\Update\WUSA-64Bit.cmd"
$OSArch = {Get-OSArchitecture -ComputerName $computer}

foreach ($computer in $Computers)
{

if ($OSArch -eq "64-Bit")
{
New-Item \\$computer\c$\update -ItemType directory
Copy-Item $HotFix_64bit -Destination \\$computer\C$\Update
    }
    Else {
New-Item \\$computer\c$\update -ItemType directory
Copy-Item $BatchFile_32bit -Destination \\$computer\c$\update
}
    }

The “test list.txt” has 2 machines 1 x86 and the other x64 so it creates the folders perfectly fine and when it gets to the copy it just copy this file “$BatchFile_32bit” to both of the machines so it totally ignored the check and didn’t complete the command of copying the $HotFix_64bit file. This issue is really bothering me and I don’t know what is wrong?? ..


Viewing all articles
Browse latest Browse all 13067

Trending Articles