BUY THIS BOOK
Add to Cart

Print Book $49.99


Add to Cart

PDF $39.99

Safari Books Online

What is this?

Add to UK Cart

Print Book £30.99

What is this?

Looking to Reprint or License this content?


Windows PowerShell Cookbook
Windows PowerShell Cookbook for Windows, Exchange 2007, and MOM V3

By Lee Holmes
Book Price: $49.99 USD
£30.99 GBP
PDF Price: $39.99

Cover | Table of Contents | Colophon


Index


[ Symbols ], 
[ A ], 
[ B ], 
[ C ], 
[ D ], 
[ E ], 
[ F ], 
[ G ], 
[ H ], 
[ I ], 
[ J ], 
[ K ], 
[ L ], 
[ M ], 
[ N ], 
[ O ], 
[ P ], 
[ Q ], 
[ R ], 
[ S ], 
[ T ], 
[ U ], 
[ V ], 
[ W ], 
[ X ], 
[ Z ], 


Symbols[ Top ]
" " (double quotes), 96
$ (dollar sign), 8
$$, 496
$? (dollar sign, question mark), 33, 496
$^, 496
$_, 50, 55, 475, 496
$args, 84, 186, 187, 474, 496
$confirmPreference, 496
$consoleFilename, 496
$currentlyExecutingCommand, 496
$debugPreference, 46, 496
$env:SystemRoot, 98
$env:variable name, 64
$error, 44, 226, 496
$errorActionPreference, 228, 496
$errorView, 227, 496
$executionContext, 320, 497
$false, 34, 497
$foreach, 497
$formatEnumerationLimit, 497
$GLOBAL:, 254
      (see also global scope)
$home, 497
$host, 497
$host.PrivateData.Debug*, 46
$host.PrivateData.Progress*, 46
$host.PrivateData.Verbose*, 46
$host.UI.RawUI.ReadKey(), 211
$input, 188, 475, 497
$lastExitCode, 33, 476, 497
$logCommandHealthEvent, 497
$logCommandLifecycleEvent, 497
$logEngineHealthEvent, 497
$logEngineLifecycleEvent, 497
$logProviderHealthEvent, 497
$logProviderLifecycleEvent, 497
$maximumAliasCount, 497
$maximumDriveCount, 497
$maximumErrorCount, 497
$maximumFunctionCount, 497
$maximumHistoryCount, 38, 497
$maximumVariableCount, 497
$message, 283
$myInvocation, 243, 476, 497
$myInvocation.InvocationName, 246
$myInvocation.MyCommand, 243
$myInvocation.ScriptName, 247
$nestedPromptLevel, 497
$null, 62, 98, 497
$ofs, 497
$outputEncoding, 498
$pid, 498
$profile, 23, 25, 486, 498
$progressPreference, 46, 498
$psHome, 498
$pwd, 320, 498
$this, 85
$true, 85
$VerbosePreference, 46, 483
%errorlevel%, 33
& (ampersand, invoke operator), 20, 29, 181
() (parentheses), 71
* (asterisk), 25
*.Format.ps1xml, 481
*-Item, 326
+ (addition operator), 201
, (comma, list operator), 195
. (dot) (see also dot-source), 67
./ (dot, forward slash), 20
./Program.exe syntax, 21
.NET
      calling, 265
      Class header, 58
      classes, 502-508
      documentation, 79, 469
      advanced features, 262
      Framework Class Library (FCL), xviii
      generic objects, 73-74
      instances, 468
      method, 67, 468
      names, 67
      objects, 67, 71
      properties, 67, 68, 70, 468
      string formats, 519
      WMI advanced tasks, 261
.NET classes and their uses, 502
.NET DateTime formatting, 522
.ps1, 176, 289, 473
.ps1xml, 289
.psc1 file extension, 48
.tmp (temporary file), 142
:: (colons), static member access, 68
<formatString>, 519
@ (at sign), list evaluation syntax, 97, 197, 449
@() (list evaluation syntax), 189
[int] (integer cast), 449
\ (backslash character), 98
` (back-tick), escape character (see also escape sequences), 98, 447
{ } double brackets (see also script block), 50
| (pipeline), 9, 49
" (quotes), 20
' (single quote), 20
0x prefix, 123, 448

A[ Top ]
A: through Z:, 314
accelerators, 211, 257, 261
Access a .NET SDK library, 276
Access arguments of a script, function, or script block, 185
Access elements of an array, 198
Access environment variables, 63
Access event logs of a remote machine, 371
Access features of the host's user interface, 221
Access information about your command's invocation, 242
Access information in an XML file, 147
Access pipeline input, 188
Access services on a remote machine, 383
Access user and machine certificates, 303
Access Windows Management Instrumentation data, 255
Access Windows performance counters, 270
ACL (access control list)
      misconfigurations, 328
      modification, 329
      registry keys, 346-348
Active Directory, 385-404
      objectClass, 400
ADAM (Active Directory Application Mode)
      create a test instance, 386
      installation, 386
      test scripts on a local installation, 385
Adapters static IP addresses, 422-423
Add a graphical user interface to your script, 223
Add a pause or delay, 93
Add a site to an Internet Explorer security zone, 341
Add a user to a security or distribution group, 399
Add custom methods and properties to objects, 80
Add custom methods and properties to types, 82
Add extended file properties to files, 330
Add inline C# to your PowerShell script, 273
Add PowerShell scripting to your own program, 283
Add/remove administrative templates, 293
Add/remove programs, 410
Add-DistributionGroupMember, 431
Add-ExtendedFileProperties.ps1, 331
Add-History, 39
addition operator (+), 201, 454
Add-Member, 80, 82, 319, 471
Add-PsSnapin SnapinIdentifier, 47
ad hoc script development, 12
Adjust script flow using conditional statements, 89
Adjust your window size, 484
Administrative numeric constants, 448
Administrative templates, 293
Administrative tools, 294
Administrator account, 413
ADSI (Active Directory Service Interfaces), 13
      ADSIEdit MMC, 390
      COM libraries, xviii
[adsi], 387, 389, 395, 397
Advanced class features, 262
Advanced query feature, 262
aliases
      Alias:, 311
      AliasProperty, 81, 85, 471
      common commands, 36
      defining, 23
      registry keys navigation, 337
      scope, 67
      structured commands, 7
alignment (string formatting), 519
Allow only
      all administrators to manage Trusted Publishers, 295
      enterprise administrators to manage Trusted Publishers, 295
AllScope, variable option, 66
AllSigned, execution policy, 288, 294
AllUsers
AllUsersDesktop, 249
AllUsersPrograms, 249
AllUsersStartMenu, 249
AllUsersStartup, 249
Alt key, 211
ampersand, invoke operator (&), 20, 29
Analyze a script's performance profile, 234
-and operator, 455
angles, 119
APIs
      calls, 271-273
      data protection, 297, 302
      errors, 479
      output, verbose, 483
      Win32, 414
-Append parameter, 41
AppendChild(), 152
Apropos, 28
Archive, 123
args, 186
argument array, 474
arguments, 185
arithmetic operators, 453
ArrayList, 73, 75, 183, 205
arrays
      access, 450
      advanced tasks, 205
      arguments, 474
      associative, 198, 206, 451
      combine, 201
      create, 195
      data, adding to the end, 201
      defining, 449
      elements, 198, 203, 449
      multidimensional (jagged), 197, 450
      ranges, 451
      searches, 200, 202, 204
      slicing, 451
      sort, 200, 204
      strongly typed, 449
      (see also lists)
arrays, search, 202
-as operator, 458
-AsPlainText, 297
-AsSecureString, 210, 296
assembly, 470
Assign a static IP address, 421
Assignment, 455
asterisk (*), 25
at sign (@) (list evaluation syntax), 97
attrib.exe, 312
attributes
      elements, 149
      file, 124
      flags, 124
      group, 396
      system update, 312
Authentication, advanced query feature, 262
Authenticode
      infrastructure, 290
      verification, 295
AuthenticodeSignature, 295
-Auto flag, 43
Automate data-intensive tasks, 56
automate programs, 266
Automate programs using COM scripting interfaces, 266
Automate wizard-guided tasks, 427
automatic variables, 496
AvailableFreeSpace, 84
Awk, 110

B[ Top ]
Back up an event log, 369
backslash character (\), 98
back-tick (`), escape character, 98, 447
      (see also escape sequences)
