PowerShell: Shot and Forgot

    Sometimes I want to ask PowerShell to do something long, and then notify me that the work is ready. And while I do something else.

    For example like this
    cp c: \ windows \ system32 -rec d :; done
    

    (As a lengthy operation, "copy everything from c: \ windows \ system32 to d:")

    The done function displays a message that says "done" and it can be seen even if your computer is locked.
    This is achieved with such a simple piece of code in the profile:

    [System.Reflection.Assembly] :: LoadWithPartialName ("System.Windows.Forms")
    function msgBox ($ x) {
        [System.Windows.Forms.MessageBox] :: Show ($ x, 'Done!: PowerShell', 
    	[Windows.Forms.MessageBoxButtons] :: OK, 
    	[Windows.Forms.MessageBoxIcon] :: Information, [Windows.Forms.MessageBoxDefaultButton] :: Button1,
    	[Windows.Forms.MessageBoxOptions] :: ServiceNotification
        )
    }
    function done () { 
        msgBox ("done")
    }
    


    Also popular now: