0

I am having troubles getting the Windows Update Log on Server 2016. As documented here Server 2016 now logs Windows update logs differently and to view the logs you need to run a Powershell command from the WindowsUpdate module called Get-WindowsUpdateLog.

The script needs to set the Symbol Cache and it does this by running 'Set-Location $SYM_CACHE'. The symbol cache variable is set earlier in the piece by this:

$WORKDIR = "$env:TEMP\WindowsUpdateLog"
$SYM_CACHE = "$WORKDIR\SymCache"

The problem I am getting is that my administrative username is 'secur.tima' and the temp variable is set with the 8.3 filename version of this which is 'C:\Users\SECUR~1.TIM\AppData\Local\Temp\4'

When the script tries to set this as the location it fails with this error:

Set-Location : An object at the specified path C:\Users\SECUR~1.TIM does not exist.
At 

    C:\Windows\system32\WindowsPowerShell\v1.0\Modules\WindowsUpdate\WindowsUpdateLog.psm1:194 char:5
    +     Set-Location $SYM_CACHE
    +     ~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Set-Location], PSArgumentException
        + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.SetLocationCommand

I have found this over at StackOverflow: https://stackoverflow.com/questions/10782739/how-to-change-to-temp-directory-in-powershell

However that shows how to fix the problem by changing the script. Whilst I could change the script provided by Microsoft, I am wondering if there is some way I can make this work from the server side or change the way that PowerShell handles 8.3 filenames?

Cheers

Tim

  • Problem I've had before in Windows with the long filename to 8.3 filename conversion was the assumption that the conversion resulted in ~1 as the expansion replacement. Sometimes there's something else preexisting which has already used the ~1 and I get ~2, or even higher, instead. Might not be the problem, but a quick. Easy enough to check using DIR /X in the normal command shell. – Gypsy Spellweaver Mar 13 '17 at 2:11
  • This problem only exists in PowerShell. If I run 'cd %TEMP%' from a command window it will change to the location successfully. – Tim Aitken Mar 13 '17 at 2:18
  • Does C:\Users\SECUR~1.TIM exist from within PowerShell, or is it C:\USERS\SECUR~1.TIM? Does PowerShell even understand the 8.3 filenames? – Gypsy Spellweaver Mar 13 '17 at 2:29
  • That is interesting; If I run test-path $env:temp the result is true. However if I run Set-location $env:temp the result is: Set-location : An object at the specified path C:\Users\ADMIN~1.TIM does not exist. – Tim Aitken Mar 13 '17 at 2:39
  • Then I'd look at the documentation for Set-Location to see if it is 8.3 conversion aware. – Gypsy Spellweaver Mar 13 '17 at 2:41
0

This technet article seems to indicate that PowerShell doesn't understand 8.3 filenames.

  • 1
    I'm pretty sure that is not what the article is saying, I believe it is telling you how to return the file path in the 8.3 format. I know that PowerShell can "understand" 8.3 file paths because test-path $env:temp or test-path C:\users\SECURE~1.TIM both work. – Tim Aitken Mar 13 '17 at 5:41
0

Make a batch file that does the CD to the temp directory, and then invoke the powershell script from within the batch file?

cd %temp%\windowsupdatelog
powershell.exe -f c:\dirname\script.ps1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.