-band operator, 126, 456
banker's rounding, 118
Base64 encoded command, 29
batch files, 30, 241
begin keyword, 190, 475
binary
      BinaryReader, 141
      management, 139
      numbers, 123
      operators, 88
      parse, 139
      representation, 128
binary file, searching, 136
binary operators, 456
bit flags, 123
-bnot operator, 457
Booleans, 446
-bor operator, 456
break statement, 464, 466
buffer size, 35
-bxor operator, 456

C[ Top ]
C#, Inline, 278
cacls.exe, 330
calculated property, 159
calculations, 120
      complex, 181
      properties, 319
      (see also operations)
Calling methods on a class, 266
Calling methods on an instance, 265
calls
      APIs, 271
      methods, 265
cancel, 485
capitalization rules, debug solutions, 219
capitalization, writing, 219
Capturing output, 482
cast, 75
CategoryView, 44, 227
cd command, 6
certificates (see digital certificates)
characters
      special, 98, 317
      whitespace, 107
child scopes, 66
CIM_Printer, 414
classes, 67
      advanced features, 262
      security, 297
      WebClient, 161
      (see also .NET)
Clear or remove a file, 311
Clear-Content, 311
cmd.exe, 20
cmdlet, compile and run an example, 285
      (see also commands)
Cmdlet keywords in scripts, 475
cmdlet, creation, 279
CodeMethod, 81, 472
CodeProperty, 81, 471
code-signing certificates, 289, 293
Collect detailed traces of a script or command, 234
colons (::), 68
COM
      interfaces, 267, 471
      methods and properties, 76
      script, 14
      script interfaces, 266
      system administrators, 516-518
COM objects and their uses, 516
Combine two arrays, 201
comma, list operator (,), 195
command shell, 434
command-line utilities, 405
commands
      CommandType, 243
      defining, 443
      duration of, 34
      error output, 44
      export as Web pages, 170
      help, 26
      history, 484
      locate
            current, 320
            past, 24
      memory usage, display, 373
      output
            comparisons of two commands, 358
            storage, 39
      status of last, 33
      structured, 279
      Trace-Command, 483
Commands and expressions, 443
CommandType, 244
comments, 444
      multiline. 97
Common customization points, 484
common folders, 248
-ComObject, 76
Compare the output of two commands, 358
Compare-Object, 358
Compare-Property, 52
Compare-Property.ps1, 52
comparison operators, 51, 88, 359, 458, 461
Complexity of user input and file content, 218
ComputerName, 58
conditional statements, 460
-Confirm parameters, 10
Connect-WebService, 166
Connect-WebService.ps1, 167
Console settings, 484
console window
      buffer size, 36
      copying and pasting, with the mouse, 36
      customization, 35, 484
      foreground and background color, 36
      history management, 38
      hotkeys, 39
      snapins, 48
[Console]::ReadKey(), 211
constructors, 71, 79, 470
-contains operator, 200, 460
content, 311
Continue ErrorAction preference, 479
continue statement, 46, 466
Continue verbose preference, 483
Control access and scope of variables and other items, 65
Convert a string to upper/lowercase, 106
Convert a VBScript WMI script to PowerShell, 263
Convert numbers between bases, 128
Convert text streams to objects, 110
[Convert]::ToInt32(), 123, 128
[Convert]::ToString(), 123, 128
ConvertFrom-SecureString, 297, 302
converting numbers, 449
Convert-TextObject, 110-114, 136-139, 172
Convert-TextObject.ps1, 110
ConvertTo-Html, 170
ConvertTo-SecureString, 297, 302
cooked input mode, 36
Copy-Item, 45, 156
cosine, 119
counted for loop, 92
Create a directory, 324
Create a filesystem hard link, 332
Create a hashtable or associative array, 206
Create a jagged or multidimensional array, 197
Create a multiline or formatted string, 97
Create a registry key value, 339
Create a security or distribution group, 395
Create a self-signed certificate, 291
Create a string, 95
Create a temporary file, 141
Create a user account, 390
Create a ZIP archive, 334
Create an array or list of items, 195
Create an instance of a .NET object, 71
Create an organizational unit, 388
Create instances of generic objects, 73
Create or remove an event log, 369
Create your own PowerShell cmdlet, 279
Creating instances of types, 470
Creating large text reports, 115
-creplace, 144
CSV
      account information, 391
      automating data intensive tasks, 56
      files, 57
      plain strings, 157
Ctrl key, 211
cube roots, 120
culture-aware script settings, 217
Custom DateTime format strings, 523
Custom formatting files, 481
Custom numeric format strings, 520
custom type extension files, 472
Customize your shell, profile, and prompt, 22
Cyrillic, 144

D[ Top ]
data
      access instrumentation, 255-257
      collection, 264
      Data Protection API, 302
      generating large amounts of, 114
      import and export structured, 153
      intensive tasks, 56
      numeric, 448
      pipelines, 114
      retrieval of hidden, 313
      source
            navigation, 336
            queries, 267-269
      SQL servers, 267
      streaming, 114
      (see also files)
date and time
      constants, 109
      DateTime
            calendar arithmetic, 310
            calling, 79
            customization, 523-527
            format, 109, 522
date and time (continued)
            generic objects, 73
            Ticks property, 122
      file modification searches, 310
      format conversion, 522-523
      internationalization problems, 109
      number format, 218
      system, 32
Date, time, and number formats, 218
-Debug, 46
Debug a script, 231
debugging solutions, 46, 231-233, 482
decimal numbers, 128, 449
declaration, 477
default parameters, 315
defrag.exe, 413
defragmentation, 412
delay command, 93
delete file, 311
-Delimiter, 138
delimiter, file, 133
Desktop, 249
Determine properties available to WMI filters, 257
Determine the current location, 320
Determine the differences between two files, 359
Determine whether a hotfix is installed, 417
Determine whether an array contains an item, 200
DHCP leases, 420
diagnostic information, 234
diff, 358, 359
diff.exe, 359
digital certificates
      access, 303
      self-signed, 291
      store, 15, 304
digital signatures, 288, 295
dir command, 6
directories
      creation, 324
      file searches, 313
      moving, 327
      removal, 324
      rename, 325
      running commands, 20
      VMImages, 435
DirectoryName, 315
Disable-Rule, 438
Discover registry settings for programs, 354
discovery commands, 10
disk
      credential passwords, 301
      space, 318
      usage statistics, 319
Display a menu to the user, 211
Display messages and output to the user, 213
DisplayName, 410, 436
distribution groups
      creation, 395
      CSV data and bulk, 396
      listing members, 401, 431
      management, 431
      property
            lists, 397
            modification, 399
      searches, 396
      users, 399, 431
division, 118, 454
do - until statement, 465
do - while statement, 92, 465
dollar hook (see $? [dollar sign, question mark])
DOS-style file manipulation commands, 5
dot, forward slash (./), 20
dot-source, 185, 254
dot-sourcing scripts, 473
double brackets ({ }), 50
      (see also script block)
double quotes (" "), 96
Download a file from the Internet, 160
Download a web page from the Internet, 161
download time, 127
DownloadFile(), WebClient method, 160
DownloadString(), WebClient method, 161
drives, 311
      access, 66
      free space, 84
      removal, 85
      scope, 67
      standard, 314
      syntax, 241

