App-V 5 virtual processes

note: I have created a video about this blogpost, see

 Get-AppvVirtualProcess

I have used the function “Get-AppvVirtualProcess” to terminate app-v processes through stop-process. This is not a clean solution but it get things done!

I was wondering about a better solution for terminating App-V processes. Playing around with “Get-AppvVirtualProcess” i noticed the results are processnames and not the packagename.

PS C:\WINDOWS\system32> Get-AppvVirtualProcess
Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
——-  ——    —–      —–     ——     —  — ———–
2701     114    52632     123616      72,56   4736   1 explorer
1235     162   515372     529284     348,44   6584   1 firefox
560      44    33148      49020       0,78   7652   1 Greenshot
1798     128   128540     155540      47,92   6592   1 Skype

For an overview of options i used Get-Method on the PowerShell Object.

PS C:\WINDOWS\system32> Get-AppvVirtualProcess -name explorer | get-member

TypeName: System.Diagnostics.Process

Name                       MemberType     Definition
—-                       ———-     ———-
Handles                    AliasProperty  Handles = Handlecount
Name                       AliasProperty  Name = ProcessName
NPM                        AliasProperty  NPM = NonpagedSystemMemorySize64
PM                         AliasProperty  PM = PagedMemorySize64
SI                         AliasProperty  SI = SessionId
VM                         AliasProperty  VM = VirtualMemorySize64
WS                         AliasProperty  WS = WorkingSet64
Disposed                   Event          System.EventHandler Disposed(System.Object, System.EventArgs)
ErrorDataReceived          Event          System.Diagnostics.DataReceivedEventHandler ErrorDataReceived(System.Object, System.Diagnostics.DataReceivedEven…
Exited                     Event          System.EventHandler Exited(System.Object, System.EventArgs)
OutputDataReceived         Event          System.Diagnostics.DataReceivedEventHandler OutputDataReceived(System.Object, System.Diagnostics.DataReceivedEve…
BeginErrorReadLine         Method         void BeginErrorReadLine()
BeginOutputReadLine        Method         void BeginOutputReadLine()
CancelErrorRead            Method         void CancelErrorRead()
CancelOutputRead           Method         void CancelOutputRead()
Close                      Method         void Close()
CloseMainWindow            Method         bool CloseMainWindow()
CreateObjRef               Method         System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
Dispose                    Method         void Dispose(), void IDisposable.Dispose()
Equals                     Method         bool Equals(System.Object obj)
GetHashCode                Method         int GetHashCode()
GetLifetimeService         Method         System.Object GetLifetimeService()
GetType                    Method         type GetType()
InitializeLifetimeService  Method         System.Object InitializeLifetimeService()
Kill                       Method         void Kill()
Refresh                    Method         void Refresh()
Start                      Method         bool Start()
ToString                   Method         string ToString()
WaitForExit                Method         bool WaitForExit(int milliseconds), void WaitForExit()
WaitForInputIdle           Method         bool WaitForInputIdle(int milliseconds), bool WaitForInputIdle()
AppvPackageData            NoteProperty   List[VirtualProcess] AppvPackageData=System.Collections.Generic.List`1[Microsoft.AppV.AppvClientFacade.VirtualPr…
__NounName                 NoteProperty   string __NounName=Process
BasePriority               Property       int BasePriority {get;}
Container                  Property       System.ComponentModel.IContainer Container {get;}
EnableRaisingEvents        Property       bool EnableRaisingEvents {get;set;}
ExitCode                   Property       int ExitCode {get;}
ExitTime                   Property       datetime ExitTime {get;}
Handle                     Property       System.IntPtr Handle {get;}
HandleCount                Property       int HandleCount {get;}
HasExited                  Property       bool HasExited {get;}
Id                         Property       int Id {get;}
MachineName                Property       string MachineName {get;}
MainModule                 Property       System.Diagnostics.ProcessModule MainModule {get;}
MainWindowHandle           Property       System.IntPtr MainWindowHandle {get;}
MainWindowTitle            Property       string MainWindowTitle {get;}
MaxWorkingSet              Property       System.IntPtr MaxWorkingSet {get;set;}
MinWorkingSet              Property       System.IntPtr MinWorkingSet {get;set;}
Modules                    Property       System.Diagnostics.ProcessModuleCollection Modules {get;}
NonpagedSystemMemorySize   Property       int NonpagedSystemMemorySize {get;}
NonpagedSystemMemorySize64 Property       long NonpagedSystemMemorySize64 {get;}
PagedMemorySize            Property       int PagedMemorySize {get;}
PagedMemorySize64          Property       long PagedMemorySize64 {get;}
PagedSystemMemorySize      Property       int PagedSystemMemorySize {get;}
PagedSystemMemorySize64    Property       long PagedSystemMemorySize64 {get;}
PeakPagedMemorySize        Property       int PeakPagedMemorySize {get;}
PeakPagedMemorySize64      Property       long PeakPagedMemorySize64 {get;}
PeakVirtualMemorySize      Property       int PeakVirtualMemorySize {get;}
PeakVirtualMemorySize64    Property       long PeakVirtualMemorySize64 {get;}
PeakWorkingSet             Property       int PeakWorkingSet {get;}
PeakWorkingSet64           Property       long PeakWorkingSet64 {get;}
PriorityBoostEnabled       Property       bool PriorityBoostEnabled {get;set;}
PriorityClass              Property       System.Diagnostics.ProcessPriorityClass PriorityClass {get;set;}
PrivateMemorySize          Property       int PrivateMemorySize {get;}
PrivateMemorySize64        Property       long PrivateMemorySize64 {get;}
PrivilegedProcessorTime    Property       timespan PrivilegedProcessorTime {get;}
ProcessName                Property       string ProcessName {get;}
ProcessorAffinity          Property       System.IntPtr ProcessorAffinity {get;set;}
Responding                 Property       bool Responding {get;}
SafeHandle                 Property       Microsoft.Win32.SafeHandles.SafeProcessHandle SafeHandle {get;}
SessionId                  Property       int SessionId {get;}
Site                       Property       System.ComponentModel.ISite Site {get;set;}
StandardError              Property       System.IO.StreamReader StandardError {get;}
StandardInput              Property       System.IO.StreamWriter StandardInput {get;}
StandardOutput             Property       System.IO.StreamReader StandardOutput {get;}
StartInfo                  Property       System.Diagnostics.ProcessStartInfo StartInfo {get;set;}
StartTime                  Property       datetime StartTime {get;}
SynchronizingObject        Property       System.ComponentModel.ISynchronizeInvoke SynchronizingObject {get;set;}
Threads                    Property       System.Diagnostics.ProcessThreadCollection Threads {get;}
TotalProcessorTime         Property       timespan TotalProcessorTime {get;}
UserProcessorTime          Property       timespan UserProcessorTime {get;}
VirtualMemorySize          Property       int VirtualMemorySize {get;}
VirtualMemorySize64        Property       long VirtualMemorySize64 {get;}
WorkingSet                 Property       int WorkingSet {get;}
WorkingSet64               Property       long WorkingSet64 {get;}
PSConfiguration            PropertySet    PSConfiguration {Name, Id, PriorityClass, FileVersion}
PSResources                PropertySet    PSResources {Name, Id, Handlecount, WorkingSet, NonPagedMemorySize, PagedMemorySize, PrivateMemorySize, VirtualM…
Company                    ScriptProperty System.Object Company {get=$this.Mainmodule.FileVersionInfo.CompanyName;}
CPU                        ScriptProperty System.Object CPU {get=$this.TotalProcessorTime.TotalSeconds;}
Description                ScriptProperty System.Object Description {get=$this.Mainmodule.FileVersionInfo.FileDescription;}
FileVersion                ScriptProperty System.Object FileVersion {get=$this.Mainmodule.FileVersionInfo.FileVersion;}
Path                       ScriptProperty System.Object Path {get=$this.Mainmodule.FileName;}
Product                    ScriptProperty System.Object Product {get=$this.Mainmodule.FileVersionInfo.ProductName;}
ProductVersion             ScriptProperty System.Object ProductVersion {get=$this.Mainmodule.FileVersionInfo.ProductVersion;}

I find “AppvPackageData” interresting. It shows the following results.

PS C:\WINDOWS\system32> (Get-AppvVirtualProcess -name explorer).AppvPackageData

ProcessId                 : 4736
PackageName               : GNU_NotepadPlusPlus_691_W10
ProcessName               : explorer.exe
UserSid                   : S-1-12-1-3104466749-1076728120-162259091-4099479556
VirtualEnvironmentVersion : 63121a84-9274-43d2-b8ac-7ee528db8b39
VirtualEnvironmentId      : 2857b3bb-94a8-43cb-af82-140328a2de4a
PackageVersionId          : 63121A84-9274-43D2-B8AC-7EE528DB8B39
PackageId                 : 2857B3BB-94A8-43CB-AF82-140328A2DE4A

ProcessId                 : 4736
PackageName               : GNU_7ZIP_1514X64_W10
ProcessName               : explorer.exe
UserSid                   : S-1-12-1-3104466749-1076728120-162259091-4099479556
VirtualEnvironmentVersion : 73927ae0-8d77-4bc9-8a70-3dee9543e643
VirtualEnvironmentId      : 70b022f2-2403-4f05-899b-ac9426fb743e
PackageVersionId          : 73927AE0-8D77-4BC9-8A70-3DEE9543E643
PackageId                 : 70B022F2-2403-4F05-899B-AC9426FB743E

The “explorer” process contains two different packages. These packages use dynamic virtualisation to inject themself into the “explorer” process. The property “PackageVersionId” and “PackageId” are the same as “VersionID” and “PackageID”.

I have also tried the same process with a process (firefox) inside of a connectiongroup.

PS C:\WINDOWS\system32> (Get-AppvVirtualProcess -name firefox).AppvPackageData

ProcessId                 : 6584
PackageName               : Con_Firefox
ProcessName               : firefox.exe
UserSid                   : S-1-12-1-3104466749-1076728120-162259091-4099479556
VirtualEnvironmentVersion : 2a8bac12-b194-4fe1-987f-259ea8e56ca2
VirtualEnvironmentId      : 340d0276-b01a-4ab4-82d8-3670fb7b7ae3
PackageVersionId          : 2A8BAC12-B194-4FE1-987F-259EA8E56CA2
PackageId                 : 340D0276-B01A-4AB4-82D8-3670FB7B7AE3

The results use the same properties as a single package, although the name of the connnectiongroup is shown. The property “PackageVersionId” and “PackageId” are the same as “VersionID” and “GroupID”.

PS C:\WINDOWS\system32> Get-AppvClientConnectionGroup -GroupId 340D0276-B01A-4AB4-82D8-3670FB7B7AE3

GroupId            : 340d0276-b01a-4ab4-82d8-3670fb7b7ae3
VersionId          : 2a8bac12-b194-4fe1-987f-259ea8e56ca2
Name               : Con_Firefox
IsEnabledToUser    : True
UserPending        : False
IsEnabledGlobally  : False
GlobalPending      : False
InUse              : True
InUseByCurrentUser : True
PercentLoaded      : 100
Priority           : 0

With this information we are able to lookup the packages underneath this App-V process.  The following command shows all the packages underneath the firefox.exe process.

PS C:\WINDOWS\system32> (Get-AppvClientConnectionGroup -GroupId 340D0276-B01A-4AB4-82D8-3670FB7B7AE3).GetPackages()

PackageId            : 640412b2-2b58-475b-914f-81dfb53663de
VersionId            : 91e1470f-17b7-42d6-a372-d66802f1b633
Name                 : Adobe_Flash_21_W10_2
Version              : 0.0.0.1
Path                 : C:\Users\RoelBeijnes\OneDrive for Business\Apps\Adobe_Flash_21_W10_2\Adobe_Flash_21_W10_2.appv
IsPublishedToUser    : True
UserPending          : True
IsPublishedGlobally  : True
GlobalPending        : True
InUse                : True
InUseByCurrentUser   : True
PackageSize          : 52653358
PercentLoaded        : 100
IsLoading            : False
HasAssetIntelligence : True

PackageId            : 064fa364-d595-4a58-addd-850720ea6e69
VersionId            : 43ccc97d-5cfe-4940-b8e7-490eedcb1a27
Name                 : Mozilla_Firefox_46_0_1_W10
Version              : 0.0.0.1
Path                 : C:\Users\RoelBeijnes\OneDrive for Business\Apps\Mozilla_Firefox_46_0_1_W10\Mozilla_Firefox_46_0_1_W10.appv
IsPublishedToUser    : True
UserPending          : True
IsPublishedGlobally  : True
GlobalPending        : True
InUse                : True
InUseByCurrentUser   : True
PackageSize          : 98234240
PercentLoaded        : 100
IsLoading            : False
HasAssetIntelligence : True

PackageId            : 262f3e62-4578-4355-afd1-9ff456509fd9
VersionId            : 181ad950-efe5-49d8-9ac7-3116da23dda4
Name                 : GNU_VLCVideoLan_222_W10
Version              : 0.0.0.1
Path                 : C:\Users\RoelBeijnes\OneDrive for Business\Apps\GNU_VLCVideoLan_222_W10\GNU_VLCVideoLan_222_W10.appv
IsPublishedToUser    : True
UserPending          : True
IsPublishedGlobally  : True
GlobalPending        : True
InUse                : True
InUseByCurrentUser   : True
PackageSize          : 127087322
PercentLoaded        : 100
IsLoading            : False
HasAssetIntelligence : True

PackageId            : a980b72a-41b4-440d-aaee-f7e8d88554a6
VersionId            : 30d04911-ead9-4135-8716-6244a8f04dc8
Name                 : Omnis-Web-Client-6.0.1
Version              : 0.0.0.1
Path                 : C:\Users\RoelBeijnes\OneDrive for Business\Apps\Omnis-Web-Client-6.0.1\Omnis-Web-Client-6.0.1.appv
IsPublishedToUser    : True
UserPending          : True
IsPublishedGlobally  : True
GlobalPending        : True
InUse                : True
InUseByCurrentUser   : True
PackageSize          : 5754025
PercentLoaded        : 100
IsLoading            : False
HasAssetIntelligence : True

This information is very useable for troubleshooting and automation!