- Prison Code Breaker Diary -

=> aka: Nhật Kí Code Tù

Categories

Commonly, it's very hard for beginners to learn a new thing, especially this case, it's PowerShell. However, if you can see through its core, know the basics, and know how to search for helps or reference, it will be getting easier.
It took me about a week to learn the basis and understand the PowerShell concepts.
1. Using MSDN or MS Technet for PowerShell references.
2. Make use of some functions that provide helps.

There are two commands I use: Get-Command and Get-Help.

1. Get-Command: this function shows a list of commands being available at current session.
You can try by just typing: Get-Command, the list will show itself like this:

CommandType     Name                                 Definition                          
-----------     ----                                 ----------                          
Alias           %                                    ForEach-Object                      
Alias           ?                                    Where-Object                        
Function        A:                                   Set-Location A:                     
Alias           ac                                   Add-Content                         
Cmdlet          Add-Computer                         Add-Computer [-DomainName] 
Cmdlet          Add-Content                          Add-Content [-Path]  [-...
Cmdlet          Add-History                          Add-History [[-InputObject] 
Cmdlet          Add-Member                           Add-Member [-MemberType] 
Cmdlet          Add-PSSnapin                         Add-PSSnapin [-Name]  [...
Cmdlet          Add-Type                             Add-Type [-TypeDefinition] 

As you can see, there are 3 properties shown up: CommandType, Name, and Definition.
There are 3 types of commands: Alias, Cmdlet and Function.
+ Cmdlet: these are the core of PowerShell, it is the real command created to use.
+ Alias: these are just the other names of Cmdlets for instant call.
+ Function: these are the already written Cmdlets for instant access when you don't want to re-type the Cmdlet that are long.
Example, list all of commands that are Cmdlets:
PS> Get-Command -CommandType Cmdlet

2. Get-Help: this command provides help about PowerShell Cmdlets and concepts.
Example, if I want to get information about Get-Command, I  type
PS> Get-Help Get-Command

To get examples about the command,

PS> Get-Help Get-Command -examples

To get details about the coomand,

PS> Get-Help Get-Command -detailed

To get full info about the command,

PS> Get-Help Get-Command -full

Hope this post may help someone finding PowerShell a bit easier to learn!

0 comments

Post a Comment