[Powershell Tutorial] PowerShell Basics 12-03-2011, 04:08 PM
#1
1) Writing To PowerShell Console
A. Formatting colors*
B. Multiple colors on same line*
- Note: Usable Colors -
• Black
• DarkBlue
• DarkGreen
• DarkCyan
• DarkRed
• DarkMagenta
• DarkYellow
• Gray
• DarkGray
• Blue
• Green
• Cyan
• Red
• Magenta
• Yellow
• White
2) Pipelining Data to Text Files
Create Text File:
Append to Text File:
3) Getting data from files
4) Other Miscellaneous things to keep in mind
A. I'm no good at making random tutorials. So suggest something for a future powershell tutorial by me after this
B. Signs
• @ - Array
• % - Hash Array
• $ - Variable
• | - Pipeline
• # - Comment all after this symbol
• .. - Range
C. Special Variables:
• $_ – Contains the current pipeline object, used in script blocks, filters, and the where statement.
• $Args – Contains an array of the parameters passed to a function.
• $Error – Contains objects for which an error occurred while being processed in a cmdlet.
• $Home – Specifies the users home directory.
• $PsHome – The directory where Windows PowerShell is installed.
Code:
Write-host "This is a basic message"Code:
Write-warning "This is a warning"A. Formatting colors*
Code:
Write-host "Hello" -foregroundcolor "magenta"B. Multiple colors on same line*
Code:
write-host "first words " -foregroundcolor "magenta" -nonewline; write-host "second set of words" -foregroundcolor "cyan"- Note: Usable Colors -
• Black
• DarkBlue
• DarkGreen
• DarkCyan
• DarkRed
• DarkMagenta
• DarkYellow
• Gray
• DarkGray
• Blue
• Green
• Cyan
• Red
• Magenta
• Yellow
• White
2) Pipelining Data to Text Files
Code:
$Proc = Get-Process | Out-File -Filepath Output_Proc_List.txtCreate Text File:
Code:
$Proc = Get-Process > Output_Proc_List.txtAppend to Text File:
Code:
$Proc = Get-Process >> Output_Proc_List.txt3) Getting data from files
Code:
Get-Content "C:\file.txt"4) Other Miscellaneous things to keep in mind
A. I'm no good at making random tutorials. So suggest something for a future powershell tutorial by me after this
B. Signs
• @ - Array
• % - Hash Array
• $ - Variable
• | - Pipeline
• # - Comment all after this symbol
• .. - Range
C. Special Variables:
• $_ – Contains the current pipeline object, used in script blocks, filters, and the where statement.
• $Args – Contains an array of the parameters passed to a function.
• $Error – Contains objects for which an error occurred while being processed in a cmdlet.
• $Home – Specifies the users home directory.
• $PsHome – The directory where Windows PowerShell is installed.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]


![[+]](https://sinister.li/images/modern/collapse_collapsed.png)