First off never use Write-Host like this – you should be outputting objetcs
Secondly you never use a backtick after a pipe symbol – the pipe is a line continuation character in its own right
Thirdly your -ErrorAction Stop should be on the get-childitem command not the select
Fourthly you should use get-item not get-childitem
Having said all that you are very close to the solution
foreach ($service in Get-WmiObject -Class Win32_Service) {
$props = [ordered]@{
Name = $service.Name
StartMode = $service.StartMode
Status = $service.State
Manufacturer = ""
}
if ($service.PathName -like "*system32\svchost.exe*") {
$props.Manufacturer = "Microsoft"
}
else {
$path = ($service.PathName -split " /")[0]
$path = $path.Replace('"', '')
$props.Manufacturer = (Get-Item -Path $($path) |
select -ExpandProperty versioninfo |
select -ExpandProperty CompanyName )
}
New-Object -TypeName PSObject -Property $props
}
I’ve not given a full solution because many services run under C:\windows\System32\svchost.exe. You’ll need to dig into those processes and see what can be discovered