7
Basic Scripts in PowerShell Table of Contents Scripting: Where to Get Started?................................................................................................... 2 Another Useful Scripting Resource ................................................................................................. 4 Trusting Scripts -1 ........................................................................................................................... 5 Trusting Scripts -2 ........................................................................................................................... 6 Notices ............................................................................................................................................ 7 Page 1 of 7

Basic Scripts in PowerShell - USALearning wife, it's the scripting guy's . legitimate, really married, it is his . counterpart. So, this is a good . resource, over on the left hand--

Embed Size (px)

Citation preview

Basic Scripts in PowerShell

Table of Contents

Scripting: Where to Get Started? ................................................................................................... 2

Another Useful Scripting Resource ................................................................................................. 4

Trusting Scripts -1 ........................................................................................................................... 5

Trusting Scripts -2 ........................................................................................................................... 6

Notices ............................................................................................................................................ 7

Page 1 of 7

Scripting: Where to Get Started?

59

Scripting: Where to Get Started?

Microsoft Script Center

Technet.Microsoft.com/en-us/scriptcenter

**059 When we think about running scripts in PowerShell, there are lots of them that are out there. You just really have to decide what you want to do. We could not figure out a whole list of here are scripts that we want to do to accomplish a certain task to display for you guys in the class. So, instead, we decided to show you some resources where you can gain access to scripts that you might think are helpful. So, the scripting guy, at Microsoft, we have the scripting guy from the script center. And his wife, apparently, is involved in scripting, too. So, we have a-- if you see this

Page 2 of 7

scripting wife, it's the scripting guy's legitimate, really married, it is his counterpart. So, this is a good resource, over on the left hand-- no, it's on the right hand side. We have this repository of scripts to do just about anything and everything that you want to do. And it's constantly being updated. One nice thing about scripting guy, he does a number of different webinars that-- very informative webinars about how to write scripts. And he's happy to help everyone from the very basic novice all the way through to the expert scripters in order to make a script do what you want. Yes? Student: Can you WhatIf a whole script? Mark Williams: Huh? Student: Could you WhatIf a whole script? Mark Williams: No, I don't believe you can WhatIf the whole script. But that's why we have ISE, the Internet- - no, not Internet-- something-- Student: Integrated. Mark Williams: Integrated Scripting Environment. I was thinking integral. I was thinking Internet, but not integrated. Yes, the integrated scripting environment, that's why we have that, so I can test them there. So, that's effectively your WhatIf capability. Scripting center's a good place.

Page 3 of 7

Another Useful Scripting Resource

60

Another Useful Scripting Resource

**060 CodePlex, how many of you guys have ever used CodePlex before? Not-- not a bad place to go. Actually, it's quite good place to go. I was about to say it's not a Microsoft resource. It is a Microsoft resource. But it's not owned by Microsoft Corporation. At least to my knowledge, it's not. But CodePlex has a number of very useful scripts, as well in their database.

Page 4 of 7

Trusting Scripts -1

61

Trusting Scripts -1

Caveat Emporium!! “Let the buyer beware!”

Before downloading any scripts, trust the source, but verify what the script does.

Test it on a small subset before deploying enterprise-wide.

Trust signed scripts only.

**061 And then, one comment about going to anywhere, anybody, and grabbing scripts, I always use the phrase caveat emptor. It's Latin for buyer beware, right? There is no honor among thieves. If you're going to go out and download somebody's script to accomplish some sort of task, you ought to spend a little bit of time trying to figure out what really does that script do. If you don't understand it, I would recommend that you don't run it, at least certainly not on a production environment, that you should spend some time to figure out what it's going to do because it could do something harmful to you.

Page 5 of 7

So, a number of the scripts that are available out there are signed by trusted publishers. The scripts available from the scripting guy, they are signed. So, we know that they came from Microsoft and they are trusted. So, that elevates our level of security. Unsigned scripts, just be wary about taking on those scripts.

Trusting Scripts -2

62

Trusting Scripts -2A script that has been digitally signed by a certificate that is trusted on a computer

• Execution policy set to AllSigned or RemoteSigned• Certification Authority must be either a trusted root or intermediate

authority• Get-Help About_Signing

**062 Let's see, signed scripts, let's talk a little bit about that. We're talking about digital signatures here. In this particular case, we can say that in PowerShell, we're not going to allow any scripts to run unless they are signed. As a matter of fact, the

Page 6 of 7

default policy for PowerShell is basically that. If it's not a signed script, we're not going to allow it to run. So, I can get help to learn more about script signing, what it is. Let's see how to sign scripts so that they comply with the Windows PowerShell execution policies.

Notices

2

Notices© 2014 Carnegie Mellon University

This material is distributed by the Software Engineering Institute (SEI) only to course attendees for their own individual study.

Except for the U.S. government purposes described below, this material SHALL NOT be reproduced or used in any other manner without requesting formal permission from the Software Engineering Institute at [email protected].

This material was created in the performance of Federal Government Contract Number FA8721-05-C-0003 with Carnegie Mellon University for the operation of the Software Engineering Institute, a federally funded research and development center. The U.S. government's rights to use, modify, reproduce, release, perform, display, or disclose this material are restricted by the Rights in Technical Data-Noncommercial Items clauses (DFAR 252-227.7013 and DFAR 252-227.7013 Alternate I) contained in the above identified contract. Any reproduction of this material or portions thereof marked with this legend must also reproduce the disclaimers contained on this slide.

Although the rights granted by contract do not require course attendance to use this material for U.S. government purposes, the SEI recommends attendance to ensure proper understanding.

THE MATERIAL IS PROVIDED ON AN “AS IS” BASIS, AND CARNEGIE MELLON DISCLAIMS ANY AND ALL WARRANTIES, IMPLIED OR OTHERWISE (INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE, RESULTS OBTAINED FROM USE OF THE MATERIAL, MERCHANTABILITY, AND/OR NON-INFRINGEMENT).

CERT ® is a registered mark owned by Carnegie Mellon University.

Page 7 of 7