E[ Top ]
e base, 120
Easily import and export your structured data, 153
EKU (Enhanced Key Usage), 304
else statement, 89, 460
elseIf statement, 89, 460
email
      information retrieval and modification, 430
      mailboxes, 430
      management, 430
      sending, 170
      transport rules, 431
Enable or disable rules, 438
Enable or disable the Windows Firewall, 408
Enable scripting through an execution policy, 287
EnablePrivileges, 262
enablers, xviii
Enable-Rule, 438
Encarta, 162
encoded files, 144
EncodedCommand, 29
-Encoding, 144
Encrypted file attribute, 124
      (see also SecureString)
end keyword, 190
end of file information, 41
End(), 107
Enhanced security configuration, 289
[Enum]::GetValues(), 248
enumerated constants, 249
enumerator, 188
env:, 63, 241, 312
environment
      global, 254
      libraries, xviii
      modification, 240
      providers, 63, 241
      values, 241
      variables, 30, 63, 240
      WSH scripters, xviii
      (see also variables)
[Environment]::GetFolderPath(), 248
[Environment]::SetEnvironmentVariable(), 241
[Environment]::GetEnvironmentVariable(), 241
-eq operator, 50, 107, 202, 458
equality operator, 458
errors
      access list of, 226
      command generated, 226
      enable scripting, 287
      $false variable, 34
      generating, 231
      invalid command-line parameters, 45
      management, 228-229, 478-480
      messages
            first time running a script, 177
            values, 249
      nonterminating, 45, 227, 478
      output stream, 479
      parameters, 479
      records, 227
      registry keys, 286
      terminating, 45, 227, 478
escape sequences, 64, 96, 318, 447
EscDomains keys, 342
event logs
      creation, 370
      remote computer access, 371
      removal, 369
      searches, 362
      write to, 370
-Examples flag, 27
Excel, output management, 157
exception, 479
Exchange Management Console, 427
Exchange Management Shell, 427
Exchange Server 2007, 426
-Exclude, 315
executables, 139
execution policies, 474
      AllSigned, 288
      configuration, 12, 31
      execution, registry keys, 336-341
      ExecutionPolicy, 288
      RemoteSigned (recommended), 288
      Restricted, 288
      scripting, 287
      Unrestricted, 288
exit statement, 33, 184, 476
expanding strings, 446
Experiment with Exchange Management Shell, 427
Experiment with the command shell, 434
exponent, 118
Export command output as a web page, 170
Export-CliXml, 39, 153
Export-Csv, 155
expressions
      alternation, 493
      assertions, 492
      backreference, 494
      calculated property, 159
      character class, 488
      commonly used, 488
expressions (continued)
      constructs, 494
      escaped characters, 494
      grouping, 490-492
      patterns, 493
      quantifiers, 489
      regular, 488
Extending types, 471
extension points, 86
extensions (see snapins)
ExternalScript, 243

F[ Top ]
-f operator, 75, 457
Favorites, 249
fields, 79
file content, functions, 218
file, reading, 133
[File]::ReadAllText(), 134
files
      adding ending information, 41
      advanced associations, 29
      attributes, 124, 125, 312
      changes, monitoring, 321
      content
            cleared, 311
            removal, 311
            retrieval, 133
      create a file to hold the cmdlet and snapin source code, 280
      create a file to hold the hosting source code, 284
      creation, 280
      CSV, 155
      custom type extensions, 472, 82
      damage, checking for, 321
      determining differences between, 359
      directory search, 313
      encoded in Unicode or another code page, 144
      event log backup, 369
      extended properties, adding, 330-332
      filenames, 20
      filesystems
            access, 330
            hard link, 332
            navigation, 4
      filters, 149
      formatting, 481
      hashes, 321
      import and export structured data, 153
      integrity verification, 360
      Internet downloads, 160
      LDIF, import, 386
      manipulation of, 405
      modification
            before a certain date, 310
            checking for, 321
      moving, 326
      navigation, 14
      OEM code, 144
      removal, 324
      rename, 325
      searches, 135, 143
            specific items, 313
            match specific patterns, 314-317
      security vulnerabilities, 142
      signed, 289
      source code, 284
      special characters, management, 317
      temporary, 141
      text
            data, 110
            manage, 136
            parse, 136
            replace, 143
            unicode, 144
      Web pages, Internet downloads, 161
      wildcards, 313
      XML access, 147
      XPath query, 150
-Filter, 256, 315
Filter items in a list or command output, 50
filters
      command output, 50
      defining, 477
      errors, 51
      items in a list, 50
      key properties, 257
      keywords, 193
      LDAP, 393, 397
      object lists, 52-54
      parameters, 341
      properties, 257
      provider-specific, 315
      WMI, 257
Find a command to accomplish a task, 25
Find all files modified before a certain date, 310
Find event log entries by their frequency, 367
Find event log entries with specific text, 364
Find files that match a pattern, 314
Find items in an array greater or less than a value, 204
Find items in an array that match a value, 202
Find the location of common system paths, 248
Find the owner of a group, 398
Find your script's location, 247
Find your script's name, 246
FindAll(), 393, 397
findstr, 33, 135
firewall, 408-410
flags, 123
floating point
      numbers, 120
      values, 118
flow control statement, 466
fonts
      customization, 35
      Fonts, 249
for loop, 56, 92, 199
for statement, 464
-Force, 227
foreach
      cmdlet, 92
      defining, 464
      Foreach-Object, 55, 56, 199
      input, 188
      instances, 264
      loop, 92
      statement, 11
Forefront Security, 434
formal parameters, 474
Format a date for output, 108
Format.custom.ps1xml, 481
Format-List *, 42, 394, 398, 403, 481
Format-Table, 81
      -Auto flag, 43
      composable commands, 9
      custom column list defining, 43
      Get-Help Format-Table, 44
      hashtables, 43
      Name, displaying, 43
      properties, 480
      screen space, efficient use of, 43
formatting
      date and time, 522
      format operators, 128
      rules, 102
      strings
            numeric, 520
            syntax, 519
Formatting output, 480
Format-Wide, 102, 481
-Full flag, 27
FullControl, 330, 347
FullName, 156
functions
      arguments, 185-187
      calculations, 181
      command type, 243
      content, 477
      data return, 182
      defining, 180, 243, 473, 477
      directory creation, 324
      Function:, 311
      integration, 8
      libraries, 184
      name, 243
      options, 243
      scriptblock, 243
      writing, 179

G[ Top ]
GB (gigabyte), 8, 127
-ge operator, 204, 458
Generate large reports and text streams, 114
Get and list the properties of a computer account, 403
Get and list the properties of a user account, 394
Get detailed documentation about types and objects, 78
Get disk usage information, 318
Get help on a command, 26
Get, install, and uninstall management packs, 437
Get properties of remote registry keys, 351
Get registry items from remote machines, 349
Get the ACL of a file or directory, 327
Get the ACL of a registry key, 346
Get the children of an Active Directory container, 390
Get the content of a file, 133
Get the current location, 252
Get the files in a directory, 313
Get the MD5 or SHA1 hash of a file, 321
Get the newest entries from an event log, 363
Get the properties of a group, 397
Get the properties of an organizational unit, 388
Get the system date and time, 32
Get-Acl, 328
Get-AclMisconfiguration.ps1, 328
Get-Agent, 435
Get-Alert, 439
Get-AliasSuggestion.ps1, 37
Get-Answer.ps1, 162
Get-Arguments.ps1, 186
Get-AuthenticodeSignature, 295
Get-Characteristics.ps1, 139
Get-ChildItem, 115, 135, 159, 310
Get-Command, 10, 25, 77, 196
Get-Content
      files contents, 133
            monitor changes, 321
      item retrieval, 56
      ReadCount, 134
      strings, generate list of, 196
      syntax, 241
