Powershell not s parte 1

So I watched these MSFT videos, here https://www.microsoftvirtualacademy.com/en-us/training-courses/getting-started-with-powershell-3-0-jump-start-8276
, that where so helpful in understanding powershell. Much better than most reference
book that I’ve used and if you pair some of this info with the Virtual Academy
lab environments you might just learn a very small amount of powershell without
actually working on a real working server environment. The first time I watched
the help video I was like omg holy shit this is amazing and took absolutely no
notes what so ever. A few days later I opened a powershell prompt in the MSFT
lab environment and just sort of stared at like “woah scope that arrow >”
and couldn’t remember anything these dudes where talking about. So I decided to
watch it again and write down everything they were saying. Turns out this info
is generally more helpful than any book ive seen see far. So maybe this exists
out there somewhere in internet land but here’s some powershell notes for
idiots like me.

Note:I do apologize for any incoveninece my typos my cause,
I was drinking beer and listening to style of hip-hop known as krunk. Some
examples of krunk are the Yin-Yang Twins known for there hit single “Salt Shaker”
and the artist Trick Daddy. You may recall Trick Daddys 1998 hit single “Nann”
from his album www.thug.com which has an
image on the cover of a website created around the time of its release. Im sure
that the website was hosted on a windows advanced server NT 4.0  machine running IIS however there is a
possibility that it was a Unix box hosting it that was powered by Apaceh.
Either way it was a real website currently it appears to have some sort of
alias record directing you to some label page. Boring.

Update-help
-force  :this command will
download the latest help file info

Using the up errow will legt you scroll through the history
of commands you have typed.

The tab key is also extremely useful in that it will let you
scroll through possible commands, in this screen shot I just typed get help and
the pressed tab and space a few times to see what the results would be. I don’t
think this would display a functional output but you get the idea.

tab key photo get-help tab key_zpsz3zfz1c0.jpg

The typical Copy and paste cntrl C cntrl V does not work
however highlighting text very carefully and then rich clicking  then scrolling down to the next input space
and right clicking does work

Get-help  
“command” or cmdlet a little confused on terminology here  :basic powershell help
parameter, an example of a “command” would be add-windowsfeature as you can see
it doesn’t like install-service  This
looks like:

get-help basic photo get-help basic_zps6sdvk70i.jpg

Help “command” :shows more information that simply using
get-help, the output of this command looks like this and as you can see it does
not require a -:

help basic photo help basic_zps8kjymglv.jpg

Man “command”  :also a more prolific version of the get-help
command, the output of this command looks like this and as you can see with
this being done on the MSFT free test lab environment we run into a few issues
as the update-help command doesn’t seem work:

man photo man basic_zps6gtxecsd.jpg

Get-help *service* :in this example these dudes are using
what amounts to a search parameter to search for anything that has the word
service in the name. This looks like this:

*service* photo get-help start service._zps5shvgjod.jpg

Get-help  g*service* :
this will narrow the list and pull any commands that have a g and service for
example get-service. The output of this command looks like this:

get-help g*service* photo get-help gstar service_zpstqwakzmw.jpg

Get-verb : this will show all the verbs used in powershell
and instead of listing all the verbs ive shown that the location of the asterisk
character matters. If you do a search with *R it will display everything that
ends with the letter R if you use R* it will show any thing that starts with
the letter R.

get-verb photo get-verb_zpsslyyex8m.jpg

Get-verb |measure :this will give a number of returned
options. This is the first time we have seen the | command show up but it’s a
very powerful tool that you can use add addendum to powershell commands. More
on this whole | in later posts. Now it feels like where getting somewhere and
learning out how organize and display information in powershell!

get-verb pipe measure photo get verb pipe measure_zpslvsxlliq.jpg

-detailed :this switch lists all the help for the command. It’s
fairly extensive and this point is worth noting what all the [,][<[] things
mean. At first I was mega confused by this because im not a coder. But basically
it goes like this, if the syntax starts with a [ then a command inside of that
then it requires no additional switches to run, however if it doesn’t start
with that you have to give some more description. If you see additional []
things inside of a [ after describing a switch you can use multiple variables. Hopefully
that makes sense and it looks something like this:

detailed switch photo detailed switch_zpsldibjm4e.jpg

-full :this switch basically the same as using the –detailed
command however there is some more info about additional paramaters and im not
sure that I fully understand that yet so after I get some more info I may
discuss this more. Also its worth noting here that I picked the add-dnsserverconditionalforwarderzone
cmdlet because DNS is somewhat confusing to me and a global sense and I just
used the Tab key to find it:

full switch photo full switch_zpsfyzuwx0i.jpg

Get-help get -service –online :the online switch takes you
to the TechNet article on the requested topic. Also you can see that we start running
into problems with using the free labs again. Im assuming they don’t have an
internal internet connection which would make sense because I could see people
using these as a proxy server of sorts being a problem.

examples/limitations photo examples limitations_zpseuzdn6ig.jpg

Get-help get-service –examples :this examples switch is
where they keep the good stuff. The get-help is absolutely useless unless you
understand the code and all the brackets and all that stuff that’s obviously
super confusing. The –examples parm displays an exact line that you can type to
get what you’re looking for. And as you can see in the previous example we are
little limited here as well

Get-help get-service –showinwindow :this is amazing and it works great in the video. The show
in window switch shows the help file that was just pulled in a separate pop
window. Like omg a GUI in a dos type inviroment. My favorite part of this, as
if this wasn’t enough to spin your command line clues brain into a spin you can
also select check boxes to figure out/drill down to specifics so you can figure
out exactly how to talk to this thing. However it doesn’t work in the test environment.

-showinwindow photo showinwindow_zpsnskugamn.jpg

There’s also an interesting bit in the video about finding
things out by using bad switches/parameters after cmdlets in hopes of getting
some information in the returned error. I didn’t exactly find that helpful but
its displayed in the next image any way.

The event log search and pull tool however is amazing. Everyone
that’s ever had to search through an event log to figure out what was going on
knows how awful it is. Powershell just makes this a non issue. You can target
specific machines, types of errors, whatever you want and then output it to an
html file and have a nice little browser display of exactly what you’re looking
for. Here’s a basic example of that, obviously there’s not a lot of event log
info on freshly created test environments.

event log/bad parm photo event log and bad parm_zpsecwh9ev0.jpg

So hopefully this helps a little with a basic understanding of powershell. Like the time that some one explained how a mouse operated when you first sat down at a computer. 

Also heres some tumblrs that have scripts on them:

http://powershell.tumblr.com/

http://pwscripts.tumblr.com/

.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: