I need to identify if the installed software (several times per host) is an 32bit or 64bit version. To do this I want to check the Execution Folder of the Service via powershell.
This is my first powershell script and I'm a bit lost. I would like to store the information of Get-WmiObject win32_service to a multidimensional array.
If I run the command selecting PathName, State and DisplayName the PathName will be shortened, for that I run this command several times. But don't know how to get is in the right fields of the array or get the right fields in my foreach
Here is what I got so far:
`$ServiceArray = @()
$ServiceArray[] = Get-WmiObject win32_service | ?{$_.Name -like 'foo_*'} |
Select PathName
$ServiceArray[][] = Get-WmiObject win32_service | ?{$_.Name -like 'foo_*'} |
Select State
$ServiceArray[][][] = Get-WmiObject win32_service | ?{$_.Name -like 'foo_*'}
| Select DisplayName
foreach($array in $ServiceArray[])
{
if ($array.Contains(\bin\test\win64\test.exe)
{
$ServiceArray[][][][] = "win64"
}
else
{
$ServiceArray[][][][] = "win32"
} `
I know that it does not work this way, but I don't know how it works correct, either.