You are on page 1of 80

PowerShell:

PowerShell
Command Line
2017 - Easy
Beginners Guide To
Write And Run
Scripts And Learn
Basic PowerShell
Commands!
Bonus Gift For You!
Get free access to your
complimentary book “Amazon
Book Bundle: Complete User
Guides To 5 Amazon
Products” by clicking the link
below.

>>>CLICK HERE TO
DOWNLOAD<<<
(or go to:
https://freebookpromo.leadpage
book-bundle/]
Copyright 2016 - All rights
reserved.

This document is geared towards


providing exact and reliable information
in regards to the topic and issue
covered. The publication is sold with
the idea that the publisher is not required
to render legal, financial, medical or any
professional services. If advice is
necessary, legal or professional, a
practiced individual in the profession
should be ordered.

In no way is it legal to reproduce,


duplicate, or transmit any part of this
document in either electronic means or
in printed format. Recording of this
publication is strictly prohibited and any
storage of this document is not allowed
unless with written permission from the
publisher. All rights reserved.

The information provided herein is


stated to be truthful and consistent, in
that any liability, in terms of inattention
or otherwise, by any usage or abuse of
any policies, processes, or directions
contained within is the solitary and utter
responsibility of the recipient reader.
Under no circumstances will any legal
responsibility or blame be held against
the publisher for any reparation,
damages, or monetary loss due to the
information herein, either directly or
indirectly.

The information herein is offered for


informational purposes solely, and is
universal as so. The presentation of the
information is without contract or any
type of guarantee assurance.

The trademarks that are used are without


any consent, and the publication of the
trademark is without permission or
backing by the trademark owner. All
trademarks and brands within the book
are for clarifying purposes only and are
owned by the owners themselves, not
affiliated with this document.
Table Of Contents
Introduction
Chapter 1 – Getting to Grips
with Powershell
Chapter 2 – Basic Commands
Chapter 3 - Scripting
Chapter 4 – Looping
Chapter 5 – Understanding
Piping
Conclusion
Introduction

PowerShell is a task automation


framework, which is made up of a
command-line shell and a scripting
language.
The basic principle of PowerShell is the
same as that of its more limited
predecessor Command Prompt.
They are both user interfaces, a point of
human and computer interaction. They
give the user direct access to an array of
the computer system’s features.
PowerShell is most useful for network
administrators. It can be used to simplify
and automate processes that would
otherwise take up a lot of time. It is
especially useful in facilitating
processes that need to run on multiple
files simultaneously.
A few examples of the tasks that you can
complete using PowerShell include
killing unresponsive processes,
accessing the USB ports of all
computers on a network, running time-
consuming processes in the background,
and accessing specific information about
computers and extracting it in a HTML
format.
By creating scripts and combining
multiple tasks an administrator can, for
example, accomplish a security update
across a large network of servers by
using only a single script.
Because PowerShell has access to both
COM and WMI administrators can
perform tasks on both local and remote
Windows systems.
PowerShell is the system that Microsoft
use for all their products and will do so
for the foreseeable future. As it is built
into all their computers, learning how to
use it gives the double advantage of
having skills that can be used across
Microsoft’s current range of products
and will continue to be of use in the
future.
Chapter 1 – Getting to
Grips with Powershell

How to find PowerShell on Windows


