I have an Application, that runs multiple instances of itself. e.g
AppName.exe instance1 AppName.exe instance2 AppName.exe instance3
Using
you can use the get-process cmdlet instead of using wmi :
$procid=get-process appname |select -expand id
$procid=(get-process appname).id