Get-Credential, 298
Get-Date, 32, 108, 183
Get-DetailedSystemInformation.ps1, 419
Get-DiskUsage.ps1, 319
Get-DistributionGroup, 431
GetEnumerator(), 207
Get-EventLog, 363
Get-FileHash.ps1, 322
Get-Help
      help on an item, 26
      view command results, 10
Get-Help About_Environment_Variable, 65
Get-Help About_Escape_Characters, 100
Get-Help About_For, 93
Get-Help About_Foreach, 93
Get-Help about_signing, 289
Get-Help About_Special_Characters, 100, 318
Get-Help About_WildCard, 316
Get-Help Add-DistributionGroupMember, 431
Get-Help Certificate, 304
Get-Help Clear-Content, 312
Get-Help Compare-Object, 359
Get-Help ConvertTo-Html, 170
Get-Help Disable-Rule, 438
Get-Help Enable-Rule, 438
Get-Help Export-CliXml, 361, 369
Get-Help Get-Agent, 436
Get-Help Get-Alert, 440
Get-Help Get-AuthenticodeSignature, 296
Get-Help Get-ChildItem, 311, 317, 318
Get-Help Get-Command, 26
Get-Help Get-Content, 134
Get-Help Get-Date, 32
Get-Help Get-DistributionGroup, 431
Get-Help Get-DistributionGroupMember, 431
Get-Help Get-EventLog, 369
Get-Help Get-ItemProperty, 338
Get-Help Get-Mailbox, 431
Get-Help Get-MaintenanceWindow, 437
Get-Help Get-ManagementPack, 438
Get-Help Get-OwaVirtualDirectory, 433
Get-Help Get-Process, 375
Get-Help Get-Rule, 438
Get-Help Get-Service, 381
Get-Help Get-Task, 439
Get-Help Get-User, 429
Get-Help Get-WmiObject, 257
Get-Help Import-CliXml, 369
Get-Help Install-ManagementPack, 438
Get-Help Measure-Command, 35
Get-Help Measure-Object, 123
Get-Help Move-Item, 327
Get-Help Move-Mailbox, 431
Get-Help New-ItemProperty, 340
Get-Help New-MaintenanceWindow, 437
Get-Help New-TransportRule, 432
Get-Help PowerShell, 77
Get-Help Read-Host, 210
Get-Help Registry, 338, 340
Get-Help Remove-Item, 312, 325
Get-Help Remove-ItemProperty, 339
Get-Help Rename-Item, 326
Get-Help Resolve-Alert, 440
Get-Help Set-Acl, 348
Get-Help Set-DistributionGroup, 431
Get-Help Set-ExecutionPolicy, 289
Get-Help Set-ItemProperty, 339
Get-Help Set-Mailbox, 431
Get-Help Set-OwaVirtualDirectory, 433
Get-Help Set-User, 429
Get-Help Start-Task, 439
Get-Help Stop-Process, 377
Get-Help Stop-Service, 382
Get-Help Trace-Command, 234, 483
Get-Help Uninstall-Agent, 436
Get-Help Uninstall-ManagementPack, 438
Get-Help Where-Object, 317, 377
Get-HelpGet-Acl, 346
Get-History cmdlet, 12
Get-InstalledSoftware.ps1, 410
Get-InvocationInfo.ps1, 244
Get-ItemProperty, 337
Get-Location, 252, 320
Get-MachineStartupShutdownScript.ps1, 407
Get-Mailbox, 430
Get-ManagementPack, 437
Get-Member, 10, 77, 469
GetNetworkCredential(), 298, 299
Get-OwnerReport.ps1, 81
Get-PageUrls, 163
Get-PageUrls.ps1, 164
Get-Process, 7, 22, 49, 196
Get-Progress.ps1, 45
Get-PsDrive, 83
GetRelated(), 262
Get-RemoteRegistryChildItem.ps1, 350
Get-RemoteRegistryKeyProperty.ps1, 351
Get-Rule, 438
Get-Service, 380
Get-Task, 439
Get-Tomorrow.ps1, 182
Get-TraceSource, 483
Get-User cmdlets, 428
Get-UserLogonLogoffScript.ps1, 406
Get-WarningsAndErrors.ps1, 228
Get-WmiClassKeyProperty.ps1, 258
Get-WmiObject
      data retrieval, 263
      instances, retrieval, 264
      startup mode, 382
      WMI access, 256
gibibytes, 127
gigabytes, 127
Global scope, 66
glue, xviii
GOTO, 180
greater than or equal operator, 458
grep, 110, 135
Group Policy
      Object Editor MMC, 293
      scripts, 405
Group Policy templates, 292
Group-Object, 367
-gt operator, 109, 204, 459
Guidelines for other resources, 220

H[ Top ]
handle count, 11
Handle warnings, errors, and terminating errors, 228
hard links, 332
hashtables
      access, 206, 452
      defining, 43, 451
      generating, 322
      hash algorithms
            MD5, 321
            SHA1, 321
      key and value pairs, 452
      mapping, 206
      order of, not retaining, 207
      sorting, 207
      (see also arrays)
HelpLink, 410
here strings, 97, 447
Hexadecimal and other number bases, 448
hexadecimal number, 128, 448
Hidden, 312
history storage properties, 35
HKCU:, 311
      drive support, 312
      (see also Registry)
HKLM:, 311
      drive support, 311
      (see also Registry)
HNetCfg.FwMgr COM, 409
HNetCfg.FWOpenPort COM, 409
host
      functionality, 222
      interface, 221
      Internet Explorer, names, 342
      keys, 342
      user interaction, 222
host.EnterNestedPrompt(), 231
hotfixes
      installation search, 417
      modified files, 136
hotkeys, 484
HREF, parsing, URL, parsing, 164
HTML, 162
      ConvertTo-Html, 170
      download, 161
      export, 170
      links, 163
      standards, 164
      Web pages, 162
HTTP (retrieving web content), 172

I[ Top ]
ICSharpCode.SharpZipLib.Zip, 277
if statement, 89, 460
Import structured data from a CSV file, 156
Import users in bulk to Active Directory, 391
Import-AdUser.ps1, 391
Import-CliXml, 153, 154, 369
Import-Csv, 57, 156
ImportNode(), 152
-Include, 313, 315
index (string formatting), 519
IndexOf(), 103
information
      dynamic, 99
      sensitive, 296
initialization, 464
Inline C#, 273-276
input
      low-fidelity, 110
      pipeline, 475
      reading, 209
      scripts, 474
Input to scripts, 474
-InputObject, 77
Inquire, 46
      ErrorAction preference, 479
      verbose preference, 483
Insert dynamic information in a string, 99
Install-AgentByName, 436
installing
      PowerShell, xxii
      snapins, 47
InstallUtil SnapinFilename.dll, 47
instance properties, 70
instances (see objects)
Instant Answers, 162
[int] (integer cast), 118
integers, 118
Interact with Internet protocols, 172
Interact with PowerShell's global environment, 254
Interacting with COM objects, 471
interactive shell, 4
      customization, 22, 35
      programs, running, 19
Interactively filter lists of objects, 52
Internet
      downloads, 160
      protocols, 172-175
      TCP (Transmission Control Protocol), 172
Internet Explorer
      configuration options, 343
      domain names, storage, 341
      Enhanced Security Configuration, 342
      security zone, 341
      site addition, 341
      UNC paths, 342
invalid command-line parameters, 45
investigate commands, 25
Investigate the invocationInfo variable, 244
InvocationInfo, 44, 244-246
InvocationName, 243
invoke, 20
      & (ampersand, invoke operator), 181
      & operator, 20
      Invoke-History, 38, 39
      Invoke-Item, 157
      scripts, 473
