Skip to content
This repository was archived by the owner on Sep 17, 2021. It is now read-only.
This repository was archived by the owner on Sep 17, 2021. It is now read-only.

Add PowerShell v1/v2 compatibility #6

@vipzen

Description

@vipzen

Hello @rasta-mouse. I've been trying to adapt Sherlock to work with PowerShell v2 and managed to make it work even with v1 without any problem.
I have an ugly but full functional code here, but I will comment on some suggestions to be adapted accordingly by you in a more beautiful way.

Get-FileVersionInfo():

Instead using Win32_Product class (unstable on v2 and nonexistent on v1), we can use CIM_DataFile.

# Double slash for CIM_DataFile
$FilePath = $FilePath.Replace("\", "\\")
    
# PsH v1/v2 support via CIM_DataFile
$VersionInfo = (Get-WmiObject -Class CIM_DataFile -Filter "Name='$FilePath'" | Select-Object Version).Version

Also, on WinXP/Win2k3 with v2/v1, for some reason the architecture check fail in some functions and $Path will return null, triggering an error in Get-FileVersionInfo()

I "fixed" it by simply adding an extra Elseif conditional:

 } ElseIf ( $Architecture[1] -eq "x86" ) {

        $Path = $env:windir + "\system32\win32k.sys"

    }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions