10 Easy Tips

cornawakeΛογισμικό & κατασκευή λογ/κού

4 Νοε 2013 (πριν από 3 χρόνια και 10 μήνες)

91 εμφανίσεις

10 Easy Tips

To Help You

Master PowerShell

for SharePoint


St ephan Samuel

SAFE

Managed Ser vi ces


Stephan Samuel

o
I write SharePoint for Catapult!

o
Find me here:

o
Stephan.Samuel@CatapultSystems.com

o
@
StephanSamuel


Do you use PowerShell?

o
It’s a .NET scripting language.

o
It allows you to control your local
environment, services, etc.

o
Scripting allows repeatability.

What Is PowerShell?

PowerShell 101,

if you’re new to it

o
Be more efficient, save time.

o
Don’t be frightened when you
need a PowerShell
-
only command.


Why PowerShell?

… didn’t we move away from DOS
years ago?

But wait…

o
Automate common tasks with PowerShell.

o
Know how you and those around you can:

o
Save time doing repeated tasks.

o
Avoid buying more expensive tools, sometimes.

I’m not a developer or admin!


Manage list or document
library content.


Install, upgrade and deploy
reliably.


Inspect and modify users or
attributes.


Filter objects with complex
criteria.


Perform
ad hoc
reporting.


Manage across site
collections.


Use PS!

You bought the farm, now it’s
time to protect and manage it!

o
We have a document library with
pictures.

o
We want to sort out the ones with
spaces in the filenames.

Today’s Task

Nuts & Bolts: the tips!

Understanding Pipes

1

o
Pipe from left to right.

o
Build as you go!


Pipes

o
Build a set.

o
Filter the set.

o
Perform an operation.


Systematic Approach

Get
-
Help

2

o
All built
-
in
cmdlets

have help: Get
-
Help

o
Get
-
Member shows more detail.



Use Help
Cmdlets

o
Bing will get you the help you need.

o
Use the visual command builder.

Go Online

It’s Not Just Text

3

o
Drag and drop files into the PS window!

o
The full path and quotes are added.

Drag & Drop

Tab completes as you type.

Tab Completion

Keep The Window Open

4

Leaving the window
open doesn’t let
bugs in!

o
Name your variables well.

o
Use them later!

Long Live The PS Window!

Common Parameters

5

o
Most
cmdlets

give additional
debugging data.

o
Confirm everything as you go!

The Debug Parameter

o
Perform a dry run.

o
Get the details before you commit.

The
WhatIf

Parameter

Useful Output

6

o
Work in small pieces.

o
Each parts only adds something
small.

Break It Apart

o
Output objects, not text.

o
Make filtering easy!

Raw Output

Reduce, Reuse, Recycle

7

o
Work in small pieces.

o
Use the standard template.

Reusable Code

o
Make piping easy.

o
From the template, these self
-
document.

Parameters

Six months from now, reading your own
code is like another developer reading
your code today.

Maintainability

Anyone Care To Comment?

8

o
For one line: #

o
For blocks: <# and #>

Comments

Naming Conventions

9

o
Learn and use common verbs:

o
Get, New, Remove

o
The standard: Verb
-
Noun

Common Verbs

o
Loop With %{ $_ }

o
Filter With ?{ $_ }

Command Abbreviations

Save Typing!

10

o
Use the SharePoint PS icon instead of the
default.

o
Get a shortcut to the SharePoint PowerShell
command.

o
You’re only adding possibilities!

Get A New Icon!

You’re Ready To Go!

What We Learned

o
Some quick tips can make PowerShell more
familiar.

o
Help is available, online and in PowerShell.

o
A few easy steps help us re
-
use our work.

o
Know how to ask someone to work for you!

Does the script work?

Can we see?

Run it!

Find me here:


Stephan.Samuel@CatapultSystems.com


@
StephanSamuel

on Twitter


Questi ons?