mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-27 20:05:34 +08:00
Merge pull request #1396 from alexandair/aleksandar
Update learning-powershell.md
This commit is contained in:
commit
d66b303201
@ -103,3 +103,4 @@ 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/
|
||||
|
||||
|
@ -1,11 +1,14 @@
|
||||
Using Visual Studio Code (VS Code)
|
||||
====
|
||||
|
||||
If you are working on Linux and OS X, you cannot use ISE because it is not supported on these platforms. In this case, you can choose your favorite editor to write PowerShell scripts. Here we choose VS Code as a PowerShell editor as an example.
|
||||
If you are working on Linux and OS X, you cannot use ISE because it is not supported on these platforms.
|
||||
In this case, you can choose your favorite editor to write PowerShell scripts.
|
||||
Here we choose VS Code as a PowerShell editor as an example.
|
||||
|
||||
You can use VS Code on Windows with PowerShell V5 by using Windows 10 or by installing [Windows Management Framework 5.0 RTM](https://www.microsoft.com/en-us/download/details.aspx?id=50395) for down-level Windows OSs (e.g. Windows 8.1, etc.).
|
||||
|
||||
Before starting it, please make sure PowerShell exists on your system. By following the [Installing PowerShell](./learning-powershell.md#installing-powershell) instructions you can install PowerShell and launch a PowerShell session.
|
||||
Before starting it, please make sure PowerShell exists on your system.
|
||||
By following the [Installing PowerShell](./learning-powershell.md#installing-powershell) instructions you can install PowerShell and launch a PowerShell session.
|
||||
|
||||
Editing with VS Code
|
||||
----
|
||||
@ -35,21 +38,32 @@ Editing with VS Code
|
||||
|
||||
- After the install, you will see the **Install** button turns to **Enable**.
|
||||
- Click on **Enable** and **OK**
|
||||
- Now you are ready for editing. For example, to create a new file, click **File->New**. To save it, click **File->Save** and then provide
|
||||
a file name, let's say "helloworld.ps1". To close the file, click on "x" next to the file name. To exit VS Code, **File->Exit**.
|
||||
- Now you are ready for editing.
|
||||
For example, to create a new file, click **File->New**.
|
||||
To save it, click **File->Save** and then provide a file name, let's say "helloworld.ps1".
|
||||
To close the file, click on "x" next to the file name.
|
||||
To exit VS Code, **File->Exit**.
|
||||
|
||||
|
||||
Debugging with VS Code
|
||||
----
|
||||
|
||||
- Open a file folder (**File->Open Folder**) that contains the PowerShell modules or scripts you have written already and want to debug. In this example, we saved the helloworld.ps1 under a directory called "demo". Thus we select the "demo" folder and open it in VS Code.
|
||||
- Open a file folder (**File->Open Folder**) that contains the PowerShell modules or scripts you have written already and want to debug.
|
||||
In this example, we saved the helloworld.ps1 under a directory called "demo".
|
||||
Thus we select the "demo" folder and open it in VS Code.
|
||||
|
||||
- Creating the Debug Configuration (launch.json)
|
||||
|
||||
Because some information regarding your scripts is needed for debugger to start executing your script, we need to set up the debug config first. This is one-time process to debug PowerShell scripts under your current folder. In our case, the "demo" folder.
|
||||
Because some information regarding your scripts is needed for debugger to start executing your script, we need to set up the debug config first.
|
||||
This is one-time process to debug PowerShell scripts under your current folder.
|
||||
In our case, the "demo" folder.
|
||||
|
||||
* Click on the **Debug** icon (or **Ctrl+Shift+D**)
|
||||
* Click on the **Settings** icon that looks like a gear. VS Code will prompt you to **Select Environment**. Choose **PowerShell**. Then VS code will auto create a debug configuration settings file in the same folder. It looks like the following:
|
||||
* Click on the **Settings** icon that looks like a gear.
|
||||
VS Code will prompt you to **Select Environment**.
|
||||
Choose **PowerShell**.
|
||||
Then VS code will auto create a debug configuration settings file in the same folder.
|
||||
It looks like the following:
|
||||
```json
|
||||
{
|
||||
"version": "0.2.0",
|
||||
@ -75,7 +89,8 @@ Debugging with VS Code
|
||||
```
|
||||
- Once the debug configuration is established, go to your helloworld.ps1 and set a breakpoint by pressing **F9** on a line you wish to debug.
|
||||
- To disable the breakpoint, press **F9** again.
|
||||
- Press **F5** to run the script. The execution should stop on the line you put the breakpoint on.
|
||||
- Press **F5** to run the script.
|
||||
The execution should stop on the line you put the breakpoint on.
|
||||
- Press **F5** to continue running the script.
|
||||
|
||||
There are a few blogs that may be helpful to get you started using PowerShell extension for VS Code
|
||||
|
Loading…
Reference in New Issue
Block a user