On powershell i'm executing the following command:
$objWMI = wmic product where "name like 'app' " get PackageCache
echo $objWMI
Output:
PackageCache
C:\Windows\Installer\file.msi
I need to convert this output only to show this dir.
The variable in your example is converted to an array once the command is successfully run, with the path always being displayed on the 3rd line, so you can simply call $objWMI[2] to give you the directory only (we use the number 2 because if we wanted the first line we would use [0]).
All together it could be something simple like below.
$objWMI = wmic product where "name like 'app' " get PackageCache
$directory=$objWMI[2]
echo $directory