Seperated Commercial Resources from Free ones and other minor fixes.

This commit is contained in:
Jianyun Tao 2016-07-21 19:09:45 -07:00
parent 8c92703ff1
commit c0d17ef57d
2 changed files with 65 additions and 53 deletions

View file

@ -2,50 +2,50 @@ Learning PowerShell
====
Whether you're an IT Professional or a developer, we'll help you get started with PowerShell.
In this document we'll cover the following:
installing PowerShell, samples walkthrough, PowerShell editor, debugger, testing tools and a map book for experienced bash users to get started with PowerShell faster.
The exercises in this document are intended to give you a solid foundation in how to use PowerShell.
You won't be a PowerShell guru at the end of reading this material but you will be well on your way with the right set of knowledge to start using PowerShell.
In this document we'll cover the following:
installing PowerShell, samples walkthrough, PowerShell editor, debugger, testing tools and a map book for experienced bash users to get started with PowerShell faster.
The exercises in this document are intended to give you a solid foundation in how to use PowerShell.
You won't be a PowerShell guru at the end of reading this material but you will be well on your way with the right set of knowledge to start using PowerShell.
If you have 30 minutes now, lets try it.
Installing PowerShell
----
First you need to set up your computer working environment if you have not done so.
Choose the platform below and follow the instructions.
First you need to set up your computer working environment if you have not done so.
Choose the platform below and follow the instructions.
At the end of this exercise, you should be able to launch the PowerShell session.
- Get PowerShell by installing package
* [PowerShell on Linux][inst-linux]
* [PowerShell on OS X][inst-linux]
* PowerShell on Windows
- [PowerShell on Linux][powershell-on-linux]
- [PowerShell on OS X][powershell-on-os-x]
- PowerShell on Windows
For this tutorial, you do not need to install PowerShell if you are running on Windows.
You can launch PowerShell console by pressing Windows key, typing PowerShell, and clicking on Windows PowerShell.
However if you want to try out the latest PowerShell, follow the [PowerShell on Windows][inst-win].
For this tutorial, you do not need to install PowerShell if you are running on Windows.
You can launch PowerShell console by pressing Windows key, typing PowerShell, and clicking on Windows PowerShell.
[powershell-on-linux]: https://github.com/PowerShell/PowerShell/blob/master/docs/building/linux.md
[powershell-on-os-x]: https://github.com/PowerShell/PowerShell/blob/master/docs/building/osx.md
TODO: Raghu for setup-dev-environment.md
- Alternatively you can get the PowerShell by [building it](../../README.md#building-powershell)
[inst-linux]: ../installation/linux.md
[inst-win]: ../installation/windows.md
Getting Started with PowerShell
----
PowerShell commands follow a Verb-Noun semantic with a set of parameters.
It's easy to learn and use PowerShell.
For example, `Get-Process` will display all the running processes on your system.
PowerShell commands follow a Verb-Noun semantic with a set of parameters.
It's easy to learn and use PowerShell.
For example, `Get-Process` will display all the running processes on your system.
Let's walk through with a few examples from the [PowerShell Beginner's Guide](powershell-beginners-guide.md).
Now you have learned the basics of PowerShell.
Now you have learned the basics of PowerShell.
Please continue reading if you want to do some development work in PowerShell.
PowerShell Editor
----
In this section, you will create a PowerShell script using a text editor.
You can use your favorite editor to write scripts.
We use Visual Studio Code (VS Code) which works on Windows, Linux, and OS X.
In this section, you will create a PowerShell script using a text editor.
You can use your favorite editor to write scripts.
We use Visual Studio Code (VS Code) which works on Windows, Linux, and OS X.
Click on the following link to create your first PowerShell script.
- [Using Visual Studio Code (VS Code)][use-vscode-editor]
@ -58,7 +58,7 @@ On Windows, you can also use [PowerShell Integrated Scripting Environment (ISE)]
PowerShell Debugger
----
Debugging can help you find bugs and fix problems in your PowerShell scripts.
Debugging can help you find bugs and fix problems in your PowerShell scripts.
Click on the link below to learn more about debugging:
- [Using Visual Studio Code (VS Code)][use-vscode-debugger]
@ -74,7 +74,7 @@ On Windows, you can also use [ISE][use-ise-debugger] to debug PowerShell script
PowerShell Testing
----
We recommend using Pester testing tool which is initiated by the PowerShell Community for writing test cases.
We recommend using Pester testing tool which is initiated by the PowerShell Community for writing test cases.
To use the tool please read [ Pester Guides](https://github.com/pester/Pester) and [Writing Pester Tests Guidelines](https://github.com/PowerShell/PowerShell/blob/master/docs/testing-guidelines/WritingPesterTests.md).
@ -85,24 +85,35 @@ TODO: Don & JP to fill in
| Bash | PowerShell | Description |
|:---------------|:--------------|:----------------|
| ls |ls |List files and folders
| cd |cd |Change directory
| ls |dir |List files and folders
| cd |cd |Change directory
| mkdir |mkdir |Create a new folder
| Clear, Ctrl+L, Reset | cls | Clear screen
More Reading
Further Reading
----
- Microsoft Virtual Academy: [Getting Started with PowerShell][getstarted-with-powershell]
- [Why Learn PowerShell][why-learn-powershell] by The Scripting Guys
- [Why Learn PowerShell][why-learn-powershell] by Ed Wilson
- PowerShell Web Docs: [Basic cookbooks][basic-cookbooks]
- [PowerShell eBook][ebook-from-powershell.com] from PowerShell.com
- [PowerShell-related Videos][channel9-learn-powershell] on Channel 9
- [Learn PowerShell Video Library][powershell.com-learn-powershell] from PowerShell.com
- [PowerShell Quick Reference Guides][quick-reference] by PowerShellMagazine.com
- [PowerShell 5 How-To Videos][script-guy-how-to] by The Scripting Guys
- [PowerShell 5 How-To Videos][script-guy-how-to] by Ed Wilson
Commercial Resources
----
- [Windows PowerShell in Action][in-action] by Bruce Payette
- [Introduction to PowerShell][powershell-intro] from Pluralsight
- [PowerShell Training and Tutorials][lynda-training] from Lynda.com
[in-action]: https://www.amazon.com/Windows-PowerShell-Action-Second-Payette/dp/1935182137
[powershell-intro]: https://www.pluralsight.com/courses/powershell-intro
[lynda-training]: https://www.lynda.com/PowerShell-training-tutorials/5779-0.html
[getstarted-with-powershell]: https://channel9.msdn.com/Series/GetStartedPowerShell3
[why-learn-powershell]: https://blogs.technet.microsoft.com/heyscriptingguy/2014/10/18/weekend-scripter-why-learn-powershell/
[basic-cookbooks]: https://msdn.microsoft.com/en-us/powershell/scripting/getting-started/basic-cookbooks
@ -111,4 +122,3 @@ More Reading
[powershell.com-learn-powershell]: http://powershell.com/cs/media/14/default.aspx
[quick-reference]: http://www.powershellmagazine.com/2014/04/24/windows-powershell-4-0-and-other-quick-reference-guides/
[script-guy-how-to]:https://blogs.technet.microsoft.com/tommypatterson/2015/09/04/ed-wilsons-powershell5-videos-now-on-channel9-2/

View file

@ -1,7 +1,7 @@
PowerShell Beginners Guide
====
If you are new to PowerShell, this document will walk you through a few examples to give you some basic ideas of PowerShell.
If you are new to PowerShell, this document will walk you through a few examples to give you some basic ideas of PowerShell.
We recommend that you open a PowerShell console/session and type along with the instructions in this document to get most out of this exercise.
@ -14,17 +14,17 @@ Getting Familiar with PowerShell Commands
---
In this section, you will learn how to
- create a file, delete a file and change file directory
- find syntax of PowerShell cmdlets
- get help if you needed
- discover what version of PowerShell you are currently using
- exit a PowerShell session
- get help if you needed
- find syntax of PowerShell cmdlets
- and more
As mentioned above, PowerShell commands are designed to have Verb-Noun structure, for instance Get-Process, Set-Location, Clear-Host, etc.
Lets exercise some of the basic PowerShell commands, also known as **cmdlets**.
Please note that we will use the PowerShell prompt sign **PS />** as it appears on Linux in the following examples.
It is shown as **PS C:\>** on Windows.
It is shown as **PS C:\\>** on Windows.
**1. Get-Process**: Gets the processes that are running on the local computer or a remote computer.
@ -41,7 +41,7 @@ Handles NPM(K) PM(K) WS(K) CPU(s) Id ProcessName
```
Only interested in the instance of firefox process that are running on your computer?
Only interested in the instance of firefox process that are running on your computer?
Try this:
```PowerShell
PS /> Get-Process -Name firefox
@ -51,8 +51,8 @@ Handles NPM(K) PM(K) WS(K) CPU(s) Id ProcessName
- - - 74 403.150 1209 firefox
```
Want to get back more than one process?
Then just specify process names and separate them with commas.
Want to get back more than one process?
Then just specify process names and separate them with commas.
```PowerShell
PS /> Get-Process -Name firefox, powershell
Handles NPM(K) PM(K) WS(K) CPU(s) Id ProcessName
@ -67,7 +67,7 @@ Handles NPM(K) PM(K) WS(K) CPU(s) Id ProcessName
PS /> Get-Process
PS /> Clear-Host
```
Type too much just for clearing the screen?
Type too much just for clearing the screen?
Here is how the alias can help.
**3. Get-Alias**: Gets the aliases for the current session.
@ -88,7 +88,7 @@ Alias ri -> Remove-Item
Alias type -> Get-Content
As you can see "cls" is an alias of Clear-Host.
As you can see "cls" is an alias of Clear-Host.
Now try it:
PS /> Get-Process
@ -130,8 +130,8 @@ Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 7/7/2016 7:17 PM 0 test.txt
```
You can use the **-Value** parameter to add some data to your file.
For example, the following command adds the phrase "Hello world!" as a file content to the test.txt.
You can use the **-Value** parameter to add some data to your file.
For example, the following command adds the phrase "Hello world!" as a file content to the test.txt.
Because the test.txt file exists already, we use **-Force** parameter to replace the existing content.
```PowerShell
@ -145,7 +145,7 @@ Mode LastWriteTime Length Name
-a---- 7/7/2016 7:19 PM 24 test.txt
```
There are other ways to add some data to a file.
There are other ways to add some data to a file.
For example, you can use Set-Content to set the file contents:
```PowerShell
@ -179,7 +179,7 @@ PS /home/jen> Remove-Item ./test.txt
**9. $PSVersionTable**: Displays the version of PowerShell you are currently using.
Type **$PSVersionTable** in your PowerShell session, you will see something like below.
Type **$PSVersionTable** in your PowerShell session, you will see something like below.
"PSVersion" indicates the PowerShell version that you are using.
```PowerShell
@ -203,7 +203,7 @@ PS /home/jen> exit
Need Help?
----
The most important command in PowerShell is possibly the Get-Help, which allows you to quickly learn PowerShell without having to search around the internet.
The most important command in PowerShell is possibly the Get-Help, which allows you to quickly learn PowerShell without having to search around the internet.
The Get-Help cmdlet also shows you how PowerShell commands work with examples.
It shows the syntax and other technical information of the Get-Process cmdlet.
@ -241,7 +241,7 @@ PS /> Get-Help Get-Process -Example
PowerShell Pipeline '|'
----
Sometimes when you run Get-ChildItem or "dir", you want to get a list of files and folders in a descending order.
Sometimes when you run Get-ChildItem or "dir", you want to get a list of files and folders in a descending order.
To achieve that, type:
```PowerShell
PS /home/jen> dir | sort -Descending
@ -264,24 +264,21 @@ How to Create and Run PowerShell scripts
- You can use ISE, VS Code or your favorite editor to create a PowerShell script and save the script with a .ps1 file extension (for example, helloworld.ps1)
- To run the script, cd to your current folder and type ./yourscript.ps1 (for example, ./helloworld.ps1).
Note: If you are using Windows, make sure you set the PowerShell's execution policy to "RemoteSigned" in this case.
Note: If you are using Windows, make sure you set the PowerShell's execution policy to "RemoteSigned" in this case.
See [Running PowerShell Scripts Is as Easy as 1-2-3] [run-ps] for more details.
[run-ps]:http://windowsitpro.com/powershell/running-powershell-scripts-easy-1-2-3
More Reading
Further Reading
----
Books & eBooks & Blogs & Tutorials
- [Windows PowerShell in Action][in-action] by Bruce Payette
- [Windows PowerShell Cookbook][cookbook] by Lee Holmes
- Video: [Get Started with PowerShell][remoting] from Channel9
- [eBooks from PowerShell.org](https://powershell.org/ebooks/)
- [eBooks List][ebook-list] by Martin Schvartzman
- [eBooks from PowerShell.com][ebooks-powershell.com]
- [eBooks List][ebook-list] by Martin Schvartzman
- [Tutorial from MVP][tutorial]
- Script Guy blog: [The best way to Learn PowerShell][to-learn]
- [Understanding PowerShell Module][ps-module]
- [How and When to Create PowerShell Module][create-ps-module] by Adam Bertram
- Video: [Get Started with PowerShell Remoting][remoting] from Channel9
- Video: [PowerShell Remoting in Depth][in-depth] from Channel9
- [PowerShell Basics: Remote Management][remote-mgmt] from ITPro
- [Running Remote Commands][remote-commands] from PowerShell Web Docs
@ -291,6 +288,11 @@ Books & eBooks & Blogs & Tutorials
- [Examples of Cmdlets Code][sample-code]
Commercial Resources
----
- [Windows PowerShell in Action][in-action] by Bruce Payette
- [Windows PowerShell Cookbook][cookbook] by Lee Holmes
[in-action]: https://www.amazon.com/Windows-PowerShell-Action-Second-Payette/dp/1935182137
[cookbook]: http://shop.oreilly.com/product/9780596801519.do
[ebook-list]: https://blogs.technet.microsoft.com/pstips/2014/05/26/free-powershell-ebooks/