Author Posts

November 13, 2017 at 12:15 am

I need to delete all msi files in the windows installer folder with the author of crowdstrike

Remove-item -path c:\windows\installer I dont get how to target author or even digital signature

is there a way? -filter maybe

Thank you

November 13, 2017 at 12:20 am

As far as I know there is no build in way to get the information you asked for from an MSI file. You might take a look at this link. It may help you How to get MSI file information with PowerShell

November 13, 2017 at 1:08 am

I just went with the *.msi option as it doesnt matter really if i keep any of the other MSI's since its a bunch of VDI linkedclones

although if anyone knows of a way i would love to know for future reference.

Thank you

November 13, 2017 at 1:59 am

It's ridiculously hard to work with the WindowsInstaller.Installer (msi) com object in powershell. I would call a vbscript from powershell or just use vbscript.

November 13, 2017 at 4:23 am

You could use the Shell.Application ComObject to read the .msi metadata.

cls
$folder = "C:\windows\Installer\"
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.namespace($folder)
$objFolder.Items() | 
Where-Object {$_.Name -like "*.msi"} |
ForEach-Object {
    [pscustomobject]@{
        $objFolder.getDetailsOf($folder, 0) = $objFolder.getDetailsOf($_, 0);
        $objFolder.getDetailsOf($folder, 20) = $objFolder.getDetailsOf($_, 20)
        $objFolder.getDetailsOf($folder, 185) = $objFolder.getDetailsOf($_, 185)
    }
} |
Where-Object {$_.Authors -eq "crowdstrike"} |
ForEach-Object {
    $_
    #Do something
}

November 13, 2017 at 4:19 pm

i tried to use the vb script and add a obj.deletefile at the end i keep getting

line 2
char 1
error invalid character
800A0408
microsoft vbscript compilation error

any ideas why its barking at me?

November 13, 2017 at 8:21 pm

Here's how I get the target of msi shortcuts. Call the vbscript and then store the result in a powershell variable:

$targetpath = cscript /nologo gettarget.vbs someshortcut.lnk

Where gettarget.vbs looks like:

Dim MSITarget
Set Msi = CreateObject("WindowsInstaller.Installer")
Set MSITarget = Msi.ShortcutTarget(wscript.arguments(0))
Wscript.Echo Msi.ComponentPath(MSITarget.StringData(1), MSITarget.StringData(3))

November 13, 2017 at 9:22 pm

Hey Steve,
What VBScript are you referring to? What I provided was PowerShell, not VBScript.