Invoke a PowerShell expression on a remote machine, 377
Invoke a PowerShell script from outside PowerShell, 29
Invoke a script block with alternate culture settings, 220
Invoke native Windows API calls, 271
Invoke-CmdScript.ps1, 31
Invoke-Inline.ps1, 274
Invoke-RemoteExpression.ps1, 378
Invoke-SqlCommand.ps1, 268
Invoke-WindowsApi.ps1, 271, 332
invoking scripts, 473
ipconfig, 6
      list all IP addresses for a computer, 423
      renew a DHCP lease, 420
      run on the remote computer, 423
-is operator, 460
-isnot operator, 460
IsReadOnly, 79, 312
items
      display properties as a list, 42
      display properties as a table, 42

J[ Top ]
Join-Path, 253, 320

K[ Top ]
KB (kilobytes), 127
keys, 210, 337
keywords, 11
kibibytes, 127
Kill() method, 8

L[ Top ]
languages
      C#, 273
      features, 273
      filtering, 316
      improve scripting, 267
      VBScript, 263
      WQL, 256
LastWriteTime, 122, 310
Launch a process, 375
LDAP filter, 385-404
-le operator, 204, 459
leading spaces, 107
Learn about types and objects, 77
Learning about types, 469
Length property, 7, 122
less than or equal to operator, 459
libraries, 277
      dot-source, 185
      functions, 185
      Library, 184
      naming conventions, 184
LibraryTemperature.ps1, 184
-like operator, 50, 88, 202, 459
links, parsing, 164
-List, 362
List a user's group membership, 400
List all event logs, 362
List all installed software, 410
List all IP addresses for a computer, 423
List all running services, 380
List and start tasks, 439
List currently running processes, 373
list evaluation syntax (@()), 189
List logon or logoff scripts for a user, 405
List network adapter properties, 424
List startup or shutdown scripts for a machine, 407
List the members of a group, 401
List the users in an organizational unit, 401
lists
      , (comma, list operator), 195
      arrays, 195
      computer account properties, 403
      all IP addresses, 423
      items
            searches for, 200
            sorting, 200
      pattern matching, 201
      statistical properties, 121
      trimming, 107
      variables, 196
literal strings, 446
-LiteralPath, 317
Load types from another assembly, 72
LoadWithPartialName, 73, 471
local scope, 66
Local Security Policy MMC, 294
LocalPolicy.CurrentProfile, 408
LocalPolicy.CurrentProfile.GloballyOpenPorts, 409
locations, 252
logical operators
      and, 455
      decisions based on, 87
      exclusive or, 455
      not, 455
      or, 455
logoff, 405
logon, 29, 405
loop labels, 464
looping statements, 56, 87, 91, 463, 464
Lower(), 106
lowercase, 106
-lt operator, 204, 459

M[ Top ]
Machine, 242
mail (see email)
Mailbox, 428
mailNickname, 397
maintenance window, 436
Make decisions with comparison and logical operators, 87
Make text selection easier, 484
Manage a running service, 382
Manage alerts, 439
Manage and change the attributes of a file, 312
Manage distribution groups, 431
Manage Exchange users, 428
Manage files that include special characters, 317
Manage large conditional statements with switches, 90
Manage mailboxes, 430
Manage Operations Manager agents, 435
Manage Outlook Web Access, 432
Manage PowerShell security in an enterprise, 292
Manage printers and print queues, 416
Manage scheduled tasks on a computer, 412
Manage transport rules, 431
management packs, 437
Managing errors, 478
mandatory parameters, 475
Map-Object.ps1, 181
Marshal, 298
-match operator, 88, 103, 202, 460
[Math], 118
math (see operations)
[Math]:::Abs(), 119
[Math]::ACos(), 119
[Math]::ASin(), 119
[Math]::ATan(), 119
[Math]::Cos(), 119
[Math]::Exp(), 120
[Math]::Log(), 120
[Math]::Pow() method, 119
[Math]::Sin(), 119
[Math]::Sqrt(), 119
[Math]::Tan(), 119
[Math]::Truncate(), 118
MB (megabytes), 8, 127
md function, 324
MD5, 321
Measure statistical properties of a list, 121
Measure-Command, 34
Measure-Object, 11, 121
mebibytes, 127
member types, 77
members, 80
-MemberType, 77
menus, 211
Message, 367
methods, 266, 468
      instances, 265, 468
      management infrastructure, 256
Microsoft
      Download Center, 386
      Script Center, 409
Microsoft Certificate Services, deploy, 293
Microsoft Forefront, 434
Microsoft Operations Manager, 434
mkdir, 324
modified data, 10
Modify data in an XML file, 151
Modify Internet Explorer settings, 343
Modify or remove a registry key value, 338
Modify properties of a security or distribution group, 399
Modify properties of a user account, 395
Modify properties of an organizational unit, 389
modulus operator, 455
Monitor a file for changes, 321
Move a file or directory, 326
Move-Item, 59, 327
Move-Mailbox, 430
mscorlib DLL, 74
MSDN documentation, 79
msiexec.exe, 412
multiplication, 454
MyCommand, 242, 476
MyDocuments, 249
MyProgram.exe, 339

N[ Top ]
namespace, 14, 75, 277
Navigate the registry, 336
navigation
      aliases, 337
      provider, 336
      registry keys, 336
-ne operator, 203, 458
negated equality operator, 458
NetCfg.FwMgr COM, 408
NetHood, 249
netstat.exe, 26
NetworkCredential, 299
New Certificate Rule, 294
New Mailbox, 428
-Newest, 363
New-FileSystemHardLink.ps1, 333
New-GenericObject.ps1, 74
New-ItemProperty, 339
New-MaintenanceWindow, 436
New-Object, 71, 195, 197, 470
New-SelfSignedCertificate.ps1, 291
New-TransportRule, 432
New-ZipFile.ps1, 334
NextValue(), 270
nonterminating errors, 479
-not operator, 455
-notcontains operator, 460
notepad, 6, 8
NoteProperty, 81, 472
-notlike operator, 89, 203, 459
-notmatch operator, 203, 460
-Noun, 25
nouns, 7, 177
Now, 468
number bases
      convert, number bases, 128
      hexadecimal
            binary, 128
            octal, 128
numbers
      alignment, 519
      assignments, 448
      bases, 448
      constants, 448
      conversions, 128
      format strings, 519
      (see also operations)
Numeric format strings, 519

O[ Top ]
objectClass=User, 402
objects
      .NET
            Framework, 8
            generate live, 71
            System.String, 10
      attributes, 124
      character counting, 7
      COM, 76
      constructors, 71
      custom methods, 80
      custom properties, 80
      defining, 61
      documentation, 78
      Foreach-Object, 56
      instance, 69, 77
      integration, 7
      output, 8, 22
      pipelines, 50
      process, 8
      Sort-Object, 49
      static members, 77
      structured command, 6
      System.Diagnostics.Process, 61
      unordered sets comparisons, 359
      Where-Object, 49
octal number, 449
octal representation, 128
OEM code, 144
Open or close ports in the Windows firewall, 409
operating systems (see systems)
operations
      administrative constants, 127
      advanced results, 119
      arithmetic, simple, 117-118
      binary numbers, 123
      calcualtions, 181
      conversions, 118, 128
      DateTime, 122
      functionality, 120
      property
            calculated, 319
            statistical, 121
      scripting language support, 118
      System.Math, 119
operations manager agents, 435
Operations Manager Command Shell
      agents, 435
      functionality, 434
      packs automation, 437
      maintenance window, 436
operators
      arithmetic, 117, 453
      binary, 456
      comparison, 458-460
      culture-neutral, 107
      logical, 455
      other simple, 457
      type replacement, 326
-or operator, 455
OU (organizational unit)
      containers, 390
      creation, 388
      lists of users, 402
      properties, 388
OuterXml, 149
Out-File, 40, 115
Outlook Web Access
      Get-Help Set-OwaVirtualDirectory, 433
      management, 432
      virtual directory, 432