10
Accessing Powershell on Windows 10
is quick and easy. There are two ways.
1. Go to Start and use the Cortana
search tool. Type in ‘powershell’ and
you will see several options including
‘Best Match’ and ‘Apps’. Pressing
‘Enter’ will take you straight into
Powershell. Other options will include
Powershell ISE and (x86) versions.
2. Go to start and scroll down the
alphabetical list of apps. Under ‘W’ you
will see ‘Windows Powershell’ folder,
click on that and you will be given the
option of opening Powershell or the
(x86) version, and Powershell ISE or
the (x86) version.
What is PowerShell?
When typing ‘dir’ into Command Prompt
you will see a lot of text appear. This
text will include information such as
name, size, and timestamps of each file
in a given directory.
There are then two operations that you
can use.
1. Redirection, which is represented by
this symbol: >
2. Piping, which is representated by this
symbol: |
An example that will pipe the file
information to a sort program for
alphabetic ordering would be:
dir /s / b | sort
This should be familiar to all users of
Command Prompt.
The different when it comes to
PowerShell is that objects are the key
here. There are hundreds of types of
object in the .NET framework and any of
these can be used in PowerShell.
The appearance of PowerShell is
similar to that of Command Prompts, but
the actuality is somewhat different and
the focus is really on objects as opposed
to text.
Objects in the .NET Framework might
include such things as files, folders,
network services, documents etc. There
are literally hundreds.
So what does PowerShell let you do? It
lets you do all sorts of new and exciting
administrative task simplification
processes and other similar things.
So you can pipe information by
redirecting the flow of the process using
the | symbol. This is really great when
you want to manipulate say, or perhaps
alter the properties, you can even get
information from objects that you want
information from. These are all great and
new advances that can really make you
administration experience an excellent
one.
If, for example, you can you were to do
something like type ‘dir’ into
PowerShell then you might realize that it
is an synonym for the action get-item. By
equipping this action with the name of
the file that you desire to take results
from you can simply use this action and
you will have the conclusion that you
expected.
Beginning with PowerShell
If you are a complete beginner with
PowerShell then you have several
knowledge obstacles to surmount. Lets
take a look at how to begin from the
ground up.
PowerShell has many levels of
functionality. It can be used as a
scripting language or more simply it can
be put to work by using cmdlets. The
first of these processes, while garnering
more from the system in the end, is much
more difficult than the second.
The second is the place to start. It will
allow you to build your confidence and
ensure that you are not overawed by the
complexity of using PowerShell as a
scripting language.
That said, it should be noted that
scripting is a valuable tool in itself and
those with some IT administration
experience should not find it too
daunting a prospect to get to grips with.
And when they do they will find that they
can accomplish much with their newly
learned and hard won skills.
One way to treat it is to be hospitable
and recognize that it isn’t a million miles
away from previous systems
administration programs such as
Command Prompt. It is with this in mind
that we can embark upon learning about
cmdlets.
Cmdlets
The longer term of cmdlets is
commandlets, these are integral scripts
that form the basis of PowerShell use.
These can be very simply used to
perform simple tasks. For example if
you want to see the date you merely have
to write: ‘get-date’; and the current date
will be displayed for you.
To get a list of the current services
running on the machine then you need to
use the cmdlets: ‘get-service’. You then
will have a full list of the services that
are running and the ones that have been
stopped.
There are hundreds of cmdlets and there
are lists of them widely available.
Synchronizing Cmdlets
The first thing you need to understand
about getting PowerShell to do things
that are actually useful is piping. Piping
effectively means joining together
different cmdlets and letting them do
their work.

The pipe symbol is this: |

This allows different cmdlets to receive


and exchange information in order to
process complex tasks using only a
simple script.

Beginning a service on a specific


computer, for example, might be
achieved by using the piping symbol to
amalgamate the processes of two
different cmdlets. This is a distinct and
new advantage because a process that
might once have involved much more
work can now be accomplished with a
very basic piece of script writing.

So in this instance you might want to


piece together the cmdlet - ‘get-service’
and ‘start-service’. The script of this
command would look something like
this:

get-service | start-service

Here then you have a process whereby


every service that starts will be on one
computer. This happens because the
piping symbol | sends each and every
service through the start-service cmdlet.

Script Processes and Commands


PowerShell runs on script processes and
commands. These are text files with the
file name extension: .ps1.
It is possible to create a script in any
text document, Notebook is the most
basic and common, after entering a
series of commands you save the file
with a name of your choice like this:
NAME.ps1.
There are a huge amount of commands
that you can use on PowerShell. For
convenience there is a full help system
that helps you to locate which command
you need to complete a task. It will also
give you an explanation of how to use
the commands.
The help command is as follows: get-
help.
You can use this to get information about
a particular command. Simply type ‘get-
help’ and follow it with the command
you want information about and press
Enter.
If you don’t know the specific command
you will need you can also use the ‘get-
help’ command to find information by
using a keyword.
So if you wanted information about
Windows services you would need to
run: ‘get-help services’.
Help is then displayed on the
PowerShell. You can also get help by
entering the parameter ‘online’, which
then opens the help file on Microsoft’s
TechNet website on your browser.
For example running the script: ‘get-help
start-service- online’

