Saturday, February 15, 2014

Basics of Microsoft's PowerShell

Window's PowerShell (PS) is Microsoft's task automation and configuration management framework, consisting of a command-line shell and associated scripting language built on .NET Framework. Today I will be going over a few basic commands you can run immediately to get you going into exploring the full capabilities of PS.

Starting with the GET commands try going to the Start pearl in the lower left hand corner of Windows 7 and in the search bar type in "Power Shell". Once it is up and running, you can type in "GET-ACL". ACL stands for Access Control List.



The next simple command is just to get the date. Type in "GET-DATE". Now this may  seem like a simple function that serves no real use, but when you start writing scripts and you want the script to perform a particular action at a certain time, you'll need to call this function and store the data, then write an IF/ELSE statement to handle it. This gives you more control over your Operating System and within your Script.



If you are unsure on what commands are available or need help, you can type "GET-HELP".


Instead of using Windows Task Manager which lists all the currently running processes, you can run "GET-PROCESS" to dump a listing of currently running processes and you can save this data in a text file. In your script, you can say something of the nature of "IF problem GET-PROCESS". This is, of course, pseudocode.


If you would like a full listing of a specific kind of command, you can use regular expression within GET-HELP. You can type something such as "GET-HELP-Name Get-*" and this will dump out a full listing of all Get commands.



Just like dumping out what the currently running processes are, you can also dump out the currently running services and their current state. Use the command "GET-SERVICE" to get a listing of this.


I did not jump into the scripting capabilities, yet. I will have another posting for diving into the scripting facet.

No comments: