• No results found

Acknowledgments Finding Your Way Around Windows PowerShell p. 1 Getting Started with Windows PowerShell p. 3 Installing Windows PowerShell p.

N/A
N/A
Protected

Academic year: 2021

Share "Acknowledgments Finding Your Way Around Windows PowerShell p. 1 Getting Started with Windows PowerShell p. 3 Installing Windows PowerShell p."

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

Introduction p. xv

Acknowledgments p. xx

Finding Your Way Around Windows PowerShell p. 1

Getting Started with Windows PowerShell p. 3

Installing Windows PowerShell p. 3

Installing .NET Framework 2.0 p. 4

Installing Windows PowerShell p. 7

Starting and Stopping PowerShell p. 8

Starting PowerShell p. 8

Exiting PowerShell p. 10

Startup Options p. 10

Finding Available Commands p. 11

Getting Help p. 14

Basic Housekeeping p. 17

Case Insensitivity p. 18

What You Get in PowerShell p. 19

Interactive Command Shell p. 19

Cmdlets p. 20

Scripting Language p. 21

Summary p. 23

The Need for Windows PowerShell p. 25

Limitations of CMD.exe p. 27

Batch Files p. 28

Inconsistency of Implementation p. 28

Inability to Answer Questions p. 29

Lack of Integration with GUI Tools p. 29

The GUI Emphasis in Windows p. 29

Previous Attempted Solutions p. 29

Windows Script Host p. 30

Windows Management Instrumentation p. 30

Summary p. 31

The Windows PowerShell Approach p. 33

A New Architecture p. 33

.NET Framework-Based Architecture p. 34

Object-Based Architecture p. 35

A New Cross-Tool Approach p. 38

GUI Shell (MMC Layered over PowerShell) p. 39

Command Line p. 39

Command Scripting p. 41

COM Scripting p. 43

(2)

File System Provider p. 47 Registry p. 47 Aliases p. 48 Variables p. 49 Active Directory p. 50 Certificates p. 51

Extensibility and Backward Compatibility p. 51

Aliases p. 51

Use Existing Utilities p. 53

Use Familiar Commands p. 55

Long Term Roadmap: Complete Coverage in 3 to 5 Years p. 55

COM Access p. 56

WMI Access p. 56

.NET Class Access p. 56

Object-Based Approach in PowerShell p. 56

Object-Based Pipelines p. 56

A Consistent Verb-Noun Naming Scheme p. 57

Coping with a Diverse World p. 58

Upgrade Path to C# p. 58

Working with Errors p. 58

Debugging in PowerShell p. 59

Additional PowerShell Features p. 59

Extended Wildcards p. 59

Automatic Variables p. 60

Summary p. 62

Using the Interactive Shell p. 63

Windows PowerShell's Two Command Line Parsing Approaches p. 63

Expression Mode Examples p. 65

Command Mode Examples p. 66

Mixing Expressions and Commands p. 69

Exploring a Windows System with Windows PowerShell p. 69

Finding Running Processes p. 69

Filtering Processes Using where-object p. 71

Filtering Processes Using Wildcards p. 72

Finding Out about Services p. 73

Finding Running Services p. 74

Finding Other Windows PowerShell Commands p. 75

Using Abbreviated Commands p. 76

Command Completion p. 76

Aliases p. 77

(3)

Sequences of Commands p. 78

Filtering Using where-object p. 79

Sorting p. 81

Grouping p. 83

Pros and Cons of Verbosity p. 85

Interactive p. 85

Stored Commands p. 87

Summary p. 87

Using Snapins, Startup Files, and Preferences p. 89

Startup p. 89

Snapins p. 90

Profiles p. 97

Profile.ps1 p. 98

Aliases p. 100

The export-alias Cmdlet p. 105

The get-alias Cmdlet p. 107

The import-alias Cmdlet p. 108

The new-alias Cmdlet p. 108

The set-alias Cmdlet p. 109

The Help Alias p. 111

Command Completion p. 112 Prompts p. 113 Preference Variables p. 115 Summary p. 116 Parameters p. 117 Using Parameters p. 118

Finding Parameters for a Cmdlet p. 121

Named Parameters p. 124

Wildcards in Parameter Values p. 125

Positional Parameters p. 127

Common Parameters p. 132

Using Variables as Parameters p. 133

Summary p. 135

Filtering and Formatting Output p. 137

Using the where-object Cmdlet p. 137

Simple Filtering p. 138

Using Multiple Tests p. 140

Using Parameters to where-object p. 142

The where-object Operators p. 144

Using the select-object Cmdlet p. 144

(4)

Expanding Properties p. 146

Selecting Unique Values p. 147

First and Last p. 148

Default Formatting p. 151

Using the format-table Cmdlet p. 155

Using the property Parameter p. 156

Using the autosize Parameter p. 157

Hiding Table Headers p. 158

Grouping Output p. 158

Specifying Labels and Column Widths p. 159

Using the format-list Cmdlet p. 161

Using the update-formatdata and update-typedata Cmdlets p. 162

Summary p. 163

Using Trusting Operations p. 165

Look Before You Leap p. 166

Using the remove-item Cmdlet p. 166

Using the whatif Parameter p. 175

Using the stop-process Cmdlet p. 175

Using the stop-service Cmdlet p. 178

Using the confirm Parameter p. 180

Using the verbose Parameter p. 181

Summary p. 182

Retrieving and Working with Data p. 183

Windows PowerShell Providers p. 183

Using the get-psdrive Cmdlet p. 184

Using the set-location Cmdlet p. 188

Using the passthru Parameter p. 190

Using the get-childitem Cmdlet p. 191

Using the get-location Cmdlet p. 194

Using the get-content Cmdlet p. 196

Using the measure-object Cmdlet p. 201

The new-item Cmdlet p. 203

The new-psdrive Cmdlet p. 204

Summary p. 205

Scripting with Windows PowerShell p. 207

Enabling Scripts on Your Machine p. 207

Using the read-host Cmdlet p. 212

Using the write-host Cmdlet p. 214

The Arithmetic Operators p. 218

Operator Precedence p. 219

(5)

The Comparison Operators p. 222

The Logical Operators p. 225

The Unary Operators p. 226

Using the set-variable and Related Cmdlets p. 227

The set-variable Cmdlet p. 228

The new-variable Cmdlet p. 229

The get-variable Cmdlet p. 230

The clear-variable Cmdlet p. 231

The remove-variable Cmdlet p. 232

Summary p. 234

Additional Windows PowerShell Language Constructs p. 235

Arrays p. 235

Creating Typed Arrays p. 239

Modifying the Structure of Arrays p. 241

Working from the End of Arrays p. 245

Concatenating Arrays p. 248

Associative Arrays p. 249

Conditional Expressions p. 250

The if Statement p. 251

The switch Statement p. 254

Looping Constructs p. 256

The for Loop p. 256

The while Loop p. 258

The do/while Loop p. 259

The foreach Statement p. 260

Summary p. 262

Processing Text p. 263

The .NET String Class p. 263

Working with String Methods p. 267

Casting Strings to Other Classes p. 287

URI p. 287 Datetime p. 288 XML p. 289 Regex p. 289 Summary p. 291 COM Automation p. 293

Using the new-object Cmdlet p. 293

Working with Specific Applications p. 294

Working with Internet Explorer p. 294

Working with Windows Script Host p. 299

(6)

Working with Excel p. 302

Accessing Data in an Access Database p. 303

Working with a Network Share p. 305

Using Synthetic Types p. 306

Summary p. 308

Working with .NET p. 309

Windows PowerShell and the .NET Framework p. 309

Creating .NET Objects p. 311

The new-object Cmdlet p. 311

Other Techniques to Create New Objects p. 317

Inspecting Properties and Methods p. 320

Using the get-member Cmdlet p. 320

Using .NET Reflection p. 324

Using the GetMembers() Method p. 324

Using the GetMember() Method p. 326

Using the GetMethods() Method p. 328

Using the GetMethod() Method p. 329

Using the GetProperties() Method p. 330

Using the GetProperty() Method p. 331

Using System.Type Members p. 333

Summary p. 334

Putting Windows PowerShell to Work p. 335

Using Windows PowerShell Tools for Discovery p. 337

Exploring System State p. 338

Using the get-location Cmdlet p. 338

Handling Errors p. 345

Namespaces p. 346

PowerShell Aliases p. 346

PowerShell Functions and Filters p. 349

PowerShell Variables p. 350

Exploring the Environment Variables p. 351

Exploring the Current Application Domain p. 353

Exploring Services p. 357

Using the get-service Cmdlet p. 358

Using the new-service Cmdlet p. 360

Using the restart-service Cmdlet p. 361

Using the set-service Cmdlet p. 362

Using the start-service Cmdlet p. 362

Using the stop-service Cmdlet p. 363

Using the suspend-service Cmdlet p. 364

(7)

Security p. 367

Minimizing the Default Risk p. 368

The Certificate Namespace p. 374

Signed Scripts p. 376

Creating a Certificate p. 376

The set-authenticodesignature Cmdlet p. 377

The get-authenticodesignature Cmdlet p. 379

Summary p. 379

Working with Errors and Exceptions p. 381

Errors in PowerShell p. 381

$Error p. 383

Using Error-Related variables p. 388

Using the $ErrorView variable p. 389

Using the $ErrorActionPreference variable p. 390

Trap Statement p. 392

Using Common Parameters p. 397

Using the ErrorAction Parameter p. 397

Using the ErrorVariable Parameter p. 399

The write-error Cmdlet p. 400

Summary p. 401

Debugging p. 403

Handling Syntax Errors p. 403

The set-PSDebug Cmdlet p. 408

The write-debug Cmdlet p. 413

Tracing p. 418

The trace-command Cmdlet p. 419

The set-tracesource Cmdlet p. 422

The get-tracesource Cmdlet p. 422

Summary p. 423

Working with the File System p. 425

Path Names in Windows PowerShell p. 426

Fully Qualified Path Names p. 427

Relative Path Names p. 430

Path Names and Running Commands p. 431

Simple Tasks with Folders and Files p. 434

Finding the drives on a system p. 434

Finding Folders and Files p. 434

Finding File Characteristics p. 436

Exploring Files Using the select-object Cmdlet p. 439

Finding Hidden Files p. 442

(8)

Redirection p. 445

Creating Custom Drives p. 447

Cmdlets for File Actions p. 449

Using the out-file Cmdlet p. 449

Using Cmdlets to Work with Paths p. 450

Summary p. 453

Working with the Registry p. 455

Introduction to the Registry p. 455

Exploring the Registry Using Windows PowerShell p. 458

Selecting a Hive p. 458

Navigating to a Desired Key p. 459

Changing the Registry p. 461

Summary p. 464

Working with Environment Variables p. 465

Environment Variables Overview p. 465

The Environment Command Shell Provider p. 468

Exploring Environment Variables p. 470

Modifying Environment Variables p. 471

Summary p. 473

Language Reference p. 475

Working with Logs p. 477

Event Log Basics p. 477

The get-eventlog Cmdlet p. 480

Summary p. 494

Working with WMI p. 495

Introducing Windows Management Instrumentation p. 496

Managed Resources p. 496

WMI Infrastructure p. 497

CIM Object Manager p. 498

The CIM Repository p. 499

WMI Consumers p. 499

WMI Tools p. 499

Using the get-wmiobject Cmdlet p. 502

Finding WMI Classes and Members p. 506

Exploring a Windows System p. 509

Characterizing the CPU p. 509

Finding Memory p. 510

Exploring Services p. 512

Exploring Remote Machines p. 513

Summary p. 514

(9)

References

Related documents

Nearly planar sustained shocks within the probed region are desired because it is useful to treat the compression process as quasi one-dimensional. 18 Stereoscopic measurements

One possible explanation for di fferent effects on immigrants and natives as well as for men and women may be di fferent resource allocation within intermar- riage: Native partners

(1) The technical evaluation of the project is made on by analying the size and length of service by building, developing and mining Ida, ventilation and safety, equipment,

Vol. Level V, anak dapat berpindah dengan kursi roda, anak mempunyai keterbatasan dalam mengontrol kepalanya, gangguan postur tubuh, dan mengontrol pergerakan lengan.

Data ecosystem Modeling insights Modeling “Black box” Heuristic insights “Smart box” Work-flow integration Process redesign Tech enablement Adoption Internal

Figure 10. A) Stratigraphic distribution of all concretion morphologies observed throughout the Murray formation from Sols 750-1900. Each point represents a Mastcam or

With terabytes, even petabytes, fast becoming a comfortable benchmark for corporate data stores, many companies are fixated on the volume and variety of “big data.” Yet what's

We examined genetic variation, gene flow, and population structure at five microsatellite loci in samples from five pre-fur trade populations throughout the sea