📜 ⬆️ ⬇️

Powershell: shot and forgot

Sometimes I want to ask PowerShell to do something long, and then notify me that the work is done. And while I can 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 you can see it even if your computer is locked.
This is achieved by 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")
 }


')

Source: https://habr.com/ru/post/59630/


All Articles