{"id":20680289,"url":"https://github.com/markwragg/powershell-watch","last_synced_at":"2025-02-27T21:18:33.191Z","repository":{"id":41284412,"uuid":"125833027","full_name":"markwragg/PowerShell-Watch","owner":"markwragg","description":"A PowerShell Watch-Command cmdlet for repeatedly running a command or block of code until a change in the output occurs.","archived":false,"fork":false,"pushed_at":"2024-08-31T08:01:56.000Z","size":213,"stargazers_count":88,"open_issues_count":2,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-20T20:11:25.056Z","etag":null,"topics":["cmdlet","comparison","powershell","scriptblock","watch"],"latest_commit_sha":null,"homepage":"http://wragg.io/watch-for-changes-with-powershell/","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markwragg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2018-03-19T09:27:29.000Z","updated_at":"2024-12-19T05:04:43.000Z","dependencies_parsed_at":"2024-12-26T12:16:38.289Z","dependency_job_id":null,"html_url":"https://github.com/markwragg/PowerShell-Watch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markwragg%2FPowerShell-Watch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markwragg%2FPowerShell-Watch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markwragg%2FPowerShell-Watch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markwragg%2FPowerShell-Watch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markwragg","download_url":"https://codeload.github.com/markwragg/PowerShell-Watch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240997345,"owners_count":19891149,"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":["cmdlet","comparison","powershell","scriptblock","watch"],"created_at":"2024-11-16T21:30:47.424Z","updated_at":"2025-02-27T21:18:33.159Z","avatar_url":"https://github.com/markwragg.png","language":"PowerShell","readme":"# PowerShell-Watch\n\n[![Build Status](https://dev.azure.com/markwragg/GitHub/_apis/build/status/markwragg.PowerShell-Watch?branchName=master)](https://dev.azure.com/markwragg/GitHub/_build/latest?definitionId=8\u0026branchName=master) ![Test Coverage](https://img.shields.io/badge/coverage-94%25-brightgreen.svg?maxAge=60)\n\nThis PowerShell module contains a `Watch-Command` cmdlet that can be used to repeatedly run a PowerShell command or scriptblock to return output when it has changed.\n\n![Watch-Command Get-Service Example](/Media/watch-command-get-service-continuous.png)\n\n\n## Installation\n\nThe module is published in the PSGallery, so if you have PowerShell 5 can be installed by running:\n```\nInstall-Module Watch -Scope CurrentUser\n```\n\n## Usage\n\nYou can use the `Watch-Command` cmdlet by providing it with a ScriptBlock. For example:\n\n```\nWatch-Command -ScriptBlock { Get-Process }\n```\n\nAlternatively ,the cmdlet has been designed so that if it is sent any input via the pipeline other than a ScriptBlock it interprets the pipeline commands that preceded it as the desired ScriptBlock.\n\nThis is for convenience, so that you can quickly and easily add `| Watch-Command` (or its Aliases `| watch` or `| wc`) to the end of an existing set of commands to run them repeatedly and output once a change has occurred. For example:\n\n```\nGet-Service | wc\n```\n\nBy default the cmdlet will run the specified ScriptBlock every 1 second and then return its output in full once it has changed from the first iteration. You can change the duration between checks via the `-Seconds` parameter.\n\nYou can have the script run continuously (until interrupted via CTRL+C) by adding the `-Continuous` parameter.\n\nYou can have the script return only objects in a collection that have changed or been added by using the `-Difference` parameter.\n\nIf you use `-Verbose` you will see a timestamp in the console prior to a change being output (particularly useful when using `-Continuous` and `-Difference`).\n\nFor example:\n```\nGet-Service | Watch-Command -Diff -Cont -Verbose\n```\nThis command will continually list output each time one of the default properties of a service has changed state. Verbose statements above each change will show when they occurred.\n\nBy default the cmdlet uses the `Compare-Object` cmdlet to perform the comparison of the object output by the ScriptBlock with its intitial interation. If the object has a Default Display Property Set (E.g the properties that appear by default in the console) then the comparison is limited to these properties by default. Otherwise it defaults to all available properties of the object.\n\nIf you want to specify specific properties to monitor for change, you can do so via the `-Property` parameter.\n\nFor example:\n```\nGet-Process | Watch-Command -Diff -Cont -Property id\n```\n\n![Watch-Command Get-Process Example](/Media/watch-command-get-process-id-continuous.png)\n\nThis command will continually list output each time the id property of the output of `Get-Process` has changed (e.g a new process has started). \n\nBy default `Watch-Command` will use the Default Display Set of properties (if a set exists) as the properties to monitor. If a Default Display Set does not exist then it will use all properties. If you want to force the use of all properties you can specify `-Property *`.\n\nYou can also use Watch-Command to monitor non-PowerShell command output (which will generally be treated as strings). Here's an example of monitoring the output of ipconfig /all for a change to the DNS server addresses:\n\n![Watch-Command ipconfig Example](/Media/watch-command-ipconfig.png)\n\nIf you want to force `Watch-Command` to treat the result of the command as an array of strings regardless of the object type returned, you can do so via the `-AsString` parameter.\n\n## Cmdlets\n\nA full list of cmdlets in this module is provided below for reference. Use `Get-Help \u003ccmdlet name\u003e` with these to learn more about their usage.\n\nCmdlet        | Description\n--------------| -------------------------------------------------------------------------------\nWatch-Command | Runs a scriptblock or the preceeding pipeline repeatedly until there is change.\nWatch         | Alias for Watch-Command\nwc            | Alias for Watch-Command\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkwragg%2Fpowershell-watch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkwragg%2Fpowershell-watch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkwragg%2Fpowershell-watch/lists"}