output, 476
      capture, 476, 482
      CategoryView, 44
      command, 55
      dates, 108
      default encoding, 40
      detailed debug, 45
      errors, 44
      export as Web pages, 170
      formatting, 480
      huge files, 92
      InvocationInfo, 44
      plain text, 49
      progress, 45
      redirection operators, 40
      storage, 40
      verbose, 45, 483
      warnings, 230
      working with each list item, 55
      Write-Debug, 46
      Write-Progress, 46
      Write-Verbose, 46
output retrieval, 476
Output warnings, errors, and terminating errors, 230
Out-String cmdlet, 104, 482
-OutVariable parameter, 482
Owner file, 80

P[ Top ]
P/Invoke (Platform Invoke), 271-273
Packet privacy, 262
params, 185-187
parent scope, 66
parentheses (), 71
Parse and manage binary files, 139
Parse and manage text-based log files, 136
ParseExpression, 138
passwords
      Password, 299
      password.txt, 301
      requesting, 298
      security, 298
      storing on disk, 301
paste, 485
-Path, 315
paths, building, 253
pause command, 93
PE (portable executable), 139
Perform an XPath query against an XML file, 150
Perform complex arithmetic, 119
Perform simple arithmetic, 117
performance
      counter access, 270
      problems, 235
Perl, 95
permission, 347
Person, 452
personalized prompt, 22
ping, 33
pipeline (|), 9, 22, 49
      chain of scripts, 192
      cmdlet keywords, 189-193
      commas (,), 183
      full-fidelity objects, 49
      input, 188, 475
      output
            data return, 182
            two value arrays, 476
      writing oriented functions, 193
PipelineLength, 243
PipelinePosition, 243
Place common functions in a library, 184
Place formatted information in a string, 101
Place special characters in a string, 98
POP3 (receiving mail), 172
popd command, 6
ports, 409
positional parameters, 7
power of numbers, 119, 127
Prevent a string from including dynamic information, 100
printers
      basics, 413-417
      cancel print jobs, 416
      clear pending jobs, 416
      information retrieval, 413
      queue statistics, 414
PrintHood, 249
Private scope, 66
process keyword, 190
Process Monitor
      automate registry writes, 357
      begin capturing information, 356
      configuration and launching, 355
      information capture, 356
      manually set the configuration option, 356
      registry key settings, 354
      review the capture logs for registry modification, 356
      stop capturing information, 356
processes
      current running, 373
      keyword, 190
      launch, 375
      sort by start time, 374
      Startup, on a remote computer, 377-379
      stop or kill, 376
ProcessName parameter, 7
profiles, 486
      customization of, 486
      interactive shell, 23
      scripts, 25
      variables, 23
ProgID, 76
Program Files, 47
Programs, 249
Progress output, 46
progress updates, 216
prompts
      aliases, command commands, 37
      colors, use of in, 24
      customization of, 486
      ID history, 24
      Prompt function, 23
properties
      alphabetical sort, 157
      calculated, 81, 159
      of a collection, 77
      extended, adding, 330-332, 471
      instance, 468
      length, 122
      mapping steps, 59
      names, 59, 136
      -Property, 122
      public, 79
      static, 70, 468
      textual, 122
PropertySet, 472
Provide progress updates on long-running tasks, 216
providers, 14, 325
      accessing paths, 64
      content, 63
proxies, 166, 343
ps command, 373
PsBase, 261, 453
PsBase.Children, 390
-PsConsoleFile, 48
PsCredential, 298
PsDrive, 83
PSDriveInfo, 84
PsExec, 377
PsIsContainer, 50, 313
PSPath, 156
Public, 79
public constructors, 79
public fields, 79
public methods, 80
public properties, 79
Publisher software, 410
pushd command, 6
Push-Location, 6
Put(), 389, 399
pwd command, 6

