0

I am trying to install a MSU file which is located on a shared drive:

if (([System.Environment]::OSVersion.Version.Major -lt 10) -and ($PSVersionTable.PSVersion.Major -le 3))
{
    $command = "`"" + "Z:\00 - FTA - General\12 - IT\Scripts\Win7 WMF5  KB3134760-x64.msu" + "`""
    $parameters = $command + " /quiet"
    $install = [System.Diagnostics.Process]::Start( "wusa",$parameters,$Username,$Password,"domainName" )
    $install.WaitForExit()
    $install.ExitCode
}

However I get the error message:

Exception calling "Start" with "5" argument(s): "The directory name is invalid" At line:8 char:5 + $install = [System.Diagnostics.Process]::Start( "wusa",$parameter ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : Win32Exception

Anyone here who knows what I'm doing wrong? I also tried replacing the drive letter with the IP, but it yelds the same error message...

\\192.168.254.3\D$\office\00 - FTA - General\12 - IT\Scripts\Win7 WMF5  KB3134760-x64.msu
henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
Docschnitzel
  • 175
  • 1
  • 2
  • 12
  • 1
    Possible duplicate of [Win32Exception: The directory name is invalid](http://stackoverflow.com/questions/990562/win32exception-the-directory-name-is-invalid) – beatcracker Apr 18 '17 at 10:23
  • 1
    Does the same error occur if you use Start-Process instead? Random thought. – Richard Dakin Apr 18 '17 at 10:25

1 Answers1

1

You've over complicated this task, you just need to use the Call Operator (&) to run wusa and pass it the path to the file along with the quiet and norestart options.

$msu = "\\192.168.254.3\D$\office\00 - FTA - General\12 - IT\Scripts\Win7 WMF5  KB3134760-x64.msu"

& wusa $msu /quiet /norestart
henrycarteruk
  • 12,708
  • 2
  • 36
  • 40