I am getting the following errors with a script that auto installs all updates in the current directory:
At K:\Operating System\ConfigureWindows10\Updates\Install-Updates.ps1:15 char:25
+ $command = "Expand –F:* '" + $msu.fullname + "' '" + $PSScr ...
+ ~~~
Unexpected token 'F:*' in expression or statement.
At K:\Operating System\ConfigureWindows10\Updates\Install-Updates.ps1:29 char:82
+ ... = "Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase"
+ ~
The string is missing the terminator: ".
At K:\Operating System\ConfigureWindows10\Updates\Install-Updates.ps1:13 char:5
+ {
+ ~
Missing closing '}' in statement block or type definition.
At K:\Operating System\ConfigureWindows10\Updates\Install-Updates.ps1:10 char:1
+ {
+ ~
Missing closing '}' in statement block or type definition.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
Here is the code body:
{
$msu = get-childitem -path $PSScriptRoot -Recurse | where ($_.extension -eq ".msu") | select fullname
foreach($package in $msu)
{
write-debug $msu.fullname
$command = "Expand –F:* '" + $msu.fullname + "' '" + $PSScriptRoot + "'"
write-debug $command
Invoke-Expression $command
}
$updates = get-childitem -path $PSScriptRoot -Recurse | where ($_.extension -eq ".cab") | select fullname
foreach($update in $updates)
{
write-debug $update.fullname
$command = "dism /online /add-package /packagepath:'" + $update.fullname + "'"
write-debug $command
Invoke-Expression $command
}
$command = "Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase"
Invoke-Expression $command
}
-(minus) or a dash before the F?