The Console
To anyone who has previously used MS
DOS the PowerShell console will be
familiar.
The command line is a black screen with
white text and a prompt down the left
hand side.
To use it you type in commands
(cmdlets) after the prompt and these are
executed after the Enter key has been
pressed.
Chapter 2 – Basic
Commands

Basic Commands
If you are conversant with DOS
commands then you will be able to use
many of the old commands that you are
familiar with.
The process remains the same. Choose a
cmdlets, type it in, add any arguments
you desire and complete the task by
depressing the Enter key.
Commands follow the naming pattern of
‘verb-noun’.
There are new PowerShell specific
cmdlets for all the old DOS commands
but it is not necessary that you use them.
One major change that PowerShell has
wrought upon itself is that cmdlets do
not actually write on the screen itself. In
fact, what they do is to give back an
object to the console, the console then
processes it and it is displayed.
This means that you don’t have to send
objects to the console, you can instead
send them to another cmdlets. This is a
technique and it has a name, which is
piping.
Let me give you an example here. You
can use the cmdlets: ‘get-itemproperty’
and use it with the name of a file, this
will display its core qualities. So it
might read something a little like this:
‘get-itemproperty
c:\windows\regedit.exe’
This command will then result in the
returning of an object to the console. You
will see only a portion of the vast array
of information that the default displays.
Piping the object to format-list all the
different bits of information can be
shown. This is the command you will
use:
‘get-itemproperty
c:\windows\regedit.exe | format-list
The | is the pipe symbol, use this for
piping. It is a separation device, which
holds apart two cmdlets, it
communicates to PowerShell that the
output of the initial command should be
sent as the input to the subsequent
command.
This piping symbol will also occur if the
result of the cmdlets is composed of a
few objects, they will then be processed
individually, on a case by case basis and
may have the appearance as indicated in
the example below:
‘dir | get-itemproperty | format-list’
The overall conclusion that comes at the
end is a selection of files and
directories, piped, neatly, in formation
into the cmdlets get-itemproperty.
Each property is piped to a format-list,
an array of the exact file information.
The previous example displays a trio of
commands, each one connected by
pipes.
Another example could illustrate the
point with pertinence. This piece of
code should be an excellent illustration.
There is an out-file cmdlet, which has
piped to it information from a file, it then
gives back the text to the console that
can be seen on the screen. Like this:
‘dir | get-itemproperty | format-list | out-
file info.txt’
Chapter 3 - Scripting

