I need to check if the Chrome extension is installed via Powershell.
What i have now is this:
function Get-ChromeExtension {
param (
[string]$ComputerName = $env:COMPUTERNAME
)
Get-ChildItem "\\$ComputerName\c$\users\*\appdata\local\Google\Chrome\User Data\Default\Extensions\*\*\manifest.json" -ErrorAction SilentlyContinue | % {
$path = $_.FullName
$_.FullName -match 'users\\(.*?)\\appdata' | Out-Null
Get-Content $_.FullName -Raw | ConvertFrom-Json | select @{n='ComputerName';e={$ComputerName}}, @{n='User';e={$Matches[1]}}, Name, Version, @{n='Path';e={$path}}
}
}
Get-ChromeExtension | ? name -notmatch '__msg_' | sort user, name, {[version]$_.version}
It returns extensions just fine. And I need to make conditions to find which extensions are and are not installed.
Something like this:
$extensions = Get-ChromeExtension | ? name -notmatch '__msg_' | sort user, name, {[version]$_.version}
if($extensions -like "NameOfPlugin")
{
#DO SOMETHING
}
I guess I cannot convert it to string this easily. Is there a different method of how can I find if "Name" contains a specific string?
You can check the name
property in this way:
if($extensions.name -like "NameOfPlugin")
{
#DO SOMETHING
}
You can also check it with -match
or -contains
.