Q[ Top ]
queries, 262, 265
Query a SQL data source, 267
question mark ($?), 33
queue statistics, 414
quickedit, 484
QuickEdit mode, 35, 36
-Quiet switch, 136
quotes ("), 20

R[ Top ]
radians, 119
Read a key of user input, 210
Read a line of user input, 209
ReadAllText(), 134
readcount file, 133
Read-Host, 93, 209
Read-HostWithPrompt.ps1, 211
ReadKey(), 93
ReadOnly, 124, 312
Recent, 249
Recipient configuration, 428
-Recurse, 313, 315
redirection operators, 40
[Reflection.Assembly]::Load(), 73
[Reflection.Assembly]::LoadFile(), 277
registry
      keys
            ACL (access control list), 346
            creation, 339
            modification, 338, 343
            program settings, 354
            properties, 351
            remote computers, 348
            removal, 338, 340
            searches, 344
            values, 353
            writes, 357
      navigation, 15
      Registry Editor, 286, 344
      RegistryAccessRule, 347
RegSetValue, 356
regular expression, 136, 460
RemoteRegistryChildItem, 348
RemoteSigned, 288, 356
Remove a file or directory, 324
Remove a registry key, 340
Remove a user from a security or distribution group, 400
Remove elements from an array, 203
Remove-Item, 311, 324, 340
Remove-PsDrive, 85
Rename a file or directory, 325
Rename-Item, 325, 326
Renew a DHCP lease, 420
repeat operations, 91
Repeat operations with loops, 91
-replace, 105, 110, 145, 326
-replace operator, 457
Replace text in a string, 105
Replace text in large files, 145
Replace text spanning multiple lines, 144
Replace text using a pattern instead of plain text, 144
Replace(), 105
reports, generating large, 114
Reset(), 475
ResolutionState, 439
Resolve-Path, 320
Restart-Service, 382
Restricted, 288
results, filtering language, 316
Resume-Service, 382
Retain changes to environment variables set by a batch file, 30
Retrieve a specific event log entry, 365
Retrieve printer information, 413
Retrieve printer queue statistics, 414
Retrieving data, 264
Retrieving output from scripts, 476
Return data from a script, function, or script block, 182
return statement, 180, 184, 476
roots
      cube, 120
      function, 120
      square, 119
RSS, feeds, 147
rules
      Deny, 330
      disable, 438
      enable, 438
Run a PowerShell command, 21
Run ipconfig on the remote computer, 421
Run programs, scripts, and existing tools, 19
RunAs, 300
running scripts, 473

S[ Top ]
S (static) icon, 79
safeguard techniques, 10
Safely build file paths out of their components, 253
sAMAccountName, 397, 403
Schedule a maintenance window, 436
schtasks.exe, 412
scope
      child, 66
      global, 254
      local, 66
      names, 477
      parent, 66
      -Scope, 66
      variables, 445
screen
      buffers, 484
      scraping, 162
Script blocks
            name, 244
      add a ScriptProperty, 84
      defining, 243, 478
Script scope, 66
Scriptblock, setscriptblock, 84
scripts
      .NET Framework, 11
      adding, 283
      arguments, 185-187, 474
      blocks
            alternate culture settings, 220
            data return, 182
            invoke, 220
            writing, 180
      calls, 29
      COM interfaces, 266
      for constant speed, 94
      current location, 320
      debug solutions, 231-233
      defining, 243, 473
      diagnostics, 231
      dot-source, 254, 473
      filenames, 177
      functions, 179
      guidelines, 220
      input, 474
      invoke, 29, 473
      keywords, 475
      libraries, 254
      location, 247
      name
            current running, 243
            finding, 246
      parameters, 474
      paths, programmatically specify, 243
      performance profile, 234-239
      PowerShell.exe, 29
      programmatically specify, 317
      readability, 31
      running, 473
      SCRIPT, 65
      ScriptLineNumber, 242
      ScriptMethod, 85, 472
      ScriptName, 242, 476
      ScriptProperty, 81, 83, 472
      SetScriptBlock, 84
      signed, 289
      testing on local installations, 385-387
      traces, 234
      ubiquitous, 11
      users
            input, 218
            interaction, 209
            written by, 283
      return values, 476
      writing, 176, 473
            culture-aware, 107, 217
            guidelines, 217
SDK libraries, 276
Search a file for text or a pattern, 135
Search a string for text or a pattern, 102
Search and replace text in a file, 143
Search for a computer account, 402
Search for a security or distribution group, 396
Search for a user account, 393
Search for WMI classes, 258
Search help for text, 28
Search the certificate store, 304
Search the Windows registry, 344
Search the Windows start menu, 250
Search-CertificateStore.ps1, 304
searches
      array, 202
      certificate store, 304
      commands, 25
      entries, 365
      event logs, 364
      files, 135
      finding domain names, 402
      help, 28
      -match, 103
      matching filters, 394
      for owners, 398
      patterns, 135
      regular expressions, 28
      SearchText, 135
      security group, 396
      StartMenu, 250
      strings, 102
      text, 25, 28, 135, 143
      verbs, 25
      wildcards, 103
      WMI, 257
Search-Help.ps1, 28
Search-Registry.ps1, 345
SearchScope, 402
Search-StartMenu.ps1, 251
Search-WmiNamespace.ps1, 258
Securely handle sensitive information, 296
Securely request usernames and passwords, 298
Securely store credentials on disk, 301
SecureString, unprotect, 296
security
      ACL (access control list), 328
      certificate searches, 304
      credentials, 300, 302
      digital signature, 290
      Enhanced configuration, 289
      enterprise setting, management, 292
      files, 142
      Forefront, 434
      groups, 395
      Internet Explorer Zone, 341
      misconfigurations, 328
      passwords, 298, 301
      policies
            execution, 288
            software restriction, 294
      privileges, 262
      properties, 397
      scripts, 21, 177, 287
      sensitive information, 296
      users, 298, 399
Sed, 110
Select-FilteredObject.ps1, 52
Select-GraphicalFilteredObject.ps1, 223
SelectNodes(), 150
Select-Object, 81
Select-String, 110, 135
Send an email, 170
Send-MailMessage.ps1, 171
Send-TcpRequest.ps1, 173
SendTo, 249
sessions, 38
      history, 12, 38
      transcripts, 41
Set, 79
Set properties of remote registry keys, 353
Set the ACL of a file or directory, 329
Set the ACL of a registry key, 347
Set-Acl, 329, 347
Set-Alias, 23
Set-AuthenticodeSignature, 289, 290, 303
Set-ConsoleProperties.ps1, 35
Set-Content variable, 241
Set-DistributionGroup, 431
Set-ExecutionPolicy, 287, 474
SetInfo(), 389, 395, 399
Set-ItemProperty, 338
Set-Location, 336
Set-Mailbox, 430
Set-OwaVirtualDirectory, 432
Set-PsDebug, 234, 482
Set-RemoteRegistryKeyProperty.ps1, 353
SetScriptBlock, 84
setup wizard, 386
Set-User cmdlets, 428
SHA1, 322
SHA256, 322
SharpZipLib, 277
Shell.Application, 331
Shift key, 211
shortcuts
      directory entries, 387
      invoke methods, 256
      operations, 93
      type, 470
      WQL language, 256
shutdown.exe, 26
SideIndicator, 359
Sign a PowerShell script or formatting file, 289
SilentlyContinue
      ErrorAction preference, 479
      hide output, 46
      verbose preference, 483
-Simple, 135
simple assignment, 448
simple operators, 453
Simplify math with administrative constants, 127
Simplify most where-object filters, 51
sine, 119
single quote ('), 20
single-line option (?s), 103, 138, 145
sites, 341
Size (MB), 81
snapins
      add to your session, 282
      compiling, 282
      defining, 282
      installation and registration, 282
      shell extensions, 47
      use of, 282
software
      list all installed, 410
      removal, 412
      restriction policies, 294
Software restriction policies, 294
sort a hashtable by key or value, 207
Sort an array or list of items, 200
sorting rules, 220
Sort-Object, 9, 49, 200
Source, 371
Split(), 110
square brackets ([]), 67
square roots, 119
Start a process as another user, 300
Start(), 107
StartMenu, 249
StartMode, 265
Start-ProcessAsUser.ps1, 300
Start-Sleep, 93
Startup, 249
statements, 443
      begin, 475
      break, 464, 466
      comparison value, 462
      conditional, 460
      continue, 464, 466
      control, 466
      do - until, 465
      do - while, 465
      end, 475
      exit, 476
      for, 464
      foreach, 464
      increment, 464
      looping, 464
      process, 475
      return, 476
      switch, 461
      while, 465
static, 468
      defining, 79
static IP address, 421-423
static members, 77
static methods, 68
static properties, 70
statistical properties, 121
Status, 50
Stop
      defining, 7
      ErrorAction preference, 479
      errors, 46
      -Process, 6, 10
      verbose preference, 483
Stop a process, 376
Stop-Process, 376
Stop-Service, 382
Stop-Transcript, 41
Store information in variables, 62
Store the output of a command in a CSV file, 155
streaming, 115
StreamReader, 141
strict mode, 231
String formatting syntax, 519
String(), 108
String.Format(), 102
strings
      arguments, 19
      capitalization, changing, 107
      creating, 96
      double quotes (" "), 96
      escape sequences, 96
      expanding, 96-98, 446
      format syntax, 519
      here strings, 447
      information
            dynamic, 99
            formatted, 101
      leading spaces, removal, 107
      literal (nonexpanding), 96-98, 446
      lowercase, 106
      multiline or formatted, 97
      numeric format, 519
      replacement rules, 96
      single quote ('), 96, 100
      special characters, 100
      text, literal strings and rules, 101
      trailing spaces, removal, 107
      uppercase, 106
      variable names, 100
      (see also here strings; variables)
structured commands, 7
subexpressions, 99
SubInAcl.exe, 347
subkeys, 342, 405
subtraction, 454
Summarize system information, 419
Suspend-Service, 382
/quiet switch, 412
switch statement, 90, 462
syntax
      filters, 397
      Noun, Verb, 499
System Center Demonstration Toolkit, 434
System Center Operations Manager 2007, 434
System.Collections.ArrayList, 73, 183, 206
System.DateTime, 70
System.Diagnostics.EventLog, 371
[System.Diagnostics.EventLog]::CreateEventSource(), 369
[System.Diagnostics.EventLog]::Delete(), 370
[System.Diagnostics.EventLog]::DeleteEventSource(), 370
System.Diagnostics.PerformanceCounter, 270
System.Diagnostics.Process, 61, 68, 374
[System.Diagnostics.Process]::Start(), 375
System.Diagnostics.ProcessStartInfo, 375
System.DirectoryServices.DirectorySearcher, 393, 397, 402
[System.Environment]::CurrentDirectory, 70
System.Globalization.StringInfo, 219
System.IO.DirectoryInfo, 314
System.IO.FileInfo, 314
[System.IO.Path]::GetTempFilename(), 141
System.Management.Automation.PSDriveInfo, 83
System.Management.ManagementClass, 262
System.Management.ManagementObject, 262
System.Management.ManagementObjectSearcher, 262
System.Math, 119
System.Net.Mail.MailMessage, 170
System.Net.WebClient, 160, 161
System.Reflection.Assembly, 72, 470
[System.Reflection.Assembly]:LoadFile(), 277
System.Security.AccessControl.FileSecurity, 328
System.Security.AccessControl.RegistrySecurity, 346
System.Security.Cryptography.X509Certificates.X509Store, 304
System.ServiceProcess.ServiceController, 381
[System.ServiceProcess.ServiceController]::GetServices(), 383
System.Text.StringBuilder, 116
System.Web.Mail.SmtpMail, 172
System.Xml.XmlDocument, 149
System.Xml.XmlElement, 149
systems
      attributes, update, 312
      date, 32
      event logs, 362
      information, summarize, 419
      inventory, 264
      operatingSystem, 403
            ServicePack, 403
            Version, 403
      path location, 248
      services, 380-384
      System.Diagnostics.Process, 8
      time, 32

T[ Top ]
tab, 7, 98
      completion, 487
      Tab key customization, 487
      tabexpansion, 487
tables, formatting, 43
tail, 321
tangent, 119
Target parameter, 242
tasks, 56, 439
      administration, 25, 412
      advanced, 261
TCP (Transmission Control Protocol), 172
Telnet, 172
Templates, 249
terminating errors, 228, 479
Test active directory scripts on a local installation, 385
Test instance, 386
Test-HotfixInstallation.ps1, 418
throw statement, 230
Ticks property, 122
-TimeStampServer, 290
tokens, 443
TotalDays property, 8
trace
      defining, 482
      sources, 234, 483
      -Trace parameter, 234
      Trace-Command, 234
trailing spaces, 107
transport rules, 431
trap statement, 228, 479
Trim a string, 107
Trim(), 107
true or false, 50, 88, 136
truncation, 118
Trusted Publishers Management, 295
type
      capitalization, changing, 107
      case-insensitive, 107
      classes, with long names, 74
      conversions, 458
      default, 72
      documentation, 78
      event log retrieval, 364
      extension files, 86, 82
      header removal, 373
      instances, 470
      libraries (assembly), 72
      methods, 82, 469
      namespace, 75
      to object conversion, 110
      operators, 460
      patterns, 144
      processing, 373
      properties, 82, 469, 471
      replacement, 105, 110, 144
      safety, 73
      searches, 110, 135
      selection, 484
      shortcuts, 72, 470
      static members, 77
      Types.custom.ps1xml, 83, 473
      types.ps1xml, 472
Types.custom.ps1xml, 83, 473
types.ps1xml, 472
Typing for long class names, 74

U[ Top ]
ubiquitous scripting, 11
-UFormat, 108
unary operator, 78, 88
UNC paths, 342
unicode
      text files, 144
      Unicode standard format, 29, 218
Uninstall an application, 411
Uninstall-Agent, 435
UninstallString, 410
Unrestricted, 288
Update-FormatData cmdlet, 481
Update-TypeData, 83
Upper(), 106
uppercase, 106
URLs, HTML Web page links, 163-166
Use .NET to perform advanced WMI tasks, 261
Use a COM object, 76
Use Excel to manage command output, 157
Use hotkeys to operate the shell more efficiently, 484
Use the ArrayList class for advanced array tasks, 205
Use the Win32_NetworkAdapterConfiguration WMI class, 421, 423
Use-Culture.ps1, 220
users
      accounts
            creation, 390
            Guest, 329
            import, 391
            property lists, 394
            searches, 393
      Active Directory, 428
      certificates, 303
      email, 428
      Exchange management, 428
      file content, 218
      first-class, 8
      input, 209
      interfaces
            graphic, 223
            host, 221
      invoked commands, 242
      menus, display, 211-213
      output and messages, display, 213-215
      property modification, 395
      script interaction, 209
      SID, 405
      start processes, 300
      supplied name, 243
      variable settings, 241
      written by, 283
User, 242
User Mailbox, 428
UserName, 299, 405
utilities
      tool directory, 21
      zip, 334

V[ Top ]
values
      binary, 124
      false, 124
      pipeline by property name, 59
      registry keys, 337, 451
      return, 180
      true, 124
Value, 207
variable storage, 242
variables
      access control, 65
      automatic, 496
      calculations, 55
      configurations, 46
      defining, 65, 444
      environment, 30, 63, 240
      escaping support, 64
      expansion, 96
      $false, 34
      functions, 66
      global, 254
      input object, 50
      newlines, 97
      numeric data, 448
      scope control, 65
      script
            exit codes, 33
            storage, 23
      security, 297
      special characters, 98
      status of last command, 33
      storage
            credentials, 301
            information, 62
            results, 8
      string, 95
      subexpressions, 99
      syntax, 64
      True, 50
      values, 84, 99
Variable:, 311
VBScript
      administrators, 256
      conversion to PowerShell, 410
      data retrieval, 264
      improve language, 267
      WMI conversion, 263
-Verbose, 46
verbose
      automatic variables, 483
      output, 46
verbs, 7, 177
      action on an item, 177
      Noun, Verb
            common verbs, 499-501
            pattern, 3, 6, 26, 177
            syntax, 499
-Verb, 25
Verify integrity of file sets, 360
Verify the digital signature of a PowerShell script, 295
VerifyCategoryRule.ps1, 283
View a registry key, 337
View and modify environment variables, 240
View the errors generated by a command, 226
virtual directory, 432
virtual labs, 434
Virtual PC images, 434
visibility, of items, 66
visit each element of an array, 199
VMImages directory, 435
[void], 183

W[ Top ]
-Wait, 321
WaitForExit(), 69
warnings
      alerts, management, 439
      management, 228-229
      output, 230
Web
      HTML, 162
      Internet downloads, 161
      proxies, 167
      service connections, 166-169
      WebClient, 161
      XHTML, 162
WebService, 166
-WhatIf, 10, 382
Where-Object, 9, 49-51, 310
while statement, 465
whitespace characters, 107
wildcards
      *.txt, 135
      characters, specify ranges of, 318
      discovery commands, 10
      defining, 103
      list, 313
      support, 7, 27, 314-317
Win32_NetworkAdapterConfiguration, 421, 423, 424
Win32_PerfFormattedData_Spooler_PrintQueue, 414
Win32_Printer, 413
Win32_PrinterConfiguration, 414
Win32_PrinterController, 414
Win32_PrinterDriver, 414
Win32_PrinterDriverDll, 414
Win32_PrinterSetting, 414
Win32_PrinterShare, 414
Win32_Product, 412
Win32_QuickfixEngineering, 417
Win32_TCPIPPrinterPort, 414
WinDiff, 359
window
      maintenance, 436
      size, 35, 484
Windows
      cooked input mode, 36
      SDK download, 279
      standard command names, 177
      Start menu, console customization, 36
      tools and applications, 6
      WMI (see Windows Management Instrumentation)
      XP SP2, 409
Windows Management Instrumentation (WMI)
      class searches, 258-261
      class subsets, 509-515
      libraries, xviii
      management infrastructure, 256
      technologies, bridging, 13
Windows SDK, 279, 283
wizard guided tasks, 427
WMI (see Windows Management Instrumentation)
WMIC tools, 256
[WmiClass], 256, 263, 266
[WmiSearcher], 256
word count, 121
Work with .NET objects, 67
Work with each item in a list or command output, 54
Work with numbers as binary, 123
Work with the registry of a remote computer, 348
Working with degrees instead of radians, 121
Working with the .NET Framework, 467
Write a function, 179
Write a pipeline-oriented function, 193
Write a script, 176
Write a script block, 180
Write culture-aware scripts, 217
Write pipeline-oriented scripts with cmdlet keywords, 189
Write to an event log, 370
Write-Debug, 46, 214, 231
WriteEntry(), 370
Write-Error, 230, 479
Write-Host cmdlet, 24
Write-Output, 183
Write-Progress, 46
Write-Verbose, 46, 214
WriteVerbose(), 483
Write-Warning, 230
writing scripts, reusing functionality, 473
WScript.Shell COM, 248
WSH scripters, xviii

X[ Top ]
XHTML web pages, 162
XML
      access information, 147
      content, 12
      items, filtering, 149
      modify data, 151
      OuterXml, 149
      variables, 452
      XmlDocument, 453
      XmlElement, 453
      XPath query, 150
XML, save, 153
XmlDocument, 147
XmlElement, 147
-xor operator, 455
XPath query, 150
xport-CliXml, 360

Z[ Top ]
zero-based index, 519
ZIP
      ZIP archives, 334
      ZipEntry, 277
zone identifier, 344


Return to Windows PowerShell Cookbook