Scripting
A script is a text file with the extension
.ps1. Text files like these will contain
strings of calls to cmdlets. This is an
alternative to working directly in the
console.
One great advantage of working with
scripts rather then in the console is that
you don’t have to execute each command
immediately after typing it. What this
does is it enables pre-processing by
PowerShell, which means that facilities
often used in programming, such as
variables, user-defined functions, and
conditional statements.
There are two methods of running a
PowerShell Script once you have
written it. Which one you use depends
on the location of the script.
1. For a script that is located in the
current directory this is the format:
./example.ps1
2. If the script is contained in a folder
then the full path is required:
c:\powershell\example.ps1
Running unsigned scripts can damage the
system, so Windows will not allow them
to be executed. This means that you have
to configure your system to run scripts
written by you, and simultaneously,
block scripts that are downloaded from
the internet.
By using this command you can achieve
this:
‘ set-executionpolicy remotesigned ’
This is the same example as used in the
above console tutorial. The purpose of
the command gives an example of the
outputting of detailed information for
each file that is contained in the current
directory.
The text is as follows:
‘ $list = dir
Get-itemproperty $list | format-list | out-
file out.txt ’
The difference between this script and
the console action is that what issues
from ‘ dir ’ is not piped directly into
the ‘ get-itemproperty ’ but is initially
stored as a variable. This variable
named list becomes declared, after this
it is used in PowerShell and it is by
prefixing a dollar sign that this is
achieved.
It is entirely possible to make the
creation of the script happen in Notapad.
If you do this then you can save the file
as, for instance, ‘ example.ps1 ’ .
In order to run the script you then return
to the console and you inscribe on the
console the file path.
After doing this you issue the execute
command: Enter.
This will then complete the action and
the command will run as you want it to.
Typing it into the console should look
like this:
.\example.ps1
This facilitates the possibility of
rerunning of the script on multiple
occasions. In this case you don ’ t have
to re-type the script again and again, you
simply enter the file path and hey presto
the task is executed in the same manner.
You can even run the same script on as
many different computers as you want
simply by saving the file to a portable
memory device, or similar file transfer
system.
This example illustrates the inherent
adaptability of scripting for PowerShell.
In this example the directory listing is
stored in the variable list, the difference
here is that the process is individually
each time, and by the script and not by
the cmdlet.
Lets take a look at the script here:
‘ $list = dir
foreach ($item in $list) {
$fn = $item.name + "_.txt"
get-itemproperty $item | format-list |
out-file $fn
}’
By using the foreach loop it runs
through each item, then the directions
contained in between the curly brackets
{} become newly processed for each
item.
The process then ends up being
something like this: the current item gets
attributed to the variable item. An
object each item is, it outlines the
properties, each of a file or of a
directory.
New variables are created, is becomes
what it is by having the filename
attributed to it. And this is the substance
of ‘fn’. An underscore is an addition, as
is a ‘.txt’
An argument then ensues, it is the ‘get-
itemproperty’ one. This collects the
properties in much detail of each one
and passing.
What has been got back is piped, it is
piped into a format list, you then
achieve a detailed look at what it is.
In conclusion the items of the property
are exported to a new text file. This is
done by the use of the filename that was
used and calculated on the above line in
the list.
A real life situation in which you might
actually want to use something like this
is when you need to create a lot of text
files. A code such as the one lucidly
explicated above might be used to
extract a lot of files created exactly by
this script.
Another clear example of how you
might do this can be found here, a
complete tyro could easily pick this up
within say, ten minutes, it really is that
quotidian and basic.
‘$list = dir
foreach ($item in $list) {
$fn = $item.name + "_.txt"
if (test-path $fn) {
del $fn
}
}’
A slight difference here is the
conditional statement ‘if’, also the
cmdlet ‘test-path’, these alight on a
novel way of examining the ontology of
the file, if it is said to have digital
substance then the script will eliminate
the file, eternally.

Basic Principles of Scripting.


A script will certainly need to do more
than one thing, that is a given. You
wouldn’t need a script if you needed to
do anything less than one thing.
Scripts are everywhere, you find them
in IT administration systems just as
much as you find them in the hand of
actors. In fact they are years old, many
IT administrators have been using them
for many years and they are, thus,
entirely familiar with them and will use
them almost every working day of the
year.
One method in which IT administrators
might use scripts are login scripts.
These are scripts that are designed for
and used as scripts to login to the
desktops of users and digital places that
are configured with the same regularity
that a user logs on to their desktop. In
this case scripts are very valuable,
some might say even essential.
With the advent of Microsoft’s
PowerShell you might say that things
have been taken to another level. It
wouldn’t be too much of an
exaggeration to say that you can do
almost anything with a script, this
versatility veers from the nascent:
working a box fresh system straight out
of the factory into the hands of the IT
administrator, in this case you might
want to use a script to install an
operating system from the bottom up.
Other tasks that are fulfilled by scripts
include file server roles and Exchange
installation.
It is true to say that the fundamental
supporting concept of a script is to
complete two or three tasks before
coming to the end.
There are a several elements that
comprise a script. Initially you have the
element that is the variable. The
secondary element is the thing that takes
the load on its shoulders and completes
the task, in other words it does the
digital donkey work.
This is an important distinction and one
that you would do well to remember, to
this end we are now about to go into
more detail about these two aspects of
scripting.

