{"id":16567019,"url":"https://github.com/sangafabrice/process-inspector-mvc","last_synced_at":"2025-08-20T18:40:22.803Z","repository":{"id":221096695,"uuid":"753393657","full_name":"sangafabrice/process-inspector-mvc","owner":"sangafabrice","description":"The Process Inspector inspects individual processes and provides an option to stop them. It is a simple GUI application built with PowerShell WinForms and structured on the MVC architecture.","archived":false,"fork":false,"pushed_at":"2024-04-05T23:23:10.000Z","size":79,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"module","last_synced_at":"2025-01-15T23:42:40.974Z","etag":null,"topics":["adapter-pattern","factory-method-pattern","gui","mediator-pattern","mvc","task-manager"],"latest_commit_sha":null,"homepage":"https://www.powershellgallery.com/packages/ProcessInspector","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sangafabrice.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-06T02:57:36.000Z","updated_at":"2024-12-21T10:30:08.000Z","dependencies_parsed_at":"2024-04-06T00:25:41.477Z","dependency_job_id":"fbba3c8f-b31a-4e6e-900c-b5d8fb6fbfbd","html_url":"https://github.com/sangafabrice/process-inspector-mvc","commit_stats":null,"previous_names":["sangafabrice/process-inspector-mvc"],"tags_count":0,"template":false,"template_full_name":"sangafabrice/module-build-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangafabrice%2Fprocess-inspector-mvc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangafabrice%2Fprocess-inspector-mvc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangafabrice%2Fprocess-inspector-mvc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangafabrice%2Fprocess-inspector-mvc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sangafabrice","download_url":"https://codeload.github.com/sangafabrice/process-inspector-mvc/tar.gz/refs/heads/module","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242008787,"owners_count":20056963,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adapter-pattern","factory-method-pattern","gui","mediator-pattern","mvc","task-manager"],"created_at":"2024-10-11T21:05:22.675Z","updated_at":"2025-03-05T10:28:02.882Z","avatar_url":"https://github.com/sangafabrice.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## **Use MVC to make a GUI with PowerShell WinForms: the Process Inspector** \n![Module Version](https://img.shields.io/badge/version-0.0.1-teal)\n[![CD of ProcessInspector](https://github.com/sangafabrice/process-inspector-mvc/actions/workflows/publish-module.yaml/badge.svg)](https://github.com/sangafabrice/process-inspector-mvc/actions/workflows/publish-module.yaml)\n\nAuthor: Fabrice Sanga\n\u003cbr\u003e\n\u003cbr\u003e\n\nYou might be familiar with the **Task Manager** in Windows, which you rush to when a program window stops working abruptly and notifies you that its process is _Not Responding_.  You then have no option other than clicking the button to _End Task_. By the name you guess, it manages tasks. It has many more features than inspecting and ending processes like monitoring system performance, starting tasks, etc.\n\nThe **Process Inspector** dialogue box is another reinvented wheel that inspects individual processes and provides an option to stop them. It is a simplified view of the Task Manager. However, it is a practical starter for making GUI applications in PowerShell while applying the **Model-View-Controller (MVC)** architecture.\n\nHere is the link to the demo of the Process Inspector [on YouTube](https://youtu.be/_qvuhucREUY). :film_strip:\n\n\u003cimg src=\"https://gistcdn.githack.com/sangafabrice/a8c75d6031a491c0907d5ca5eb5587e0/raw/406120be7a900c3998e33d7302772827f20539f0/automation.svg\" alt=\"Custom Powershell Module Icon\" width=\"3%\"\u003e [![Downloads](https://img.shields.io/powershellgallery/dt/ProcessInspector?color=blue\u0026label=PSGallery%20%E2%AC%87%EF%B8%8F)](https://www.powershellgallery.com/packages/ProcessInspector)\n--\n\u003cbr\u003e\n\nThe project is a PowerShell module structured around three nested module scripts **ProcessInspector.Model.psm1**, **ProcessInspector.View.psm1**\u003c/span\u003e, and **ProcessInspector.Controller.psm1** in the `.\\module` subfolder provided that the paths are relative to the module base directory in `PSModulePath`.\n\u003cbr\u003e\n\n```\nProcessInspector\n│   ProcessInspector.psd1\n│\n└───module\n    │   ProcessInspector.Controller.psm1\n    │   ProcessInspector.Model.psm1\n    │   ProcessInspector.View.psm1\n    │\n    └───script\n            Get-ProcessInspectorUIAdapter.ps1\n            ico.bmp\n            New-ProcessInspectorUI.ps1\n            Set-ProcessInspectorUIAdapterProperties.ps1\n```\n\u003cbr\u003e\n\n## 1. The ProcessInspector.View nested module\n\nThe module contains all the code related to the user interface, which is built using **Windows Forms**. It exports its only function **New-ProcessInspector**, referred to as a **Factory Method** that creates a new process inspector dialogue object that contains all the graphic elements.\n\n```PowerShell\nPS\u003e Import-Module ProcessInspector\\module\\ProcessInspector.View.psm1\nPS\u003e New-ProcessInspector | Get-Member -MemberType Script* | Select-Object Name,MemberType\n\nName                        MemberType\n----                        ----------\nDisplay                   ScriptMethod\nDispose                   ScriptMethod\nOnProcessListDropDown     ScriptMethod\nOnProcessSelected         ScriptMethod\nOnRefreshTick             ScriptMethod\nOnTerminateProcessClick   ScriptMethod\nMemoryUsage             ScriptProperty\nProcessList             ScriptProperty\nProcessName             ScriptProperty\nSortByName              ScriptProperty\nTotalMemoryUsage        ScriptProperty\n```\n\u003cbr\u003e\n\nWith the previous commands, we list the custom methods and properties of the Process Inspector UI object. It inherits its other members from the `PSCustomObject` type. You can unbind the parameter `MemberType` from `Get-Member` to get the complete list of members.\n\nThe created Process Inspector UI object encapsulates the bare **WinForms** user interface. The logic of the function `New-ProcessInspector` depends on the **Adapter Design Pattern**. The first script on which the View module depends, **New-ProcessInspectorUI.ps1**, returns the WinForms dialogue box object decorated with a timer and other note-properties that refer to graphic elements which state or behavior change. The commands below are executed from the `PSModulePath`.\n\n```PowerShell\nPS\u003e .\\ProcessInspector\\module\\script\\New-ProcessInspectorUI | Get-Member -MemberType NoteProperty | Select-Object Name\n\nName\n----\nButtonToTerminateProcess\nCheckBoxForSortByNameOption\nComboBoxForProcessName\nLabelForMemoryUsage\nLabelForTotalMemoryUsage\nTimer\n```\n\u003cbr\u003e\n\n`New-ProcessInspector` returns an adapted view of the user interface form with the successive calls to **Get-ProcessInspectorUIAdapter.ps1** and **Set-ProcessInspectorUIAdapterProperties.ps1** scripts.\n\nFirst, the controls convert to the values they contain:\n+ **ComboBoxForProcessName** converts to **ProcessName** and **ProcessList**,\n+ **CheckBoxForSortByNameOption** converts to **SortByName**,\n+ **LabelForMemoryUsage** converts to **MemoryUsage**,\n+ **LabelForTotalMemoryUsage** converts to **TotalMemoryUsage**.\n\nThen, the controls and timer convert to a unified set of event listeners:\n+ **ComboBoxForProcessName** listens to **OnProcessSelected()** and **OnProcessListDropDown()**,\n+ **ButtonToTerminateProcess** listens to **OnTerminateProcessClick()**,\n+ **Timer** listens to **OnRefreshTick()**.\n\nThe method **Display()** starts the timer and opens the dialogue box. The timer stops when the dialogue box closes. **Dispose()** releases resources.\n\nHere is the link to the demo of the View [on YouTube](https://youtu.be/2To7t4ZtoW0). :film_strip:\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 2. The ProcessInspector.Model nested module\n\nThe module is stateless and exports three simple functions. Their goal is to read data related to processes on the local system.\n+ **Get-ProcessInstance** gets a list of custom process objects. It only returns process names when it binds the parameter **NoMemoryUsage** switch for faster processing time when the user ticks the option to sort the list by names.\n+ **Get-ProcessMemoryUsage** returns the memory usage in megabytes (MB) of a specified process as computed in Task Manager. Here is the link to the comparison of values between the Task Manager and the Process Inspector [on YouTube](https://youtube.com/shorts/XL0X0GET7Vo?feature=share). :film_strip:\n+ **Get-TotalMemoryUsage** returns the total memory usage of the local computer and displays it as a percentage value.\n\n```PowerShell\nPS\u003e Import-Module ProcessInspector\\module\\ProcessInspector.Model.psm1\nPS\u003e Get-ProcessInstance | Sort-Object MemoryUsage -Descending | Select-Object -First 10\n\nName                      MemoryUsage\n----                      -----------\nchrome                  1647558656.00\nCode                    1311846400.00\nMsMpEng                  360693760.00\nmsedge                   347893760.00\nsvchost                  206532608.00\nStartMenuExperienceHost  176316416.00\ndwm                      136261632.00\nVideo.UI                 132186112.00\nexplorer                 130179072.00\npwsh                     128028672.00\n\nPS\u003e Get-ProcessInstance -NoMemoryUsage | Select-Object -First 10\n\nName\n----\nAgentService\nApplicationFrameHost\napp_updater\naudiodg\nbackgroundTaskHost\nchrome\nclient32\ncmd\nCode\nCompPkgSrv\n\nPS\u003e Get-ProcessMemoryUsage chrome # in MB\n1440.44\n\nPS\u003e Get-TotalMemoryUsage # in %\n74.71\n```\n\u003cbr\u003e\n\n## 3. The ProcessInspector.Controller nested module\n\nThe Controller module is a **Mediator** between the View and the Model, both decoupled from each other. It exports three functions whose tasks are as follows:\n+ **Reset-ProcessInspector**: initializing the User Interface or resetting it,\n+ **Show-ProcessInspector**: displaying the Process Inspector dialog window,\n+ **Stop-ProcessInspector**: disposing of the resources.\n\n`Reset-ProcessInspector` is where the **event handlers** are defined. The Controller performs only one **Delete** operation on the data when the **OnTerminateProcessClick** is raised. When the user clicks **\"Terminate Process\"**, the selected process is deleted from the dropdown list and stopped from running on the local system.\n\n**Read** operations happen when the user opens the dialogue to display the overall memory usage of the local system, when she clicks the combo box to list processes, and when she selects one to show its memory consumption.\n\nAt last, the **ProcessInspector** manifest indexes the Controller as the root module and exposes its functions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsangafabrice%2Fprocess-inspector-mvc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsangafabrice%2Fprocess-inspector-mvc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsangafabrice%2Fprocess-inspector-mvc/lists"}