Dan_ATR Posted December 1, 2015 Posted December 1, 2015 What am I doing wrong!!! I am trying to check the versions of the authui.dll and then if they are diffrent it needs to go to else and copy the file accross. The code in the else section works as I used it before but I dont want the script to copy accross the authui.dll on every boot. # 6.1.7601.18906 Clear-Host $VersionInfo = (Get-Item C:\Windows\System32\authui.dll).VersionInfo $FileVersion = ("{0}.{1}.{2}.{3}" -f $VersionInfo.FileMajorPart, $VersionInfo.FileMinorPart, $VersionInfo.FileBuildPart, $VersionInfo.FilePrivatePart) $FileVersion $FileVersion2 = 6.1.7601.17514 If ($FileVersion -eq $FileVersion2) { Write-Host "Already Updated!" exit } Else { Write-Host "Run script!" Stop-Process -name explorer Stop-Process -name LogonUI takeown.exe /F C:\Windows\System32\authui.dll icacls.exe C:\Windows\System32\authui.dll /grant Administrators:F Remove-Item C:\Windows\System32\authui.dll -recurse Start-Process explorer Copy-Item -Path .\authui.dll -Destination C:\Windows\System32\ Start-Process LogonUI }
Steve21 Posted December 1, 2015 Posted December 1, 2015 $FileVersion = ("{0}.{1}.{2}.{3}" -f $VersionInfo.FileMajorPart, $VersionInfo.FileMinorPart, $VersionInfo.FileBuildPart, $VersionInfo.FilePrivatePart) $FileVersion $FileVersion2 = 6.1.7601.17514 Why are you redoing $FileVersion as wouldn't you wipe what's already in there? Steve
Dan_ATR Posted December 1, 2015 Author Posted December 1, 2015 I dont know. Im only using what iv found on the web. Im not a power shell scripter lol. What would you recoment I do?
Steve21 Posted December 1, 2015 Posted December 1, 2015 Actually ignore that, just tried it. $FileVersion2 = 6.3.9600.17962 is returning blank If you change it to $FileVersion2 = "6.3.9600.17962" it works on mine PS C:\Windows\system32> PS C:\Windows\system32> $VersionInfo = (Get-Item C:\Windows\System32\authui.dll).VersionInfo PS C:\Windows\system32> PS C:\Windows\system32> $FileVersion = ("{0}.{1}.{2}.{3}" -f $VersionInfo.FileMajorPart, >> $VersionInfo.FileMinorPart, >> $VersionInfo.FileBuildPart, >> $VersionInfo.FilePrivatePart) >> PS C:\Windows\system32> $FileVersion2 = "6.3.9600.17962" PS C:\Windows\system32> PS C:\Windows\system32> Write-Host $FileVersion 6.3.9600.17962 PS C:\Windows\system32> Write-Host $FileVersion2 6.3.9600.17962 PS C:\Windows\system32> PS C:\Windows\system32> If ($FileVersion -eq $FileVersion2) {Write-Host "Already Updated!"} else {write-host "no"} Already Updated! PS C:\Windows\system32> Edit - Note I changed version to match mine Steve
Dan_ATR Posted December 1, 2015 Author Posted December 1, 2015 Still will not go to the else section.
Steve21 Posted December 1, 2015 Posted December 1, 2015 You can't have the spaces between them: # 6.1.7601.18906 Clear-Host $VersionInfo = (Get-Item C:\Windows\System32\authui.dll).VersionInfo $FileVersion = ("{0}.{1}.{2}.{3}" -f $VersionInfo.FileMajorPart, $VersionInfo.FileMinorPart, $VersionInfo.FileBuildPart, $VersionInfo.FilePrivatePart) $FileVersion2 = "6.1.7601.17514" Write-Host $FileVersion Write-Host $FileVersion2 If ($FileVersion -eq $FileVersion2) { Write-Host "Already Updated!" exit } else { Write-Host "Run script!" } As an example Steve 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now