Jump to content

Power shell run else if authui.dll versions are diffrent.


Recommended Posts

Posted

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

}

Posted

$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

Posted

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 :p

 

Steve

Posted

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

  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...