To start your own learning check out Microsoft Virtual Academy:
(http://www.microsoftvirtualacademy.com/training-courses/getting-started-with-powershell-3-0-jump-start?o=3276#?fbid=aVs9FfAH2DJ)
(rewritten based on my notes available here: https://drive.google.com/file/d/0B1fwreWrAZioQ28xTmx0d29HUzQ/edit?usp=sharing)
Module 7: "Getting prepared for automation" consists of 2 video segments totaling ≈ 26 minutes along with a PowerPoint of 12 slides.
Overview
- Execution Policy (http://cleeit.blogspot.com/2014/01/MVA-powershell-m07-part1.html)
- What is it
- How to set it
- Signing scripts (http://cleeit.blogspot.com/2014/01/MVA-powershell-m07-part1.html)
- Create
- Load
- Sign
- Results
- Variables (http://cleeit.blogspot.com/2014/01/MVA-powershell-m07-part2.html)
- Defining
- Prompt for input (Read-Host)
- Output to screen
- Write-Host
- Write-Warning/Error/Debug
Output to Screen
PowerShell offers a few ways to provide output to the screen from your script. The most common is Write-Host as it provides the ability to format colors. There are some issues with using Write-Host as it breaks the ability to pipe. To maintain the pipeline use Write-Output. To provide you color text they have provided us with Write-Error / Write-Warning / Write-Debug.
Write-Host
Allows output to the screen to be formatted. Remember this breaks pipeline usage and is not best practice in a script.
Outputs:Hello
Write-Output
Way to output to screen with out breaking pipeline.
Outputs: Hello
Write-Error / Write-Warning / Write-Debug
All three of these cmdlets use the default PowerShell scheme to maintain quick recognition.
Outputs: Help, Help
Outputs: Doom, Doom
Check out the rest of this segment:
Part 1: http://cleeit.blogspot.com/2014/01/MVA-powershell-m07-part1.html
Part 2: http://cleeit.blogspot.com/2014/01/MVA-powershell-m07-part2.html
PowerShell offers a few ways to provide output to the screen from your script. The most common is Write-Host as it provides the ability to format colors. There are some issues with using Write-Host as it breaks the ability to pipe. To maintain the pipeline use Write-Output. To provide you color text they have provided us with Write-Error / Write-Warning / Write-Debug.
Write-Host
Allows output to the screen to be formatted. Remember this breaks pipeline usage and is not best practice in a script.
Write-Host "Hello" -Foregroundcolor red -BackGroundColor greenSets colors
Outputs:Hello
Write-Output
Way to output to screen with out breaking pipeline.
Write-Output "Hello"
Outputs: Hello
Write-Error / Write-Warning / Write-Debug
All three of these cmdlets use the default PowerShell scheme to maintain quick recognition.
Write-Warning "Help, Help"
Outputs: Help, Help
Write-Error "Doom, Doom"
Outputs: Doom, Doom
Check out the rest of this segment:
Part 1: http://cleeit.blogspot.com/2014/01/MVA-powershell-m07-part1.html
Part 2: http://cleeit.blogspot.com/2014/01/MVA-powershell-m07-part2.html
No comments:
Post a Comment