PowerShell Watch Script Command

Here is a simple PowerShell script to get something similar to the watch command on line.  Just put it in your PowerShell modules directory and run “Import-Module Watch”

# Author:       John Rizzo
# Created:      06/12/2014
# Last Updated: 06/12/2014
# Example:      Watch 5 Get-Date

function Watch {
    param (
        [int]$interval = 10,

    process {
        $cmd = [scriptblock]::Create($command);
        While($True) {
            Write-Host "Command: " $command;
            sleep $interval;

Export-ModuleMember -function Watch

John Rizzo

Technology, problem solving, learning, business, society and where those things intersect is what I am always thinking about. From my hobbies to my profession I attempt to combine those interests in a way that makes the sum greater than the whole. Find out more about me at linkedin, http://www.linkedin.com/in/johnrizzo1.

You may also like...