Here I will continue our PowerShell introduction discussion further and will discuss following topic in continuation to what we discussed in previous video:
f) Scripting
g) Using PowerShell
h) Execution policy
i) Get-help and Get-Command
j) Format output
k) Advantages and disadvantages
I have used a free tool ezvid to record this training, let me know if you have any good software name which i can use to record my session more effectively.
Please share your feedback and comments.
2. Scripting
In Windows PowerShell, script files have a .ps1 file name extension. To
run a script, type the name of the script at the command prompt. The
file name extension is optional.
For example:
c:testHelloWorld.ps1
-or-
c:testHelloWorld
3. Using PowerShell
The first topic of interest might be the Help system itself. To display
information about the Help system inWindows PowerShell, type:
get-help
Then, you might be interested in learning about a few of the basic
cmdlets, such as Get-Help, Get-Command, Get-Process, Get-Service,
and Get-Eventlog.
4. Execution Policy
• The Get-ExecutionPolicy cmdlet simply tells
you which of the four execution policies
(policies that determine whichWindows
PowerShell scripts, if any, will run on your
computer) is currently in-force.TheWindows
PowerShell execution policies include the
following:
• Restricted - No scripts can be run.Windows
PowerShell can be used only in interactive
mode.
• AllSigned - Only scripts signed by a trusted
publisher can be run.
• RemoteSigned - Downloaded scripts must
be signed by a trusted publisher before they
can be run.
• Unrestricted - No restrictions; allWindows
PowerShell scripts can be run.
• The Set-ExecutionPolicy cmdlet enables
you to determine whichWindows
PowerShell scripts (if any) will be allowed to
run on your computer.Windows PowerShell
has four different execution policies:
• Restricted - No scripts can be run.Windows
PowerShell can be used only in interactive
mode.
• AllSigned - Only scripts signed by a trusted
publisher can be run.
• RemoteSigned - Downloaded scripts must
be signed by a trusted publisher before they
can be run.
• Unrestricted - No restrictions; allWindows
PowerShell scripts can be run.
5.
6. Get-help and Get-Command
• To get help for aWindows PowerShell command, type Get-Help
followed by the command name, such as: Get-Help Get-Process .
• Get-Command can help you with. Just type Get-Command without
any additional parameters and you’ll get back a list of all the Windows
PowerShell cmdlets:
7. Format Output
• Windows PowerShell has a set of cmdlets that allow you to control
which properties are displayed for particular objects.The names of all
the cmdlets begin with the verb Format.We commonly use Format-
Table and Format-List quite often
8.
9. Advantages and Disadvantages of
PowerShell
• Advantages
• Object-Oriented
• .NET Objects and Forms supported
• More Functions compared to cmd.exe andVBScript.
More Extensible via cmdlets, plugins.
• Background Jobs
• Ease of administration
• Disadvantages
• Remoting creates openings for an attacker to exploit
• WinRM requires aWeb server to run on the server