1. Variables
The main point here of writing and
running a script is to make the computer
system run a task over and over again,
and complete this is a manner than is
identical each turn.
There are two aspects here. One is to
exemplify the action. This is the
movement that is going to be performed,
this is the crux of the matter and your
definition of it.
The second will see you ensure that this
action is capable of being performed, in
the same manner, on a different object.
This is where variables come into the
picture.
A variable is a blank space and it is in
this space that you enter the value of the
thing that you want to change. In here
you can put words, numbers etc.
The symbol for a variable in
PowerShell is a prefix of the dollar
sign: $
By using the dollar sign you are making
a declaration of the variables. These
might look like this:
$number = 12345
$location = ‘San Francisco’
$name = ‘Michael’
$listofnumbers = 1,2,3,4,5
$date = 3/8/17

The key here is to implement the dollar


sign, PowerShell can then read this and
know that you mean a variable. Note
that the syntax for this command does
not allow for a space between the
symbol and the name of the variable,
this is followed by the equals sign,
which opens up the system to the
variable. Finally it is up to you to
decide on the variable.
If the variable is a word then you need
to use apostrophes on either side of the
word. It is possible to leave the
variable empty if you don’t know what
it will consist of yet.
Another variable suggestion is the
output that is cmdlet. This is a sign and
it will allow you to access the easiest
part of .NET coding, which actually
gives you back a result. This will come
from one of two places, the first of
these two places is the PowerShell
prompt. The second of these two places
is a script.
The cmdlet ‘get-process’ enables you to
list all processes. The cmdlet ‘get-
PSSnapin’ will bring you the
contemporary snap-ins on PowerShell,
these aloow for brand new
functionality.
The total number of cmdlets can be
found if you use ‘(get-
command_.count’. This gives you a full
system of cmdlets and allows you to
look through it. There are over a
thousand cmdlets on this list, so you
will havve plenty to go at when you do
this.
Chapter 4 – Looping

Looping
There are many types of looping
procedures that you can perform, here is
the beginners guide. This will get you up
and running loops in no time. There are
two main types of loop detailed here.
The first is called Do While and serves
as a perfect introduction to the looping
process. The second takes you into
slightly deeper territory, it is called For
Each and allows you to set a task for
PowerShell to perform on any given set
of values.
Do While
One example of a loop is Do While, this
is one of the simplest and therefore
easiest loops to perform in PowerShell.
You can learn how to do this very easily
if you follow steps set out here.
A definition of a loop might run as
follows: a code that performs a specific
task and does that task over and over
again in a repetition of the same process.
This is why it is called a loop, because
it performs the same task over again in a
loop, hence then name: loop.
It will end up doing this task until a
condition changes the process and
disrupt the task and then it will cease
doing the task. Either this or until the set
of files and things have been completely
used up and no longer have any to do.
The Do While script uses a typically
ingenious method of naming a process,
one often used by computer science
boffins. It describes the task by saying
what it does. So in this case we can
suppose, with absolute clarity, that the
process is one that will be performed
until you reach a pre-set condition. It
might be regarded as a shortening of the
phrase do while you are commanded not
to.
As with most things on PowerShell the
are two ways to do this. These are
details of how to successfully perform
both, so that you have a great and full
understanding of what it is you are
undertaking to complete.
1. Do followed by a left curly bracket
on the same line:
DO {
This is a method that will enable you to
complete the task rather efficiently. You
will want a set of commands to be
repeated and this repetition can go on for
as long as you want. You will also set up
a condition that will be in place for the
conclusion of the repetition, indeed it
will bring it about. The task will be
repeated as many times as you want it to
be.
After writing the DO and the left curly
bracket {, you will got to the next line.
On this new line you will write the
cmdlets that you want to run. Finally, you
will put a right curly bracket } on the
line below and append the word While
and a pair of normal brackets () inside
of which you will write your conditional
statement. This statement must be binary,
either true or false, anything that is
ambiguous will not be understood.
This is an example of the Do While
loop:
Set a variable, say the number 1. Setting
a variable must be done using the dollar
$ sign and equals. This Do While loop is
set up to add 1 to the number in the
variable until it reaches the number 10.
It will look something like this:
Do {
$numbers = $numbers + 1
Write-Host "The current value of the
variable is $numbers"
} While ($numbers –lt 10)

For Each
The second looping method is called For
Each. For Each works by isolating
individual items from a larger set and
analysing the component parts on a case
by case basis. You then should augment
this process by setting the performance
of an action or group of commands to be
acted out upon the process.
As an example we might take a task in
which you need to isolate a group of
items in your directory. So we might take
something such as might be used by the
department or employees who deal with
HR at a particular company. They might
be instituting a process that takes action
on certain colleagues from a large
database. The task might be to cancel the
active processes that act upon the
account of each employee automatically,
without prompt from a human agent.
In this case perhaps the employees are
ones who have resigned, been sacked,
retired, or are no longer part of the
company for whatever reason. These
might be employees who have deserted
the employment of the company within a
given amount of time previous to the
institution of the action.
This is an eventuality that you can use
the loop For Each to complete. In order
to complete this action you need to use
the curly brackets again { Open the
sequence with the list of users. Then hit
the words For Each and the then follow
it with a parenthesis in which you should
write the words: user in that list, so that
it follows on from the ForEach tag and
makes sense if you were to read it out.
Next use, on the line below, a left curly
bracket {
Next you need to specify what it is you
are looking to accomplish, so on the next
line you might write ‘disable process X
on the users above so that it stops
permanently’. After this you need to hit
the close curly bracket and that looks
like this }.
So the whole thing would be set out as
below in the window you can see:
ForEach (user in that list)
{
disable process X on the users above
so that it stops permanently
}

The part of the For Each loop that can be


varied in order to resolve another set of
purposes. In this instance we used the
keyword In and that was in the
parenthesis, this tells the PowerShell
program that it has to do something, it is
the actionable item. And it is the most
important thing.
What is actually does is to set a
variable, this variable is then set for the
action to work on. What this means is
that the values that come out are
registered by the PowerShell as it goes
through the list. One at a time, you will
find that the shell moves and performs
when set to by this word.
So lets look at an example for you to be
going on with.
So we might have a list of names:
(remember that lists of things begin with
the dollar sign, like this: $)
$names = ‘Mr White’, ‘Mr Black’,
’Mrs Blue’, ‘Miss Gray’, ‘Mr Pink’,
‘Mrs Yellow’
After you have inserted your list, which
should look something like the example
provided above. Making a list within a
variable is called an array. This is
simply an enormous web of practical
difficulties, these are pronounced and set
upon. In reality it allows the PowerShell
to play good host to a large pack of
individuals or items.
Once an array is established the
PowerShell can take one piece at a time
and go through it with absolute
thoroughness. In order to display how
this works we can see here that a count
variable can be started. So:
$count = 0
This is like the starting gun; it starts the
loop. The loop here will tally the total
amount of names that are in the list that
we set to task. It is within the
parentheses that you will name the
variable, the variable has to be whatever
you want it to be named. This is your
choice, you can call it whatever you
like.
The purpose of this variable is to
contain the names that are extracted from
the list of names that have been set up
for PowerShell to deal with. In this case,
the example, let the variable be called
one name. So it will look like this:
$onename
So PowerShell works its way down the
list and removes each name that
conforms to the preconditions you have
set it for the task. Once it has found a
value that conforms it continues to
process and finds all the others that are
present in the list. This is the essence of
a loop, to perform a single task over and
over, so that all the things that need to be
completed can be completed with one,
simple script.
In this example the script, when it has
been written in the shell, will look like
this:
ForEach ($onename in $names) {
$count += 1
Write-Host ‘$onename’
}

You may be wondering what the +=


signs mean as before you will be used to
seeing on the = sign on its own without
the + sign. Well these signs, when put
together, have the meaning that they are
delineating the next step onwards. So
when it says:
+=1
The computer reads this as taking one
step at a time. If you knew that all the
names were going to be in even or odd
numbers on the list you could put +=2,
and this would skip half of the numbers
and make the task completion an even
quicker turn around.
The next instruction that is on the line
below is called Write-Host, and this
comes on the same line as the variable
value. The purpose of this is offer us a
greater insight into the current workings
that PowerShell is going through on the
loop. This enables you to keep track of
what is going on and ensures that you
never get confused.
The addition of the Write-Host line
gives you a clear picture of the result of
your task. By using this you get the
answer to your query clearly stated, in
this case the answer will be the total
number of names in the list. So, in order
to get this you will add a Write-Host line
at the end of the script, after the } right
hand curly bracket has close the
actionable section.
It will look like this:
Write-Host "The total number of
names is $count."
This is the second way of running loops.
There are plenty of tasks you can get
done with this script and there are plenty
more loops to learn. This is a very
versatile tool and is great at drawing out
vital statistics, performing a pre-set
action on all specified values, and
simplifying your IT administration tasks.
Chapter 5 – Understanding
Piping

Piping is a procedure that is common to


PowerShell and you will have come
across it a few times already in this
guide. This chapter focusses on how to
understand the principles behind piping
and how to get to grips with putting it
into action.
You will learn the reason for piping,
how it makes things flow more easily
and come to understand why the
computer nerds delved into the
cobwebbed attics of their imaginations
and named it piping.
Nevertheless piping is a great tool for
PowerShell, its organisational abilities
are really first rate. You will not be
disappointed that you have spent the time
learning about this procedure because,
just like all the procedures detail herein,
they are ultimately time saving devices
for your IT administration tasks.
And anyone who is making it in business
knows that time really is money and, not
to put to fine a point on it, time is of the
essence in this ephemeral life. So
learning piping can become another
instance of that old adage: to speculate
is to accumulate. In this instance you are
speculating time to accumulate more
time, which is money. So in the end you
and your business will be better off for
learning about how to pipe in
PowerShell.

Piping
You can use piping in almost all places
on Powershell. The piping does not take
place in the interstices of the commands
but rather takes the objects and pipes
them.
The symbolic representation of piping,
as you will have already seen, is: |
This is the same symbol as has been
used in previous versions of IT
administration, however, in this case
there is something new involved with
PowerShell.
Utilization of the cmdlet Out-Host gives
you information taken from the a position
of another command and displays the
information in a normal text format, as
lines of text and data. This can be
confusing and poor for quick reference.
By using the Out-Host cmdlet in
conjunction with the Paging command
on the occasion of having a lot of
information coming from the output, you
can use the piping cmdlet in order to
cimply things a little bit.
Processes that take a lot of juice from
the computer can really benefit here.
This is all about the display of the
processes in the console window. The
console window is required to display
its information in text format, this
representation of what is really
computing can be very difficult and takes
time to sift through.
The information is beamed to the cmdlet
Out-Host when the system has
something to display. The previous
cmdlets can halt the process at this point
until the next piece of information is
available for display.
To illustrate this try running this script in
your PowerShell console:
Get-Adultitem C:\Windows - Recurse
And then compare it to this one:
GetAdultitem C:\Windows - Recurse |
Out-Host -Paging
Notice the use of the piping symbol in
the second code.
This is a great way to simplify your
processes and can save you so much
time it is unreal.

Commanding Piping
The main thing to remember when
becoming a fully fledged pipe
commander is that PowerShell is an
object focussed console.
The user has the distinct advantage of
being able to ascertain the package
related information that becomes
available. A specific extraction can then
take place in order for the correct
information to be loosed; it really is a
great way of accomplishing the task that
you have set yourself.
For instance the Get-Location
command, which is a commonly used
cmdlet, can be used in a variety of ways.
It sends back information resulting from
a different path. This information goes
by the name of PathInfo and it is an
object. The computer than decides how
to display things and does it in a way
that is great for all concerned.
PowerShell helps you to send
information to an alternative output,
which is an invaluable tool when
completing IT administration tactics.
Conclusion

Microsoft PowerShell is a step-up from


previous versions of system
administration. The processes that can
be completed on this are manifold and
universal.
From extracting information to
performing tasks at an increased rate of
production, PowerShell has it all.
Contained here are just a few basic
instructions on how to begin your
inevitable mastery of PowerShell. One
might say you have ‘come out of your
shell’ by reading this dispensable guide.
From learning about the basic principles
of PowerShell, to learning about
cmdlets, to learning about how to write
your very own first script, and learning
how to detail such practical wizardry
and loops and pipes. You are now ready
to put your learning into play and
develop your own distinctive
PowerShell praxis.

You might also like