Generating Powershell scripts by working in Windows GUI

My understanding is that virtually all "real work" done by the various GUI components in Windows Server 2012 (for example, in Disk Management) is performed by invoking Powershell. (That is, there's nothing that can be done in the GUI that can't be done with Powershell.)

The ability to see and/or collect the various Powershell actions taken by Windows as you're using the GUI would be terribly valuable. You would turn this feature on, do the configuration work you need to do, and turn it off, resulting in one or more Powershell scripts that automate what you just did by hand. (Of course, the script(s) likely could be parameterized in various ways.) The time saved by not having to figure out which cmdlets are used to do various tasks, and what options are passed to them, would be enormous -- even just knowing what cmdlets are used would give you quite a leg up on figuring out how to automate things.

This capability would be just like turning on the Macro Recorder in Excel, doing your operation, and turning it off -- examining the resulting macro tells you what underlying objects are being manipulated, and how, to obtain the result that you got easily using the Excel GUI.

Does this capability exist? How do you turn it on and off? (I've googled and binged myself silly but have not seen anything that says how to do it -- or even says explicitly that it's possible -- even though I could swear I've read/heard about it on some blog or podcast, back at a time when I didn't care about Powershell.)

Any information would be appreciated.



Read more here: https://stackoverflow.com/questions/17459077/generating-powershell-scripts-by-working-in-windows-gui

Content Attribution

This content was originally published by J.Merrill at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: