excerpt_index

Document Sample
excerpt_index Powered By Docstoc
					index

Symbols                                              A
-- symbol 41                                         abstraction 8
./ prefix 45                                         access controls, and endpoints 533–535
.\ prefix 45                                         access restriction 543
(see!) argument 228                                  access to current tab 623
@ symbol 37, 95                                      accessing COM objects 767
@( ... ). See array subexpressions                   AccessMode module 388
& operator 415                                       accidental code injections 439
                                                     accidental execution 276
& symbol 37
                                                     accumulated results, in variables 208
# character 58
                                                     acronyms 37
% alias 684
                                                     -Action parameter 855
+ symbol 59                                          Action parameter 842
+= operator 685                                      Action property, on PSBreakpoint object 654
> operator 181                                       action script block, in breakpoints 658
>> operator 181                                      actions
$_ variable 37, 217–218, 224, 265, 572, 677             asynchronous events 854
$? variable 564–565, 621, 794                           running upon module removal 389–391
$( ... ). See subexpressions                         Actions.Create() method 789
$count variable 379                                  Active Directory Services Interface (ADSI) 75
$error variable 560–561                              active scope 652
                                                     ActiveScript engine 783
Numerics                                             ActiveX Data Objects (ADO) 75
                                                     adaptation 761
2> operator 181                                         extending objects 401
2>&1 operator 181                                       of existing member 427
2>> operator 181                                        synthetic members 402
32-bit applications, 64-bit applications vs. 793     adaptation layer, COM 762
32-bit operating systems 499                         adapter mechanism 77
64-bit applications, vs. 32-bit applications 793     add members 401
64-bit operating systems 499                         add property 405

                                                   929
Add() method 261, 746                           aggregating events with GROUP
add/remove software, appwiz.cpl command 597         keyword 874–875
add_Click() method 850, 855                     algorithms
addition operator 113–116                           comparison 128
addition, with hash tables 115                      module search 329–330
Add-Member cmdlet 423, 425                      Alias attribute, creating parameter aliases
   addressing, remoting target 518–520              with 303–305
     connecting to nondefault ports 518–519     -Alias parameter 334
     DNS names and IP addresses 518             alias property 404
     proxy servers 520                          alias: drive 667
     using URI 519                              aliased members 405
   using to extend objects 402–408              aliases
     adding AliasProperty members 404–405           and elastic syntax 47–50
     adding NoteProperty members 405–406            listing definitions 667
     adding ScriptMethod members 406–407            predefined 48
     adding ScriptProperty members 407–408          why use parameter alias 49
Add-Type cmdlet 710, 723                        AliasesToExport element 370
   compiling code with 440–446                  AliasProperty members, adding to
     defining new .NET class with C#                objects 404–405
          language 440–442                      -All flag 351
     defining new enum types at                 -AllMatches switch 692
          runtime 442–443                       Allow Automatic Configuration of Listeners
     dynamic binary modules 443                     policy 453
   defining new types with 729–739              -AllowClobber parameter 480
     creating Singleton member                  AllowEmptyCollection attribute 306
          definitions 730–734                   AllowEmptyString attribute 306
     interoperation with P/Invoke               AllowNull attribute 306
          signatures 734–735                    AllowNullExample function 306
     -Path parameter set 737–739                AllSigned execution policy 899
     -TypeDefinition parameter set 736–737      alternate layouts, in ISE 609
   example 731                                  Alt-F4 shortcut, ISE 611
   -IgnoreWarnings parameter 731                AMD64 processor 500
   -Language parameter 730                      Anchor property 749
   -Path parameter set 737                      -and operator 149
   singleton member definitions 730             anonymous code 658
   -UsingNamespace parameter 730                anonymous filter 266
Admin Script PowerShell IDE 752                 anonymous functions 398
Administrator privileges 517                    APIs (application programming interfaces) 7
Administrators group 517                            debugging with host 580–593
administrators, in other domains                       catching errors with strict mode 582–584
   enabling remoting for 517–518                       Set-StrictMode cmdlet 584–589
ADO (ActiveX Data Objects) 75                          static analysis of scripts 589–593
ADSI (Active Directory Services Interface) 75       interoperation with 69
-After parameter 601                            AppActivate() method 778
agentless monitoring using remoting 462         AppDomain class 725


930                                                                                       INDEX
appending error records 183                             convert array to string 677
Application Data directory 668                          determining unique members 684
Application event log 879                               discarding empty elements 683
Application log 602                                     grouping by key property 686
application output redirection, in ISE 617              indexing with negative values 685
Applications list, controlling access to 540            number of occurrences 684
Applications property, From                         array operators 112, 162–173
    $ExecutionContext.SessionState 539                  comma 162–165
applications. See also native commands                  indexing and slicing 167–170
    issues in ISE 616                                   multidimensional 171–173
    managing with COM 779–783                           range 165–167
       looking up word definitions using Internet   array slicing 197, 603
            Explorer 779–781                        array subexpression operator 158
       spell checking using Microsoft               ArrayList class 261
            Word 781–783                            arrays 91–96
    native executables and PowerShell paths 666         0 origin 24
appwiz.cpl command 597                                  as reference types 93–94
$args scalar 238                                        collecting pipeline output as 91–92
$args variable 241, 278, 289                            concatenation of 25
    passing arguments using 237–239                     empty arrays 94–96
                                                        indexing of 92
    simplifying processing with multiple
                                                        multiplication of 116
        assignment 240
                                                        of characters 435
$args.length 246
                                                          converting to string 406
argument processing, by ForEach-Object
                                                          string as 406
    cmdlet 227–228
                                                        of indexes 172
ArgumentList parameter 358
                                                        polymorphism in 92–93
arguments 60, 174
                                                        presentation in tracing 641
    handling variable numbers of 245–246
                                                        resizing 259
    passing to scripts 278–280                          subexpressions 160–162
    passing using $args variable 237–239            -as operator 152, 154
    printing 222                                    -As parameter 712
    specifying to switch parameters 250–252         ASCII encoding 679
    vs. parameters 39                               AsCustomObject parameter 417
-Arguments parameter 813                            AsCustomObject() method 382
arithmetic operation 24                             -AsJob parameter 481, 489–490, 492, 802–803,
arithmetic operators 112–119                            882
    addition 113–116                                -AsSecureString parameter 917
    multiplication 116–117                          assemblies 721–725
    subtraction, division, and modulus 117–119          default 722
[array] class 170                                       loading
array assignment 94                                       dynamically 722–723
Array class 434                                           using Load() method 724
array concatenation 113                                   with Add-Type 723
array literals 91                                         with System.Reflection.Assembly
array operations                                               class 723–725


INDEX                                                                                         931
    pros and cons of dynamic linking 721              automatic type conversion 154
    versioning and 721–722                            automatic variables 224, 437, 860
assembly manifest 721                                 automatically generated help fields 315
Assembly property 444                                 automating applications 765
-AssemblyName parameter 759                           automation interfaces 761, 763
assets                                                Automation model 765
    definition 893                                    AutoReset property 857
    threats, mitigation, and 893–897                  -AutoReset timer property 728
      authentication, authorization, and              -AutoSize switch 65–66
           roles 894–895                              AWK 224
      avoiding lawn gnome mitigation 893–894
      blacklisting/whitelisting 894                   B
      code injection 896–897                          background color, setting in ISE 625
      input validation 895–896                        background jobs 481–493
assignable elements 122                                  cmdlets 483–487
assignable expressions 155                                  removing jobs 487
assignment expressions                                      waiting for jobs to complete 486
    as value expressions 123                             commands 483
    syntax 120                                           multiple 487–489
assignment operators 119–124, 187                        running in existing sessions 492–493
    as value expressions 123–124                         starting on remote computers 489–492
    multiple 120–123                                  background processing, using ISE tabs 628
asynchronous events 853–855                           backquote character 52
    .NET 855–860                                      backslash character 54
      managing subscriptions 859–860                  backtick character 52, 669
      writing timer event handler 856–859             base class 423
    eventing cmdlets 854–855                          bash shell 6, 38
    handling with scriptblocks 860–863                bash, Windows 4
      automatic variables 860                         Basic type 514
      dynamic modules and event handler               bastion server 515
           state 862–863                              -Before parameter 601
    subscriptions, registrations, and actions 854     begin blocks, functions with 266–267
attacks, defined 892                                  begin clause 61, 397, 419
authentication                                        begin keyword 266
    authorization, roles, and 894–895                 Begin() function 420
    connecting user 514–518                           BeginInit() method 726
      enabling remoting for administrators in other   BeginInvoke() method 726
           domains 517–518                            begin-processing clause 62
      forwarding credentials in multihop              binary data operations 674
           environments 515–517                       binary modules 353
    target computer 511–514                              creating 355–357
    to server 511                                        dynamic 443
-Authentication parameter 803                            nesting in script modules 357
Author element 367                                       vs. snap-in modules 354–355
authorization, authentication, roles, and 894–895     binary operator 179, 225


932                                                                                             INDEX
binary tree 163                            building objects, in PowerShell 400
binding                                    built-in $PSHOME variable 333
   event action 857–858                    built-in commands 42
   objects, data and methods 400           built-in type conversion 104
   parameters pipelines and 62–63          Button control 755
bitmap files                               Button object 850, 855
   dumping 676                             by reference 94
   working with 677                        bypass security boundary, using scriptblocks 541
BitsTransfer module 363                    bypass type adapter 824
bitwise operators 148–150                  byte order mark (BOM) 613
blacklisting/whitelisting 894
block of code, trap statement scope 570    C
.BMP files. See bitmap files               C# language 201, 261, 440–442, 570, 575
boilerplate preamble 551                   $c2 variable 417
BOM (Byte order mark) 613                  caching security 905
[bool] parameter 252–253                   calc process 822, 842, 869
[bool] type 107                            calculated field 411
[bool] type accelerator 252                calculated module exports 346–347
Boolean parameters 252–257                 calculated property 805
bootstrap remoting 453                     call (&) operator 286
bottom-tested variant, of while loop 204   call operator 537, 569
bound variables 414                            executing script block with 438
boundaries 543                                 script blocks 396
Bourne shell 9                             CallExit function 280
bp function 647                            calling functions 242
braces, mandatory in statement lists 201   calling modules
branching 215                                  defining modules vs. 384–387
break keyword 571, 655                           accessing defining module 385–386
break statement 212–216, 220               Call-JScript function 785
breakpoint command 646–647                 Call-VBScript function 784
breakpoint ID 654                          -CancelTimeout parameter 526
breakpoint line, highlight in ISE 649      candidate conversion 106
breakpoints                                CanInvoke property 626–627
   conditional breakpoints 654             canonical aliases 673
   objects 653–656                         captures 563
   setting                                 capturing error objects 555
     on commands 656–657                   capturing error records 556, 560
     on variable assignment 657–658        capturing errors 566
browser cache path issues 668              capturing script output 593
browser windows                            -case flag 218
   management module 770–777               -case option 218
     adding graphical front end 773–774    case-insensitive 116
     defining control actions 775–776      case-insensitive keywords 199
     XAML 774–777                          -casesensitive option 217
   managing using COM 767–770              -CaseSensitive parameter 689


INDEX                                                                                   933
case-sensitivity, comparison operators           Microsoft WMI, using Get-WmiObject cmdlet
   and 127–128                                       to find 806–807
cast notation 96, 185                        cleaning up breakpoints 656
casting 153                                  Clear() method 636
   strings to arrays of characters 406       Clear-EventLog cmdlet 597
   to void 156                               Clear-Item cmdlet 673
catch keyword 575                            Click event 746
categories, of COM objects 794               Click() method 746, 757
CategoryInfo property 557                    clipboard, Windows 17
cd alias, For Get-Location 665               clippy function 268
-ceq operator 125                            CliXML format 632
Certificate snap-in 908                      Clixml format 717
certificates                                 clobbering output 184
   exporting 913                             Clone() method 90
   self-signed 905–909                       Close() method 746
   using to sign scripts 909–912             closures 414–417, 638
      setting up test 909–910                CLRVersion element 367–368
      signing test 910–912
                                             Cmd.exe 281
      testing integrity 912
                                             cmd.exe 4, 187
Certmgr.exe (Certificate Manager tool) 913
                                                 /c option 565
chained cast 102
                                                 and PSPaths 666
change-tolerant scripts 137
                                                 and transcript files 596
[char] class 677
                                                 command completion 20
char array 729
character classes 682                            command equivalents 673
character encodings 674, 679                     convenience aliases 673
checksum function 680                            security 889
child jobs                                   -Cmdlet parameter 334
   and nesting 489–490                       cmdlet Verb-Noun syntax 47
   with Invoke-Command cmdlet 490–492        CmdletBinding attribute 289, 296
ChildJob property 491                            $PSCmdlet variable 293
ChildJobs property 490                           ConfirmImpact property 293
Church, Alonzo 394                               DefaultParameterSetName property 293
CIM (Common Information Model)                   SupportsShouldProcess property 290–293
   namespaces 8, 807–810                     cmdlets 13, 42–43, 483
CIM_Process class 799                            background jobs 483–487
CIM_Process.Terminate() method 799                  removing jobs 487
class definition, removing 432                      waiting for jobs to complete 486
class keyword, implementing 431                  commands and 38–42
-Class parameter 807, 818                        flow control using 223–231
class-based event registrations, Microsoft          ForEach-Object cmdlet 223–228
   WMI 867–870                                      Where-Object 228–231
   using WIN32_ProcessTrace events 868–870       formatting and output 64–70
   verifying that events fired 870               Microsoft WMI 801–824
classes                                             common parameters 802–803
   defined 12, 429                                  Get-WmiObject cmdlet 804–813


934                                                                                INDEX
cmdlets (continued)                                colon character, in variable names 186
      invoke-WmiMethod cmdlet 819–822              color names 625
      remove-WmiObject cmdlet 822–824              COM (Component Object Model) 760–796
      Set-WmiInstance cmdlet 813–819                  adapter issues and limitations 793
   variable 188–193                                   automating Microsoft Windows with 764–777
      getting and setting options 189–191                browser window management
      indirectly setting 188–189                             module 770–777
      names vs. values 192–193                           managing browser windows using
      using PSVariable objects as                            COM 767–770
           references 191–192                            Shell.Application class 765–766
   verb-noun pairs 13                                 classes, identifying and locating 762–764
   WS-Man 831–832                                     in ISE 618
      invoking methods with Invoke-WSManAc-           Interop assembly 794
           tion cmdlet 841–846                        issues with 793–796
      retrieving management data with Get-WSMa-          64-bit vs. 32-bit applications 793
           nInstance cmdlet 832–839                      interop assemblies, wrappers, and
      updating resources using Set-WSManInstance             typelibs 793
           cmdlet 840–841                                threading model problems 793
   WSMan implementation 509–511                       managing applications with 779–783
      establishing remote connection 510–511
                                                         looking up word definitions using Internet
      testing connections 510
                                                             Explorer 779–781
CmdletsToExport element 370
                                                         spell checking using Microsoft
code
                                                             Word 781–783
   compiling with Add-Type cmdlet 440–446
                                                      Microsoft Windows Task Scheduler 786–793
      defining new .NET class with C#
                                                         Schedule.Service class 786–787
           language 440–446
                                                         tasks 787–793
      defining new enum types at
           runtime 442–443                            objects 761–762
      dynamic binary modules 443–446                  WScript.Shell class 777–779
   example                                            WSH ScriptControl class 783–786
      basic expressions and variables 23–25              embedding JScript code 785–786
      navigation and basic operations 22–23              embedding VBScript code 784
code execution 893                                 comma operator 162–166, 197
code injection 896–897, 924                        command aliases, for DOS and UNIX 22
code injection attacks 439                         command completion 13, 20–21
Code reuse role 324                                command discovery 394
CodeMethod type 403                                command editing, in console host 16
CodeProperty type 403                              command history 6
code-signing 907                                   command information 399
coding exercise 890                                command input editor, ISE 608
collection comparisons 129                         command interpreter, vs. shell 6
collection type 108                                command line debugger 638
collections 24                                     command lines 6–7, 267
   of numbers 263                                  command mode 54, 59
   of objects 215                                  command not found error, and private
   using comparison operators with 129–131            commands 540


INDEX                                                                                          935
command not found exception 422                     executing other in debug mode 651
command output, parsing using regular               first element of 39
  expressions 136–137                               invoking 394–396
command pane 608–609                                native, issues with 616–617
-Command parameter 285                              no concurrent in session 468
command path, managing 898                          offset in pipeline 559
command resolution, in constrained sessions 548     prefixing 45
command switches, using switch parameters to        proxy, creating with steppable
  define 248–252                                        pipelines 420–423
command type 396                                    running in traditional shells 209
command visibility                                  setting breakpoints on 656–657
  controlling 536–539                               with built-in remoting 448–449
  in remoting 535                                 comma-separated values 143
CommandInfo object 382, 395–396, 476, 536         comment block 904
CommandInfo, FunctionInfo subclass 399            comment syntax 58–60
command-line debugging 652–660                    comments
  breakpoints                                       comment-based help 316–318
    objects 653–656                                 tags used in 318–321
    setting 656–658                                    .COMPONENT help 320
  debugger limitations and issues 658–660              .EXTERNALHELP help 320–321
command-line editing 16                                .FORWARDHELPCATEGORY help 320
command-mode parsing 54–56                             .FORWARDHELPTARGETNAME
CommandPaneUp, ISE menu item 625                            help 320
commands                                               .LINK help 320
  anatomy of 38                                        .PARAMETER help 319
  and cmdlets 38–42                                    .REMOTEHELPRUNSPACE help 320
  background jobs 483                             Common Information Model (CIM) 8, 709
  break-down of 39                                -ComObject parameter 761
  breakpoint 646–647                              CompanyName element 367
  built-in 42                                     comparison operators 124–131
  categories of 42–46                               and case-sensitivity 127–128
    cmdlets 42–43                                   case sensitivity factor 124
    functions 43                                    design rational 125
    native commands 44–46                           left-hand rule 126
    scripts 44                                      scalar 125–127
  considerations when running                          basic comparison rules 126
      remotely 493–501                                 type conversions and comparisons 126–127
    executables 495–496                             using with collections 129–131
    processor architecture 498–501                compile time 436
    profiles and remoting 494–495                 compiled script 438
    reading and writing to console 496–497        compile-time error 185
    remote output vs. local output 497–498        compiling code, with Add-Type cmdlet 440–446
    remote session startup directory 494            defining new .NET class with C#
  converted 40                                          language 440–442
  determining if errors in 564–566                  defining new enum types at runtime 442–443
  executing in ISE 614–616                          dynamic binary modules 443–446


936                                                                                     INDEX
complete statement 56                             connections
complied programs 722                                establishing remote 510–511
.COMPONENT help tag 320                              persistent, remoting sessions and 462–473
Composing solutions role 324                         testing 510
composite management applications, mash-          Connect-WSMan cmdlet 509, 514
   ups 324–325                                    Connect-WSMan command 525
compound assignment operators 120                 console
compression, of properties in serialization 509      reading and writing to 496–497
-ComputerName parameter 602, 805                     threading differences between ISE and 618
COMtools.psm1 module 770–771                      console APIs 735
-Concatenate parameter 513                        console applications, in ISE 616
concatenated statements 80                        console editing features 16
concatenation, of arguments 240                   console host 14–16
concrete system resources 799                     console objects 616
concurrency, adding to remoting                   Console.ReadLine API 496
   examples 455–457                               Console.WriteLine API 496
concurrent connections                            [ConsoleColor] parameter 310
   fan-in remoting 528                            constant expression folding, in PowerShell 562
   fan-out remoting 528                           constant expressions 562
   limiting 522                                   constant variables 184
concurrent operation                              constrained application environment, in
   using remoting 455                                remoting 530
   with jobs 487                                  constrained endpoint 543
concurrent sessions, in ISE 607                   constraining
condition part, of if statement 202                  execution environments 543
condition test 206                                   sessions 535–543
conditional breakpoints 654                            controlling command visibility 536–539
conditional matches 219                                setting language mode 539–543
conditional statement 199–203                     construction elements, module manifests 370–375
configuration script                                 loader elements 371–373
   boilerplate 551                                   module component load order 374–375
   updating 549                                   Constructors type 106
configuration updates, scope of change 549        containment operators 130–131
-ConfigurationName parameter 530                  -contains operator 130–131
configurations 530–535                            content elements, module manifests 375–376
   creating custom 531–533                        context properties, searching with 692
     registering endpoint configuration 532–533   context-sensitive keywords 199
     session configuration 531–532                continue keyword 571
   setting security descriptors on 534–535        continue statement 212–215, 220, 571
Configuring the environment role 324              contract parameter 305
-Confirm flag 292                                 control actions, defining 775–776
ConfirmImpact property 293                        control flow, in trap statement 572
$ConfirmPreference preference variable 293        control structures 393
connection patterns, remote services 527–530      control transfer, in trap statements 570
   fan-in 528–530                                 Controls member 751
   fan-out 527–528                                convenience aliases 48


INDEX                                                                                        937
conventions, used in examples 15                  Ctrl-Break 616
conversion and precision 73, 102                  Ctrl-C 616
conversion error 185                              Ctrl-F5 637
conversion rule 113                               Ctrl-N 611, 625
conversions, of types 101–109                     Ctrl-O 612
    .NET-based custom 104–107                     Ctrl-R 611
    built-in 104                                  CUA (Common User Access) 17, 610
    in parameter binding 107–109                  currency symbol 181
    overview 101–104                              current directory 208
ConvertFrom-SecureString cmdlet 918               current execution line, displayed in debugger 649
ConvertTo-SecureString cmdlet 918                 Current property 264
ConvertTo-Xml cmdlet 711–714                      current scope 280
copying elements 114                              current state 769
copying, into Windows clipboard 17                current working directory 111
Copy-Item cmdlet 239, 673                         CurrentDomain property 725
    -LiteralPath parameter 670                    CurrentFile property, ISE object model 623
Copyright element 367                             CurrentPowerShellTab property, ISE Object
Core cmdlet noun 664                                 model 623
core cmdlets 664–665, 673                         custom drives 665
Count property 131, 238                           custom hosts 546
$count variable 342, 379, 416                     custom menu items
    using with Get-Count and Reset-                  hotkey collisions 634
       Count 338–339                                 removing 636
    variables and aliases exported 345               updating 635
counter module 343, 382                           custom objects 393, 417–418
counter2 module 350, 353                          custom remoting endpoint 543
counting loop 205                                 custom services 527–552
countUp function 350                                 access controls and endpoints 533–535
Create() method 627, 776, 819, 828, 842              configurations 530–531
CreateElement() 695                                  constrained execution environments 543
CreateProcess() API 898, 922                         constraining sessions 535–543
credential dialog 621                                  controlling command visibility 536–539
credential information 452                             setting language mode 539–543
-Credential parameter 511                            remote service connection patterns 527–530
credentials                                            fan-in 528–530
    and scheduled tasks 789–792                        fan-out 527–528
                                                  CustomClass keywords 428–433
    forwarding in multihop environments 515–517
                                                  customizing ISE
    passing securely 516
                                                     setting font and font size 624
CredSSP (Credential Security Service
                                                     using object model 621
    Provider) 509, 515–517
CredSSP type 515
                                                  D
critical operations 566
Critical type 599                                 Danom virus 890–891
cryptography 889                                  data abstraction 428
CSV file 188                                      Data General 9


938                                                                                         INDEX
data structure, example of 122                   declaring types 73
data, processing 25–30                           decrement operator 155
   problem-solving pattern 29–30                 default assemblies 722
   selecting properties from objects 27–28       default clause 216
   sorting objects 25–27                         default file encoding 676
   with ForEach-Object cmdlet 28–29              default presentation, overriding 558
DateTime objects 11, 128, 585, 805               default prompts, in remote sessions 470
DayOfWeek property 406                           default remoting port (HTTP) 518
DCE/RPC (Distributed Computing Environment/      default remoting port (HTTPS) 518
   Remote Procedure Call) 802                    default session configuration, creating 534
DCOM protocol 802                                Default type 514
(DDL) dynamic link library 42, 721               default values, initializing function parameters
dead objects 803                                    with 246–247
Debug menu                                       default, security by 897–898
   Disable All Breakpoints item 649                 disabling remoting 897
   Display Call Stack 649                           managing command path 898
   Enable All Breakpoints item 649                  no execution of scripts 897–898
   List-Breakpoints item 649                        notepad 897
   Remove All Breakpoints item 649               DefaultParameterSetName property 293
   Run/Continue item 648                         Definition property 477, 540, 547
   Step Into item 648                            definitions
   Step Out item 648                                managing in session 267–269
   Step Over item 648                               of words, looking up using Internet
   Stop Debugger item 648                               Explorer 779–781
   Toggle Breakpoint item 649                    delegation
Debug mode 651                                      and delegates 850–853
debug mode prompt 649                                  non-GUI synchronous event
debug statements 259                                        example 851–853
debugger shortcut commands 651                   Delete() method 825
debugging 63                                     deleting
   command-line 652–660                             functions 399
      breakpoints 653–658                           variables 583
      debugger limitations and issues 658–660    -Delimiter parameter 678–679
   problems in function output 259–262           denial-of-service (DoS) attacks 892
   scripts 638–647                               -Depth parameter 713
      nested prompts and Suspend                 depth, default serialization 498
           operation 643–647                     Descendants() method 710
      Set-PSDebug cmdlet 638–643                 Description element 367
   v2 debugger 647–652                           Description property 388, 805
   with host APIs 580–593                        descriptors, security 534–535
      catching errors with strict mode 582–584   Deserialized Property 508
      Set-StrictMode cmdlet 584–589              design decision, contentious issues 125
      static analysis of scripts 589–593         desk.cpl command 598
[decimal] value 75                               Desktop Management Task Force 8
declaring parameters 241                         destructive conversion 102


INDEX                                                                                               939
DeviceID property 840                           DockPanel control 775
DHCPEnabled property 805                        documentation comments 315
diagnosing problems, using Eventlog 602         documentation package, PowerShell 14
diagnostics error 562                           documenting 314–321
diagnostics, tracing and logging 553               help
dialog boxes, WinForms 747–750                       automatically generated fields 315
DialogResult property 749                            comment-based 316–318
Dictionaries type, serialization in 507              creating manual content 315–316
Digest type 515                                    tags used in comments 318–321
digital signature 905                                .COMPONENT help 320
dir alias, Get-ChildItem 664                         .EXTERNALHELP help 320–321
dir command                                          .FORWARDHELPCATEGORY help 320
   comparison between two files 11                   .FORWARDHELPTARGETNAME
   new PowerShell console 14–15                           help 320
   -Path parameter 738                               .LINK help 320
   positional parameters 249                         .PARAMETER help 319
   using pipelines 158                               .REMOTEHELPRUNSPACE help tag 320
DirectoryInfo object 423, 427                   documents
Disable All Breakpoints debug menu item 649        analyzing word use in 683–684
Disable-PSBreakPoint cmdlet 653                    test 703–704
Disable-PSSessionConfiguration cmdlet 531       dollar sign 186
Disable-WSManCredSSP cmdlet 509                 domain controller 511
discarding error messages 568                   domain, extracting 137
discarding output 183                           domain-specific languages 428, 709
Disconnect-WSMan cmdlet 509                     DoS (denial-of-service) attack 892
Display Call Stack debug menu item 649          dot operator 173–177, 197
display settings, desk.cpl command 598          dot script 283
display, width of 65                            DotNetFrameworkVersion element 367–368
DisplayName event 875                           dot-sourcing 615
DisplayName property 626, 628                      scripts and functions 283–284
Distributed Computing Environment/Remote Pro-   [double] type 74
   cedure Call (DCE/RPC) 802                    double assignment, Fibonacci example 121
distributed object model 802                    double quotes 52, 437
division 74                                     double-clicking on script 897
division by zero error 561                      double-colon operator 177–178, 197
division operator 117–119                       double-quoted strings 78–79
DLL (dynamic link library) 42, 721              do-while loop 204–205
DLR (Dynamic Language Runtime) 729              DPAPI (Windows Data Protection API) 918
DMTF (Distributed Management Task               drives
   Force) 799                                      and providers 665
DNS (Domain Name Service) names, and IP            creating custom 665
   addresses 518                                   function: drive 672
Do It button 744                                   PowerShell drive abstraction 665
doc comments 315                                   variable: drive 672
Dock property, on winforms objects 746          DriveType property 840


940                                                                               INDEX
DSL (Domain-Specific Language) 686, 709            EjectPC() method 766
dynamic binary modules 445                         elastic syntax 46, 239
dynamic code generation 658                            aliases and 47–50
Dynamic Language Runtime (DLR) 729                     definition 48
dynamic languages 73, 400, 428                     Element() method 710
  debugging 643                                    elements, adding to XML objects 695–697
  security 895                                     elevated privileges, and remoting 468
Dynamic Link Libraries (DDL) 42, 721               elevation of privilege, defined 892
dynamic linking, pros and cons of 721              elseif clauses 201
dynamic modules 412–418                            elseif keyword 201–202
  and event handler state 862–863                  emits objects 257
  binary 443–446                                   empty arrays 94–96, 211
  closures 414–417                                 Enable All Breakpoints debug menu item 649
  creating custom objects from 417–418             Enable Strong Protection box, Certificate Export
  script 412–414                                       Wizard 914
dynamic parameters, and dynamicParam               Enabled timer property 728
  keyword 311–314                                  Enable-PSBreakPoint cmdlet 653
  steps for adding 312–314                         Enable-PSRemoting cmdlet 450, 452, 531
  when to use 314                                  Enable-PSSessionConfiguration cmdlet 531
dynamic scoping 272–273, 430                       Enable-PSTrace 334
  defined 269                                      Enable-WSManCredSSP cmdlet 509, 516
  implementation of 415                            enabling V1 strict mode 583
  passing arguments from enclosing scope 926       encapsulating data and code 400
  same name of variables 652                       encoded pipeline 505
dynamic typing 72, 586                             encoding
dynamically generating scriptblocks 642                command arguments 505
dynamicParam block 312                                 serialization 505
                                                       used in strings 77–78
E                                                  -Encoding parameter 311, 679
-ea parameter 567                                  -encoding parameter 184
Eclipse minicomputer 9                             encryption
edit.com program 45, 617                               in remoting 514
editor                                                 public key, and one-way hashing 904–905
   ISE 610–614                                     encryption key, security 918
      files 612–613                                end blocks, functions with 266–267
      syntax highlighting in ISE panes 614         end clause 267, 397
      tab expansion in editor pane 613–614         End() function 420
   running current pane contents 614–615           end-of-parameters parameter 41
editor buffer, ISE editor pane 631                 endpoints
editor keystrokes 16                                   access controls and 533–535
editor pane                                            registering configurations 532–533
   hiding in ISE 610                                   remoting configuration 532
   ISE (Integrated Scripting Environment) 18–20,       unregistering 533
       607                                             verifying existence 533
   making changes in 631–632                       end-processing clause 62


INDEX                                                                                            941
engine events                                    error buffer
   generating in functions and scripts 876–877      circular bounded buffer 560
   predefined 875–876                               controlling size 560
   registrations 875–877                            operations 561
EnterNestedPrompt() method 646                   error codes
enterprise, enabling remoting in 452–454            $LASTEXITCODE variable 565
Enter-PSSession cmdlet 450, 469, 518, 619, 621      use in PowerShell 554
Enter-PSSession command 34                       error messages 244, 568
EntryType filter 599                             error objects 182, 259, 564
EntryWritten event 879                           error processing subsystem 554
enum types                                       error record exception property 559
   defining new at runtime 442–443               error records 554
   serialization in 506                             as formatted text 556
enumerable collection array 114                     as strings 556
-Enumerate parameter 837                            displaying all properties 558
enumerating collection, update issues 635        error stream 259
enumerating, hash tables 87–88                   error subsystem, architecture of 554
enumeration types 683                            $error variable 559–564
                                                 $error.Clear() method 560
enumerations 814
                                                 -ErrorAction parameter 567–569
   filtering results 837–838
                                                 -ErrorActionpreference parameter 569
   singleton resources vs. 836–837
                                                 $ErrorActionPreference variable 567, 569, 571
EnumerationTimeoutms setting 525
                                                 ErrorDetails Property 557
enumerators 636
                                                 ERRORLEVEL variable 281
en-US bubdirectory 363
                                                 ErrorRecord 554, 572
$ENV: environment provider 376
                                                 errors 553–605
$ENV: MYAPPDIR variable 376                         capturing error objects 560
$ENV: PATH 329                                      capturing session output 593–596
$ENV: PROCESSOR_ARCHITECTURE 376                    catching 431
$ENV: PSModulePath directory 362, 368               debugging with host APIs 580–593
$ENV: PSModulePath variable 329                        catching errors with strict mode 582–584
$ENV drive 619                                         Set-StrictMode cmdlet 584–589
env namespace 186                                      static analysis of scripts 589–593
$ENV:HOMEPATH environment 494                       event log 597–605
$ENV:PATH environment variable 898                     EventLog cmdlets 597–602
$ENV:PATHEXT variable 898                              viewing 603–605
$ENV:PROCESSOR_ARCHITECTURE                         getting detailed information about 559
   variable 499                                     handling 554–569
$env:PSExecutionPolicyPreference                       $error variable and -ErrorVariable
   environment 903                                          parameter 560–564
environment variables 186, 197, 619                    controlling actions taken on errors 566–569
environmental forces, definition 6                     determining if commands had
-eq operator 124, 127                                       errors 564–566
$error[0] 562                                          error records and error stream 555–560
error action policy 566, 578                        object references 563
error action preference 566–567, 571                redirecting 181–182


942                                                                                        INDEX
errors (continued)                                       engine
   runtime behavior 566                                     event registrations 875–877
   that terminate execution 569–580                         generating events in functions and
      throw statement 578–580                                   scripts 876–877
      trap statement 570–575                                predefined 875–876
      try/catch/finally statement 575–578                forwarding, remoting and 877–882
   types of 554, 599                                     handling 848–849
-ErrorVariable parameter 560, 562–564                    Microsoft WMI 866–875
escape character 53, 669                                 Microsoft WMI intrinsic classes 871–874
Escape processing. See quoting                           queued, and Wait-Event cmdlet 863–866
escape sequence processing 54                            synchronous 849–853
evaluates 228                                               delegates and delegation 850–853
evaluation order, in foreach loop 209                       in GUIs 850
event log 597–605                                        workings of 882–887
   accessing from PowerShell 603                      Events member 751
   EventLog cmdlets 597–602                           EventSubscriber cmdlet 861
   viewing 603–605                                    $EventSubscriber variable 861
event log entries                                     EventWatcher1 879
   event categories in PowerShell log 603             exact matches 219
                                                      example code 22–35
   PowerShell state transitions 603
                                                         basic expressions and variables 23–25
   properties 604
                                                         flow control statements 30–31
   types 603
                                                         navigation and basic operations 22–23
event log tasks
                                                         processing data 25–30
   clearing and event log 597
                                                            problem-solving pattern 29–30
   creating new event log 597
                                                            selecting properties from objects 27–28
   listing available logs 598
                                                            sorting objects 25–27
   setting log size limits 597                              with ForEach-Object cmdlet 28–29
   writing new event log entry 597                       remoting and Universal Execution Model 32
$Event variable 861                                      scripts and functions 31–32
Event viewer, and Show-Event cmdlet 597               examplemodule.dll 356
$event.Entry.Message 880                              Exception property 558
$Event.SourceArgs 861                                 exceptions. See also errors
event-based script 849                                   accessing in trap block 572
EventHandler variables 745                               C# and VB.Net 554
EventIdentifier 865                                      catching all exceptions 570
eventing cmdlets 854–855                                 related to error records 572
EventLog cmdlets 597–602                                 rethrowing 571
EventLog events 879–882                                  terminating error 570
EventLog object 879                                      throwing 574
events 847–887                                        Exchange server 505
   asynchronous 853, 855                              executables 495–496
      .NET events 855–860                             executing code, at runtime 436
      event handling with scriptblocks 860–863        execution
      eventing cmdlets 854–855                           errors that terminate 569–580
      subscriptions, registrations, and actions 854         throw statement 578–580


INDEX                                                                                            943
execution (continued)                                     controlling export 343–346
      trap statement 570–575                        exports 334
      try/catch/finally statement 575–578              accessing using PSModule Info object 381–382
   of scripts, none by default 897–898                 calculated module 346–347
   policy, enabling scripts with 898–903               elements 337
execution context, and remoting 466                    of functions, controlling 343–344
execution environments, constrained 543                of variables and aliases, controlling 344–346
execution policy 910, 915                           Expression Blend 610
   and implicit remoting 473                        expression member, with Select-Object 411
   for scripts 276–278                              expression mode 54
execution stopped error 568                         expression oriented syntax, with try/catch
$ExecutionContext variable 437, 539                    statements 578
-ExecutionPolicy parameter 901                      expression-mode parsing 54–56
ExecutionTimeLimit property 789                     expression-oriented language 589
executive job 490                                   expressions 231
exit code 565                                          basic 23–25
exit command 34                                        operators in. See operators in expressions
   in remoting 470                                     using try/catch/finally statement in 578
   issued in constrained sessions 550               extended type system 64
exit scripts 280                                    extending
exit statement, exiting scripts and 280–281, 645       ISE 622–638
exit with code 0 565                                      $psISE variable 622–623
Exit() API 643                                            custom menus 633–638
exiting constrained sessions, with Exit-PSSession         Options property 624–625
   function 550                                           tabs and files 625–629
Exit-PSSession cmdlet 450                                 text panes 629–633
Exit-PSSession function 550                            objects 423
expandable strings 78                                  PowerShell language 428–436
ExpandString() method 437–438                             adding CustomClass keywords 428–433
Explicit Cast Operator type 107                           little languages 428
explore objects 423                                       type extension 433–436
Explore() method 766                                   runtime 445
Explorer, as a shell 6                              extensibility points, in ISE 622
Export-Clixml cmdlet 711, 714–718                   EXtensible Application Markup Language. See
Exported member term 326                               XAML
ExportedCommand property 353                        Extensible Stylesheet Language Transformations.
ExportedCommands 350, 381                              See XSLT language 710
ExportedFunctions member 332, 381                   External command lookups 548
exporting certificates 913                          external commands
Export-ModuleMember 413                                error handling 565
Export-ModuleMember cmdlet 325–326,                    in sessions 538
   343–347                                          external executables 44
   controlling module member visibility with        .EXTERNALHELP <XML HELP FILE PATH>
      calculated module exports 346–347                help tag 320


944                                                                                         INDEX
F                                             adding file checker menu item 637
                                              creating new 613
-f operator 103, 179–180, 197
                                              default association, notepad 897
F5 execute current text buffer 615
                                              loading and saving 697–701
F8 execute selected text 615
                                              opening 612–613
factorial function 262
                                              processing 672–681
FailFast() method 853, 880
                                              processing with switch statement 221–222
Failure Audit type 599
                                              saving list of open 632–633
$false variable 131, 184
fan-in remoting 528–530                       searching with Select-String cmdlet 688–693
fan-out remoting 527–528                         getting all matches in line 692–693
Fibonacci sequence 121                           -list and -quiet parameters 690–691
fidelity 497                                     trees of files 691
fields 66, 682                                   with context properties 692
file association 897                          specifying format and password 914
file encodings 675–676                    FileSystemWatcher object 864
file length 188                           FileVersionInfo property 33
File menu, ISE 620                        filter keyword 265, 267
file names, matching 132                  -Filter parameter 810–812
file not found error 562                  filtering
file operations 663                           enumeration results 837–838
    concatenating multiple files 675          where cmdlet 33
    display file contents 675             Filtering output, using Get-Member cmdlet 557
    formatting and output subsystem 686   filters 398
    reading 674                               and functions 265–266
    renaming 673                              filtering EventLog entries 599
    searching file hierarchy 691          finally keyword 575
    writing binary data 679               FindName() method 776
    writing pre-formatted data 679        findstr command 688
    writing to files 679                  firewall exception, for WinRM Service 453
-file option 222                          fl command 48
-File parameter 285                       flattened results 226
file paths 667, 669                       floating point 24
File property 352                         flow control 198, 234–235
file search tool                              adding new 428
    defining appearance 754–756               conditional statement 200–203
    specifying behavior 756–758               labeled loops and break and continue
file system                                       statements 212–215
    listing directories 664                   looping statements 203–212
    working with 22                              do-while loop 204–205
file system provider 187, 667                    for loop 205–207
FileInfo object 175                              foreach loop 207–212
FileList manifest element 375                    while loop 203–204
-FilePath option 461                          performance 233–235
-FilePath parameter 494                       statements as values 231–233
files 625–629                                 switch statement 215


INDEX                                                                                 945
flow control (continued)                           comparing with foreach statement 31
      processing files with 221–222                definition and example 30
      using $switch loop enumerator in 222         processing with 28–29
      using regular expressions with 217–221       recognized as command or statement 207
      using wildcard patterns with 216–217         using alias 702
   using cmdlets 223–231                           using return statement with 227
      ForEach-Object 223–228                    Foreach-Object cmdlet 169
      Where-Object 228–231                      foreground color
flushing changes 828–829                           setting in ISE 625
Folder object 789                               forensic tools 916
folder structure, of modules 362–363            formal arguments 246
foo imports 326                                 formal parameters, declaring for
foo variable 817                                   functions 241–257
for loop 30, 205–207                               adding type constraints to 243–245
-Force flag 359                                    handling mandatory 248
Force option 388                                   handling variable numbers of arguments 246
-Force parameter 341, 380, 513                     initializing with default values 246–247
   in process of remoting access 451               mixing named and positional 242–243
   overwriting existing definition 439             switch parameters 248–257
   removing jobs 487
                                                format operator 179–181
   using with SecureString cmdlets 919
                                                format specifier element 180
   viewing hidden files with 668
                                                format string 179
foreach block 877
                                                Format-Custom formatter 66
foreach cmdlet 526
                                                Format-List cmdlet 332, 341, 350
foreach keyword 207, 225
                                                   using to display Registry 671
foreach loop 207–212, 875
                                                   using to see error record 558
   and $null value 211–212
   debugging 639                                   using to see log 600
   defined 30                                      using with Get-WSManInstance 832
   displaying hash tables 88                    Format-List command 64–65
   evaluation order in 209                      formats, specifying for files 914
   removing items from collection 635           FormatsToProcess element 370, 373
   using $foreach loop enumerator in 209–211    FormatsToProcess manifest element 373
   using range operator 167                     Format-Table cmdlet 411
$foreach loop enumerator, using in foreach      Format-Table command 34, 64
   loop 209–211                                 formatting output 179, 686
foreach statement 30, 87, 205, 207, 209, 234,      in interactive remoting 471
   635–636                                         in non-interactive remoting 472
$foreach variable 209, 263, 701                 formatting strings 179
$foreach.MoveNext() method 210                  Format-Wide cmdlet 66
ForEach-Object cmdlet 223–228, 393–394, 398,    Format-XmlDocument function 837
   684, 849                                     -Forward parameter 877
   argument processing by 227–228               .FORWARDHELPCATEGORY <CATEGORY>
   as anonymous filter 265                         help tag 320
   comparing order of execution with foreach    .FORWARDHELPTARGETNAME <COM-
       loop 209                                    MAND-NAME> help tag 320


946                                                                                   INDEX
forwarding events, remoting and 877–882               return statement 262–263
fragments, of script code 569                       using in pipeline 263–267
frameworks, for WPF 758–759                           filters and functions 265–266
freespace 29                                          functions with begin, process, and end
FullName property 425, 724                                 blocks 266–267
full-screen applications 616                        variable scoping in 269–274
full-screen editor 617                                declaring variables 270–272
fully qualified path 666                              modifiers 272–274
FullyQualifiedErrorId property 558                  VBScript 784
function body 238                                function-scoped variable 282
function calls, tracing 639                      FunctionsToExport element 370
function definition, changing 399
function definitions 268, 546                    G
function drive 268, 274, 398, 439–440            GAC. See global assembly cache
function keyword 44, 316, 397, 399               gateway server 515
-Function parameter 334                          General Impression, Size, and Shape (GISS) 37
function provider 399, 547                       generating elements 209
function visibility, constrained sessions 537    generating script 279
function: drive 399, 672                         generic types 98–99, 739–740
FunctionInfo object 399                          Get command 841
functions 31–32, 43, 236–274                     GET() method 825
    body of 32                                   Get/Update/Set pattern 253–257
    called like methods 586–587                  GetAssemblies() method 725
    calling 242                                  Get-AuthenticodeSignature cmdlet, security 911
    declaring formal parameters for 241–257      Get-Bios command 477
      adding type constraints to 243–245         Get-Bios function 476
      handling mandatory 248                     Get-BrowserWindow function 770, 772–773
      handling variable numbers of               Get-Character function 253, 255
            arguments 245–246                    Get-ChildItem cmdlet 395, 402, 664, 691
      initializing with default values 246–247   Get-ChildItem command 47
      mixing named and positional 242–243        Get-Command 332, 339, 342, 353, 384, 545
      switch parameters 248–257                  Get-CommandString function 758
    defining at runtime 398–400                  GetConsoleWindow() method 734
    definition 397                               Get-Content cmdlet 221, 673–678
    dot-sourcing scripts and 283–284                performance caveats 680–681
    fundamentals of 237–240                         -ReadCount parameter, and Where-Object
      $args variable 237–240                           cmdlet 229–231
      ql and qs functions 239–240                   reading files 697
    generating events in 876–877                    sending data to pipeline 122
    initializing parameters 580                     sending data to variables 143
    managing definitions in session 267–269         using with binary files 188
    parameterizing 237                           Get-Content command 47
    returning values from 257–263                Get-Count 338–339, 342–343, 345
      debugging problems in function             Get-Count function 379–380, 383–384
            output 259–262                       Get-Credential cmdlet 475, 917, 919


INDEX                                                                                          947
Get-Date cmdlet 81, 182, 247, 395, 593           Get-PSProvider cmdlet 664
Get-Date command 11, 395                         Get-PSSession cmdlet 472
GetEnumerator() method 87, 720                   Get-PSSession command 472
Get-Event cmdlet 854                             Get-PSSessionConfiguration cmdlet 531
Get-EventLog cmdlet 597–598, 601, 603            Get-Service cmdlet 711
  filtering entries 602                          Get-Spelling.ps1 script 781
  -InstanceID parameter 602                      GetTempFileName() method 881
  -Message parameter 602                         getter method 407
  -Source parameter 602                          GetType() method 73, 123, 142
Get-EventSubscriber cmdlet 854, 856, 859         GetTypes() method 726
GetExportedTypes() method 725                    Get-Variable cmdlet 651
Get-HealthModel command 544                      Get-Variable function 379
Get-Help cmdlet 701                              Get-WmiObject cmdlet 804–813
Get-Help command 22, 325                            -Filter parameter 810–812
Get-Help Online about_execution_policies 31         Microsoft WMI objects
Get-HexDump function example 676–677                   selecting instances using filters and
Get-Item cmdlet 512, 564, 567                               queries 810
Get-Item command, retrieving RootSDDL 534              selecting using -Query parameter 812–813
Get-ItemProperty cmdlet 672                         navigating CIM namespaces 807–810
Get-Job cmdlet 483–485, 882                         using to find Microsoft WMI classes 806–807
GetLength() function 784                         Get-WmiObject command 29
Get-Location cmdlet 665, 673                     Get-WordDefinition function 779
Get-MagicNumber function example 677–679         Get-WSManCredSSP cmdlet 509
Get-MailboxStatistics command 29                 Get-WSManInstance cmdlet
Get-Member cmdlet 175, 557, 623, 653, 765, 857      retrieving management data with 832–839
  examining objects 400                                filtering enumeration results 837–838
  getting information of object using 13               getting Win32_OperatingSystem
  static members 401                                        resource 834–836
GetMembers() method, listing object                    selecting instances 838–839
  members 119                                          singleton resources vs.
Get-Module cmdlet 333, 359                                  enumerations 836–837
  description of 325                                   targeting WS-Man resources using URIs 834
  finding modules 327–329                        gigabytes 83
  getting information about loaded module 331,   GISS (General Impression, Size, and Shape) 37
      350–351                                    $global 387
GetNetworkCredential() method 790                global assembly cache 722
GetNewClosure() method 415                       global context 186
Get-OkCancel() function 747                      global environment, importing nested modules into
Get-PageFaultRate command 531                       with -Global flag 352–353
Get-PfxCertificate cmdlet 915                    -Global flag, importing nested modules into global
Get-Process command 29, 40                          environment with 352–353
Get-ProgID function 763                          global functions 430–431
Get-PSBreakPoint cmdlet 653                      global level 335
Get-PSCallStack cmdlet 653                       global modifier 273
Get-PSDrive command 457                          -Global parameter 353


948                                                                                        INDEX
global scope 436                                    remote EventLog events, example 879–882
$global:name scope modifier 281                 hanging applications, in ISE 616
globalization support, in ISE 607               has-a relationship 13
goto statement 212                              hash algorithm, MD5 889
grammar 38                                      hash table argument 244
graphical debugger 648–652                      hashing
   executing other commands in debug mode 651       one-way, public key encryption and 904–905
   hovering over variables to see values 652    hashtable operators 112
graphical environment 622                       hashtables 85–91
graphical programming 445                           as reference types 90–91
Graphical User Interfaces. See GUIs 743             counting unique words with 684–686
green play button 18                                empty 429
grep command 688                                    enumerating 87–88
GROUP clause 874                                    extending 435
GROUP keyword, aggregating events                   modifying 88–89
   with 874–875                                     sorting 87–88
Group Policy, enable remoting using 452             use with Select-Object 411
GUI builder tools 752                           health model function 544
GUI debugger 653                                Hello world program 3
-Gui flag 774                                   help
-Gui option 773                                     automatically generated fields 315
-Gui parameter 773                                  comment-based 316–318
GUID (globally unique ID) 762                       creating manual content 315–316
   serialization in 506                             tags
   used as Job Instance ID 484                        .COMPONENT help 320
GUIs (graphical user interfaces) 4, 743–759           .EXTERNALHELP help 320
   creating winforms modules 750–753                  .FORWARDHELPCATEGORY help 320
   defining in XAML 774–775                           .FORWARDHELPTARGETNAME
   synchronous events in 850                               help 320
   WinForms library 744–750                           .LINK help 320
     simple dialog boxes 747–750                      .PARAMETER help 319
   WPF 753–759                                        .REMOTEHELPRUNSPACE help 320
     advantages of 758                          help files, operating on 683
     file search tool 754                       help subsystem, PowerShell 23
     frameworks for 758–759                     help topics, about_Assignment_operators 685
     preconditions 753                          help viewer 611
                                                helper function 430
H
                                                HelpMessage property 302–303
Handle property 839                             here-strings 77, 80–82, 279, 638
handlers, event                                     loading XAML from 776–777
   state 862–863                                hex digits 114
   timer 856–859                                hexadecimals 84–85, 180
handles 226, 395                                hi function 470
handling                                        hi member 425
   events 848–849, 860–863                      hiding editor pane


INDEX                                                                                      949
   Ctrl-R 611                                        IIS (Internet Information Services) 529
   in ISE 610                                        IList interface 507
highlighting syntax, in ISE panes 614                IList type 108
History tab 792                                      -Impersonation parameter 803
HitCount property, on breakpoints 654                implementation decision, concatenation
hklm: registry drive 671                                hashtables 115
home directories, of providers 667                   implicit behavior, overriding 127
Home directory 667                                   Implicit Cast Operator type 106
$HOME variable 494                                   implicit remoting 473–481, 535
host APIs, debugging with 580–593, 595                  and execution policy 473
   catching errors with strict mode 582–584             connection sequence 474
   Set-StrictMode cmdlet 584–589                        generating temporary modules 480
   static analysis of scripts 589–593                   in constrained sessions 545
host application interfaces 643                         in InitialSessionState 546
host application, PowerShell 14                         local proxy functions 473
$host member 581                                        message flow 476
host programs 466                                    Import-Clixml cmdlet 633, 714–718
$host variable 467, 580, 646                         Imported member term 326
host version 581                                     importing SecureString 918
hosting fan-in remoting, IIS (Internet Information   Import-Module cmdlet 331, 353–354, 358, 414
   Services) 529                                        and nested modules 350
$hostName parameter 308                                 description of 325
hotkey sequences                                        loading modules 331, 356
   defining in ISE 634                                  module loading another 326
   ISE pane positions 610                               using -ArgumentList parameter 358
hovering over variables 652                             using -Global flag 352
Howard, Michael 892                                  Import-Module function 368, 372, 380
HTML tags 741                                        Import-PSSession cmdlet 474, 551
HTTP (Hypertext Transport Protocol) 504              Import-PSSession, with constrained sessions 546
HTTPS (Hypertext Transfer Protocol Secure) 512       imports 334
HTTPS (Secure HTTP) 504                              increment operator 80, 155, 204
hygienic dynamic scoping 269                         $increment variable 338, 345, 379, 384, 416
                                                     indenting text, in editor pane 612
I                                                    index operation 396
                                                     indexing 167–170
I/O redirection 68, 183                                 of arrays 92
IComparable interface 127                               with variables 173
-IdleTimeout parameter 526                           indirect method invocation 178–179
IE (Internet Explorer) 668                           indirect property name retrievals 176
IEEE Specification 1003.2, POSIX Shell 9             information disclosure attack 896
IEnumerable interface 210, 720                       Information type 599
-ieq operator 125                                    infrastructure script 461
IETF (Internet Engineering Taskforce) 504            inheritance hierarchy 424
if statement 200, 358, 376, 774                      inheritances 433
IgnoreCase option 146                                Initialize-ComplexConstrained-
-IgnoreWarnings parameter 731                           HMConfiguration.ps1 548


950                                                                                           INDEX
Initialize-ConstrainedHMConfiguration.ps1 543        opening multiple files 18
initializer expressions 247–248, 580                 output window 17
initializing multiple variables 123                  syntax highlighting 18
injection code 896–897                               three parts of 17
inline documentation 60                              three parts of the 17
in-memory buffering 187                              using F1 key 23
in-memory sessions, local 619                        Visual Studio comparison 20
inner loops 214                                   interactive command interpreter, security 897
InnerException property 559                       interactive environment 226
InnerText() method 695                            interactive errors 562
in-process execution 619                          interactive InitialSessionState 546
input redirection 182                             interactive mode 643
input validation 895–896                          interactive operation, constrained sessions 545
$input variable 263, 265, 455                     interactive remoting 619
input, processing 264                                with custom configuration 549
$input.current.$p expression 264                  interactive sessions 450, 469–472, 621
-InputObject parameter 39, 51                        multiple concurrent sessions 471
InputObject parameter 813                         interactive token, creating from credentials 515
installation directory path 434                   intercepting expressions 124
installutil.exe program 354                       interfaces, defined 12
instance members 177, 819                         interleave user commands 607
_InstanceCreationEvent class 871                  internal command lookups 548
InstanceDeletionEvent class 871                   internal commands 541
InstanceID filter 599                             Internet Explorer, looking up word definitions
-InstanceID parameter, on Get-Eventlog 602           using 779–781
InstanceID property 600                           Internet Information Services 529
InstanceModificationEvent class 872               Internet, .NET framework and 740–743
InstanceOperationEvent class 872                     processing RSS feeds 742–743
instances                                            retrieving web pages 740–742
    creating 429, 432                             InternetExplorer.Application.1 ProgID. 763
    extending 401, 434                            Interop assemblies, COM and 761–796
    setting properties of 816–819                 Interop library 762
    using Microsoft WMI paths to target 814–816   interpreter 199, 439, 639
instantiating objects 727                         interpreter reentrancy 643
integer 74, 127                                   Interval property 857
integrated debugger, ISE 648                      Interval timer property 728
Integrated Scripting Environment 14               intervening characters 136
    automating 20                                 invalid file name, security 896
    command entry window 17                       invocation intrinsics 445
    Ctrl-C behavior 17                            InvocationInfo property 558–559
    Ctrl-C in 17                                  Invoke method 178
    editor window 17                              Invoke() method 382–383, 627, 852
    F8 key in 18                                  Invoke-Command cmdlet 32, 449, 518, 881–882
    help within 23                                   child jobs with 490–492
    is scriptable 20                                 description of 450
    multiple session tabs 18                         syntax for 449


INDEX                                                                                         951
Invoke-Expression cmdlet 104, 142, 377,               View Menu 610
    436–437, 643, 924                             ISE menu item 634
    avoiding 923–927                              ISE object model
    security 895                                      adding new session tab 631
Invoke-Gui piece 774                                  hierarchy of 623
InvokeScript() method 437–438                         reloading saved tabs 633
invoke-WmiMethod cmdlet 819–822                       saving list of open 632
Invoke-WSManAction cmdlet, invoking methods           setting editor buffer contents 632
    with 841–846                                  ISE panes 608
invoking commands, indirectly 395                 -isnot operator 152, 154
invoking script blocks 393                        ISO/IEC recommendations 84
IP (Internet Protocol) addresses, DNS names       isolated execution environment. See AppDomain
    and 518                                       isolation, between sessions 619
IP address 518                                    IT industry 8
IPAddress property 805                            Item() property 768
ipconfig command 898                              ItemNotFoundException 558
-is operator 152–154, 404                         iterating value 211
IsChecked property 757                            iteration 215
ISE (Integrated Scripting Environment) 17–20,
    260, 606–660                                  J
    controlling pane layout 607–610
      command pane 608–609                        jagged arrays 171, 197
      ISE toolbar 609–610                         JavaScript 401, 783
    editor 610–614                                $jb variable 486
      files 612–613                               job objects 486, 859
      syntax highlighting in ISE panes 614        jobs
      tab expansion in editor pane 613–614            background 481–493
    editor pane 18–20                                   cmdlets 483–487
    executing commands in 614–616                       commands 483
      running current editor pane                       multiple 487–489
           contents 614–615                             running in existing sessions 492–493
      selected text 615–616                             starting on remote computers 489–492
    extending 622–638                                 child
      $psISE variable 622–623                           and nesting 489–490
      custom menus 633–638                              with Invoke-Command cmdlet 490–492
      Options property 624–625                        removing jobs 487
      tabs and files 625–629                          waiting to complete 486
      text panes 629–633                          join 177
    key bindings 610                              join method 177
    running scripts in 616–618                    -join operator 139–143, 406
      issues with native commands 616–617         Join() methods 683
      threading differences between console and   joining strings 177
           ISE 618                                Join-Path cmdlet 376
    using multiple tabs 618–622                   JScript code, embedding in script 785–786
      local in-memory session 619                 JScript language 785
      remote session 619–622                      jumping 214


952                                                                                      INDEX
K                                                    Leibniz, Gottfried Wilhelm 5
                                                     length of file object 221
Kerberos 514
                                                     length property 164, 170, 173
Kerberos type 515
                                                     level of abstraction 8
key codes, reading from PowerShell 581
                                                     levels of indirection 175
key-binding, ISE 610
                                                     lexical analyzer 50
keyboard shortcuts, in debugger 648
                                                     lexical element 81
keys
                                                     lexical scoping 269
   in Registry 671
                                                     lexical, ambiguity with type literals 178
   private protection, enabling strong 913–915
                                                     lfunc function 281
   public encryption, and one-way
                                                     libraries
      hashing 904–905
                                                         of functions 283
keys property 86
                                                         simple 283, 747–750
key-value pairs 85
                                                         WinForms 744–750
keywords 199, 430, 433, 589
                                                     lightweight data record 86
Kidder, Tracey 9
                                                     -like operator 132–133, 215, 217
kilobytes 83
                                                     Limit-EventLog cmdlet 598
Kleene, Stephen Cole 394
                                                     lines, getting all matches in 692–693
Korn shell 9, 38
                                                     .LINK help tag 320
                                                     linking, pros and cons of dynamic 721
L
                                                     list comprehensions feature 159
labeled loops, and break and continue                list of functions, function drive 398
    statements 212–215                               -List parameter 690–691, 804
lambda calculus 394                                  List type, serialization in 507
lambda expressions 394                               $list variable 194
language development 9–11                            -ListAvailable parameter 328
language elements 428                                List-Breakpoints debug menu item 649
language mode                                        LiteralPath parameter 670–671
    sequence of operations 544                       literals 96–101
    setting 539–543                                      accessing static members with 99–101
language restrictions, in module manifests 376–377       generic types 98–99
LanguageMode property 539, 541                           script block 397–398
last mile problem 8                                      type aliases 96–98
$LAST variable 421–422                               little languages 428
$last variable 421                                   live objects 508, 803
$LASTEXITCODE variable 564–565                       live shell session 613
LastWriteTime property 11                            load order, of module components 374–375
lawn gnome mitigation, avoiding 893–894              Load() method 724
layout settings, ISE panes 610                       loader manifest elements, module
leading zeros, numeric comparison 126                    manifests 371–373
LeBlanc, David 892                                       ModuleToProcess manifest element 371–372
left aligned 180                                         NestedModules manifest element 372
left operand 118                                         RequiredAssemblies manifest element 372
left-hand rule operators 113                             ScriptsToProcess manifest element 372–373
legacy commands 44                                       TypesToProcess and FormatsToProcess mani-
legitimately signed scripts 913                              fest elements 373


INDEX                                                                                          953
loading                                               format 316
   by module name 331–333                           management model, Windows 35
   files 697–701                                    management objects 7, 797–846
   removing loaded modules 335–337                    Microsoft WMI 798–801
   tracing with -Verbose flag 333–334                    cmdlets 801–824
LoadWithPartialName() method 723                         infrastructure 799–801
local certificate authority, role in remoting 512        object adapter 824–830
local certificate store, defined 905                     putting modified objects back 828–830
local in-memory sessions 619                          WS-Man 830–846
local output, remote output vs. 497–498             management, of types 72–77
local proxy functions 473                           managing error records 560
Local Security Policy MMC snap in 521               managing resource consumption, with quotas 523
local session 619                                   mandatory arguments 223, 248
Local User Administration dialog 920                mandatory parameters
LocalAccountTokenFilterPolicy 517, 521                handling 248
Location property 354                                 in functions using throw statement 580
LocationName property 772                           Mandatory property 248, 297
logical complement 229                              manifests 721
logical disk object 830                             manipulate script blocks 400
logical operators 148–150                           manipulating code 400
logical type containment 720                        manual documentation, in help files 315–316
lookup word definition 779                          .map() operator 209
loop 80, 639                                        Margin property 756
loop counter 206–207                                mash-ups, composite management
loop keyword 428                                      applications 324–325
loop processing 220                                 Match class, System.Text.Success property 688
loop statement 233                                  match group 135
looping construct, adding new 428                   Match object, Value property 688
looping statements 203–212                          -match operator 134–137, 215, 218, 687, 772
   do-while loop 204–205                              matching using named captures 135–136
   for loop 205–207                                   parsing command output using regular
   foreach loop 207–212                                   expressions 136–137
      and $null value 211–212                       Match() method 687
      evaluation order in 209                       matched value 216
      using $foreach loop enumerator in 209–211     $matches variable 134, 218
   while loop 203–204                               matches, getting all in line 692–693
                                                    MatchEvaluator class 851–852
M
                                                    MatchEvaluator method 852
machines, monitoring                                MatchInfo class 692
  multiple machines 458                             MatchInfo object 691
  single machine 457–458                            matching process 216
magic number, determining binary file types 677     matching quote 52
MakeCert.exe program 906                            math operations, advanced 727
malware, defined 890                                MaxEnvelopeSizeKB setting 523
MAML (Microsoft Assistance Markup Language)         maximum integer value 578


954                                                                                        INDEX
$MaximumErrorCount variable 560                        closures 414–417
MaximumReceivedDataSizePerCommandMB                    creating custom objects from 417–418
  parameter 523                                        script 412–414
MaximumReceivedObjectSizeMB parameter 523           extending PowerShell language 428–436
$MaximumVariableCount variable 523                     adding CustomClass keywords 428–433
MaxPacketRetrievalTimeSeconds setting 525              little languages 428
MaxProviderRequests setting 523                        type extension 433–436
MaxShellsPerUser controls 511                       objects 400–410
MaxTimeoutms setting 524                               adding note properties with New-Object
MD5 hash algorithm 889                                      cmdlet 409–410
Measure-Command cmdlet 465                             public members 400–402
Measure-Object cmdlet 710                              using Add-Member cmdlet to
megabytes 83                                                extend 402–408
member collection 425                               script blocks 393–400
member types 400                                       defining functions at runtime 398–400
member types, Add-Member cmdlet 403                    invoking commands 394–396
-MemberDefinition property, On Add-Type                literals 397–398
  cmdlet 730                                        Select-Object cmdlet 410–412
members, creating Singleton definitions 730–734     steppable pipelines 418–423
memory consumption 560                                 creating proxy command with 420–423
menus, custom 633–638                               type system 423–428
  adding file checker item 637                         adding properties to 425–427
  submenu for Snippets 637–638                         shadowing existing properties 427–428
merging streams 183                               method call arguments 176
Message filter 599                                method invocations 176, 178–179
-Message parameter 602                            method operators 173–179
-MessageData parameter 855, 863                     dot 174–177
MessageData property 863                            indirect method invocation 178–179
metadata. See also module manifests 288, 391        static methods and double-colon
metaprogramming 392–446                                 operator 177–178
  building script code at runtime 436–440         methods
    $ExecutionContext variable 437                  defined 11
    creating elements in function drive 439–440     functions called like 586–587
    ExpandString() method 437–438                   invoking with Invoke-WSManAction
    Invoke-Expression cmdlet 436–437                    cmdlet 841–846
    InvokeScript() method 438                       static, calling 819–822
    script blocks 438–439                         Methods type 403
  compiling code with Add-Type                    Microsoft Assistance Markup Language (MAML)
     cmdlet 440–446                                 format 316
    defining new .NET class with C#               Microsoft Baseline Configuration Analyzer 462
         language 440–442                         Microsoft Communications Protocol Program 505
    defining new enum types at                    Microsoft Developers Network. See MSDN 424
         runtime 442–443                          Microsoft Exchange 29
    dynamic binary modules 443–446                Microsoft Management Console. See MMC
  dynamic modules 412–418                         Microsoft security response 890


INDEX                                                                                      955
Microsoft study on improving offerings 7               avoiding lawn gnome mitigation 893–894
Microsoft Update 14                                    blacklisting/whitelisting 894
Microsoft Windows                                      code injection 896–897
   automating with COM (Component Object               input validation 895–896
       Model) 764–777                             mkdir command 67
     browser windows 767–777                      MkDir function 673
     Shell.Application class 765–766              mkdir function 268
   connection issues 520–522                      MMC (Microsoft Management Console) 32, 521,
   Task Scheduler 786–793                           597, 908, 922
     Schedule.Service class 786–787               modeling
     tasks 787–793                                  security 891–897
   Vista, connection issues 521–522                    threat modeling 891–892
   XP with SP3, connection issues 520–521              threats, assets, and mitigations 893–897
Microsoft WMI (Windows Management                 models, defined 891
   Instrumentation) 8, 75, 522, 797, 866–875      Model-View-Controller (MVC) pattern 187
   cmdlets 801–824                                modernized languages 418
     common parameters 802–803                    modifiers 272–274, 428
     Get-WmiObject 804–813                        modifying hashtables 88–89
     invoke-WmiMethod 819–822                     module boundary 541
                                                  module exports 535
     remove-WmiObject 822–824
                                                  module identity 368
     Set-WmiInstance 813–819
                                                  Module manifest term 326
   documentation 807
                                                  module manifests 361–391
   event registrations
                                                    construction elements 370–375
     class-based 867–870
                                                       loader manifest elements 371–373
     query-based 871–875
                                                       module component load order 374–375
   example of 29–30
                                                    content elements 375–376
   infrastructure 799–801                           controlling when modules can be
   methods 824                                          unloaded 388–389
   namespace hierarchy 814                          defining module vs. calling module 384–387
   object adapter 824–830                              accessing calling module 385–386
   putting modified objects back 828–830               accessing defining module 385–386
   samples and resources, adapting 830              language restrictions in 376–377
   type accelerator 828                             module folder structure 362–363
Microsoft Word, spell checking using 781–783        production elements 366–370
Microsoft.PowerShell endpoint 533                      module identity 368–370
Microsoft.PowerShell, session configuration 524        runtime dependencies 368–370
$mInfo variable 388                                 PSModuleInfo object 378–382
minicomputer, Eclipse 9                                accessing module exports using 381–382
minute property 412                                    invocation in module context 378–381
mitigation                                             methods 382–384
   defined 893                                      running an action when module is
   serialization 505                                    removed 389–391
   threats, assets, and 893–897                     setting module properties from inside script
     authentication, authorization, and                 module 388
          roles 894–895                             structure of 363–366


956                                                                                      INDEX
Module member term 326                                    nested modules 350–353
Module property 351, 383                                  review of scripts 338–340
module scope 349                                          scopes in script modules 348–350
Module type term 326                                      turning into module 340–343
ModuleList element 375                               ModuleToProcess element 370–372, 374
ModuleName property 351–352                          ModuleVersion element 367–368
module-qualified command name 548                    modulus operator 117–119
modules 7, 322–360                                   Monad project 5
  accessing exports using PSModule Info              Monadology, The (Leibniz) 5
      object 381–382                                 monitor size, and ISE 609
  basics of 325–327                                  monitoring, using remoting 457
     single-instance objects 326–327                 Move-Item cmdlet 673
     terminology 326                                 MoveNext() method 210, 223, 264
  binary 353                                         MoveToNextAttribute() method 701
     creating 355–357                                MSDN (Microsoft Developers Network) 68, 424
     nesting in script modules 357–360                 blogs home page 741
     vs. snap-in modules 354–355                       documentation 762
  browser window management 770–777                  MSH/Cibyz worm 891
     adding graphical front end 773–774              [MS-PSRP] remoting protocol 504
     defining control actions 775–776                MSRPC (Microsoft Remote Procedure Call) 802
     XAML 774–777                                    MS-WSMV (Web Services Management Protocol
  component load order 374–375                         Extensions for Windows Vista) 504
  controlling unloading of 388–389                   MTA (multithreaded apartment) 618, 793
  dynamic                                            multicore processors 618
     and event handler state 862–863                 multidimensional arrays 171–173, 197
     closures 414–417                                multihop environments, forwarding credentials
     creating custom objects from 417–418              in 515–517
     script 412–414                                  multiline comments 59–60
  dynamic binary 443–446                             multiline option 147–148
  finding on system 327–330                          multimachine monitoring 457–462
     imports and exports 334                           multiple machines 458
     loading module 331–334                            parameterizing solution 459–462
     module search algorithm 329–330                   resource management using throttling 458–459
  identity 368–370                                     single machine 457–458
  invocation of PSModuleInfo object in context       multiple assignment 187, 240
      of 378–381                                     multiple jobs
  removing loaded 335–337                              application of 488
  role of 323–325                                      performance considerations 489
  running actions when removed 389–391               multiple machines 622
  setting properties from inside script module 388   multiplication operator 116–117
  winforms 750–753                                   multiplier suffixes, for numeric types 83–84
  writing script 337–353                             multiplying numbers 113, 116
     controlling member visibility with Export-      multiscope catch 579
          ModuleMember cmdlet 343–347                multiscope trap 579
     installing module 347                           multivalued arguments 243


INDEX                                                                                          957
MVC (Model-View-Controller) pattern 187             NestedModules element 370, 372
$MyInvocation.MyCommand.Module 385                  nested-prompt level 646
                                                    $NestedPromptLevel variable 645
N                                                   nested-shell level 647
                                                    nesting, child jobs and 489–490
nadd function 244
                                                    .NET assembly, loading 781
name member, with Select-Object 411
                                                    .NET class
name of host, obtaining 581
Name property 175, 425, 491, 756, 815                  defining new with C# language 440–442
named captures, matching using 135–136              .NET events 855–860
named parameters 242–243                               managing subscriptions 859–860
names, of variables                                    writing timer event handler 856–859
   syntax for 186–188                                    creating timer object 856
   vs. variable values 192–193                           enabling 858–859
NAMESPACE class 808                                      setting parameters 857
namespace collisions 535                            .NET exceptions 579
-Namespace parameter 730, 807                       .NET framework 719–759
namespace providers 800                                and Internet 740–743
namespace qualifiers 272                                 processing RSS feeds 742–743
namespace, notation variables 186                        retrieving web pages 740–742
namespaces 665, 720                                    assemblies 721–725
name-value pair 193                                      default 722
native commands 44–46, 565                               loading 722–725
   issues with 616–617                                   pros and cons of dynamic linking 721
   Windows 39                                            versioning and 721–722
navigation 22–23                                       basics 720–721
-ne operator 124                                       GUIs 743–759
negative indexing 170                                    creating winforms modules 750–753
Negotiate type 515                                       WinForms library 744–750
nest prompt characters 56                                WPF 753–759
nested data structures 197                             types
nested function 387                                      creating instances of 727–729
nested interactive session 644                           defining new with Add-Type
nested loops 214                                              cmdlet 729–739
Nested module term 326, 350                              finding 725–727
nested modules 350–353                                   generic 739–740
   binary in script 357–360                         .NET interop wrapper 794
   importing into global environment with -Global   .NET libraries. See Assemblies
       flag 352–353                                 .NET object model
nested pipelines 643                                   leveraging 10–11
nested prompts, and Suspend operation 643–647          self-describing 10
   breakpoint command 646–647                       .NET/COM Interop library 761
   suspending script while in step mode 644–645     .NET-based custom type conversion 104–107
nested session 646                                  netbooks 610
nested shell operation sequence 643                 network programming 740
nested statement 235                                network tokens 515


958                                                                                      INDEX
new interactive session 646                            setting 408
new language features 433                           Notepad function 666
New Remote PowerShell Tab 620                       notepad, default file association 897
new tasks, XML representation of 791                Notepad.exe command 666
NewBoundScriptBlock() method 382–384, 416           NoteProperty members, adding to
NewBoundScriptBlockScriptblock() method 862            objects 405–406
New-Control function 751                            NoteProperty PSPath property 425
New-Event cmdlet 854                                -NoTypeInformation parameter 713
New-EventLog cmdlet 597                             nouns 428
new_instance function 430–431                       NTLM authentication 518
New-Item cmdlet 439, 672–673                        $null variable 583, 684–685
newline character 56–57, 678                           casting string to int 153
New-Module cmdlet 325, 413–414                         reference to uninitialized variable 184
New-ModuleManifest cmdlet 325, 363, 366                using in integer expressions 570
-NewName parameter 108                              numbers, conversion to string 25
New-Object cmdlet 172, 425, 761                     numeric calculations 73
   adding note properties to objects with 409–410   numeric comparison 126
   examples of 729                                  numeric context 129
   limitations of 728                               numeric conversion rules 127
   -Property parameter 727–728                      numeric expressions, and $null 583
New-PSSession cmdlet 450, 465, 468–469, 518,        numeric types 82–85
   879                                                 hexadecimals 84–85
New-PSSessionOption cmdlet 519, 523, 526               multiplier suffixes for 83–84
NewScriptBlock() method 437–438                        specifying 83
NewTask() method 788                                $numProcesses parameter 460
New-WSManSessionOption cmdlet 509
NextMatch() method 688                              O
No to All 642                                       [object] type 354
-noclobber parameter 184                            object adapter
NoLanguage mode 550                                    Microsoft WMI 824–830
non-filesystem providers 672                             type accelerators 825–828
noninteractive remoting 450                         object model
non-numeric string 114                                 .Net 10
nonprintable characters 676                            customizing ISE 621
nonstructured exit 212                              object normalization 402
non-terminating errors 554, 566, 569                object streaming model 554
non-zero value 566                                  Object tab 713
non-zero-length strings 253                         ObjectNotFound category 559
-NoProfile option 494                               object-oriented languages 245, 401
normal flow of control 849                          objects 128, 400
-notcontains operator 130                              adding note properties with New-Object
note member 433                                           cmdlet 409–410
note properties                                        creating custom from modules 417–418
   adding to objects with New-Object                   defined 11
      cmdlet 409–410                                   managing windows through 7–8


INDEX                                                                                            959
objects (continued)                                 array 162–173
   public members 400–402                              comma operator 162–165
   rendering as XML 711–718                            indexing and slicing 167–170
     ConvertTo-Xml cmdlet 711–714                      multidimensional 171–173
     Import-Clixml and Export-Clixml                   range operator 165–167, 170–171
          cmdlets 714–718                           for working with types 152–154
   representing in protocol stack 505–509           format 179–181
   reviewing OOP 11–13                              grouping 157–162
   selecting properties from 27–28                  property and method 173–179
   sorting 25–27                                       dot operator 174–177
   type of 12                                          indirect method invocation 178–179
   using Add-Member cmdlet to extend 402–408           static methods and double-colon
     adding AliasProperty members 404–405                   operator 177–178
     adding NoteProperty members 405–406            redirection 181–184
     adding ScriptMethod members 406–407            unary 154–157
     adding ScriptProperty members 407–408       operators in expressions 110–150
   using XML as 693–694                             arithmetic 112–119
   XML, adding elements to 695–697                     addition operator 113–116
-Off parameter, on Set-PSDebug 582                     multiplication operator 116–117
$OFS variable 103, 238, 387, 677–678                   subtraction, division, and modulus
one-dimensional arrays 171                                  operators 117–119
one-way hashing, public key encryption              assignment 119–124
   and 904–905                                         as value expressions 123–124
OnRemove handler 480                                   multiple 120–121
OnRemove property 390                               comparison 124–131
OOP (object-oriented programming) 11–13                and case-sensitivity 127–128
op_ class 112                                          scalar 125–127
op_Addition () method 112                              using with collections 129–131
op_Division() method 119                            logical and bitwise 148–150
Open file command, psEdit 612                       pattern matching and text
open tabs, listing In ISE 626                           manipulation 131–148
opening multiple files, in ISE 612                     -join operator 139–143
-OpenTimeout parameter 526                             -match operator 134–137
operand 114                                            regular expressions 133–134
operating environment, object-based 8                  -replace operator 137–139
operating on binary data 149                           -split operator 143–148
operations                                             wildcard patterns and -like operator 132–133
   basic 22–23                                   Option Explicit, in Visual Basic 582
   setting timeouts on 524–527                   Options property 624–625
Operations Manager, examining OpsMgr event log   orchestrating information 461
   entries 600                                   original tables 115
-OperationTimeout parameter 526                  origin-zero arrays 92
-OperationTimeout value 526                      OS information 595
operator semantics 150                           out-default 67
operators 151–197, 589                           Out-Default cmdlet 421, 555


960                                                                                        INDEX
Out-Default function 421                            param statement 242, 279–280, 397
outer loops 214                                     .PARAMETER <PARAMETER-NAME> help
OuterXML property 835                                  tag 319
Out-File cmdlet 68, 183, 679                        [Parameter()] attributes 355
Out-GridView command 69–70                          [Parameter] attribute 42
Out-Host cmdlet 69                                  parameter 41
Outlook Express 899                                 parameter aliases 49
Out-Null outputter 67                               Parameter attributes, specifying 296–303
Out-Printer cmdlet 68                                  HelpMessage property 302–303
output 64–70                                           Mandatory property 297
Output Field Separator ($OFS) variable 103, 238,       ParameterSetName property 298–299
   387, 677–678                                        Position property 297–298
output messages 568                                    ValueFromPipeline property 300
output objects 555, 568                                ValueFromPipelineByPropertyName
output pane                                                property 300–301
   accessing contents 629                              ValueFromRemainingArguments
   ISE 609                                                 property 301–302
   saving contents 629–631                          parameter binding 39
output redirection 22, 111, 181–182                    pipelines and 62–63
output stream 675                                      remoting 509
-OutputAssembly parameter 738                          type conversion in 107–109
outputter cmdlets 67–70                             parameter initializers, terminating errors in 580
OutputType attribute 293–295                        parameter sets
Out-String cmdlet 69                                   -Path 737–739
OverloadDefinitions property 682                       -TypeDefinition 736–737
overriding method 423                               parameterized properties 768
overwriting output 184                              ParameterizedProperty type 403
                                                    parameterizing functions 237
P                                                   parameters 60
P/Invoke 733                                           adding 459–462
P/Invoke signatures, interoperation with Add-Type      creating aliases with Alias attribute 303–305
   cmdlet 734–735                                      declaring 42, 241
PadLeft() method 677                                   for scriptblock 108–109
panes                                                  formal, declaring for functions 241–257
   controlling layout 607–610                          Microsoft WMI common 802–803
     command pane 608–609                                -AsJob and ThrottleLimit 803
     ISE toolbar 609–610                               processing 248
   editor, expansion in 613–614                        setting, for timer event handler 857
   ISE, syntax highlighting in 614                     validation attributes of 305–311
   text 629–633                                          AllowEmptyCollection 306
     making changes in editor pane 631–632               AllowEmptyString 306
     saving list of open files 632–633                   AllowNull 306
     saving output pane contents 629–631                 ValidateCount 307–308
param block 416, 773                                     ValidateLength 308
param keyword 31, 273                                    ValidateNotNull 307


INDEX                                                                                              961
parameters (continued)                            providers and core cmdlets 664–665
      ValidateNotNullOrEmpty 307                  PSDrives 665–667
      ValidatePattern 308–309                     Registry provider 671–672
      ValidateRange 309                           suppressing wildcard processing 668–669
      ValidateScript 310–311                   provider-specific path 666
      ValidateSet 310                          special characters 667
   vs. arguments 39                         pattern matching 215, 219
ParameterSetName property 298–299              and text manipulation 131–148
parent job 490                                    -join operator 139–143
parentheses 157, 176                              -match operator 134–137
Parse() method 106                                regular expressions 133–134
parsing 36, 562                                   -replace operator 137–139
   command output using regular                   -split operator 143–148
       expressions 136–137                        wildcard patterns and -like operator 132–133
   comment syntax 58–60                        operations 150
      multiline 59–60                          suppressing 670
   expression-mode and command-mode 54–56   $Pattern parameter 772
   quoting 51–54, 669                       peer-to-peer networks 891
   statement termination 56–58              performance
parsing modes 56, 243                          caveats for Get-Content cmdlet 680–681
partial type name 724                          flow control 233–235
-PassThru parameter 365, 379, 405              in remoting 465
Password field 790                          Perl 37, 889
password parameter 917                      PERL scripting language 133, 582
Password property 922                       persistent connections, remoting sessions
passwords                                      and 462–473
   in remoting 511                             additional session attributes 466–468
   specifying for files 914                    interactive sessions 469–472
path components 667                            managing sessions 472–473
path issues, relative paths 666                New-PSSession cmdlet 468–469
-Path parameter 296, 675, 737–739, 814      Personal Information Exchange, Certificate Export
-path parameter 249                            Wizard 914
__PATH property 814, 821, 826               petabytes 83
Path property 480                           .pfx files
path resolution 666                            signing scripts using 915–916
path translation 666                           specifying name for 915
path-based pattern language 703                verifying creation of 915
PATHEXT environment variable 898            PHP 38
paths                                       physical type containment 720
   Microsoft WMI, using to target           Pi constant 101
       instances 814–816                    $PID variable 468
   processing 664–672                       pipe operator 60
      containing wildcards 667–668          pipeline object flows 555–556
      LiteralPath parameter 670–671         pipeline output, as array 91–92


962                                                                                   INDEX
pipelines 60–63, 199, 202, 263                      adding CustomClass keywords 428–433
   and parameter binding 62–63                      little languages 428
   and streaming behavior 61–62                     type extension 433–436
   index of commands in 559                      grammar 201
   number of commands in 559                     help subsystem 23
   processing documents in 701–702               host application 14
   steppable 418–423                             installation directory 689
   using functions in 263–267                    IntelliSense in 21
      filters and functions 265–266              lookup algorithm 272
      functions with begin, process, and end     namespace capabilities in 267
           blocks 266–267                        parameter binding 509
PKI (Public Key Infrastructure) 905              -Property parameter 28
Platform Invoke. See P/Invoke                    provider infrastructure 187
plus operator 93                                 registry keys 671
plus-equals operator 93                          remoting host process, wsmprovhost.exe 528
point class 429                                  remoting schema 505
Point type 748                                   script file extensions 614
polymorphic behavior 196, 244                    scripts in 565
polymorphic methods 112                          secondary prompt in 28
polymorphism, in arrays 92–93                    setting the exit code 281
Popup() method 777                               string handling 25
-Port parameter 518                              support for .NET decimal type 24
ports, connecting to nondefault 518–519          syntax for script blocks 393
Position property 297–298                        terminology similar to other shells 38
positional parameters 242–243, 249               type system 423
PositionMessage property 559                     use of full .NET Framework 10
POSIX 38                                         using interactively 202
postincrement operator 80                        using wildcard characters with help 23
PowerPoint 614                                   VBScript and Jscript 785
PowerShell                                       viewing constraint variables 523
   aligning with C# syntax 38                  PowerShell API 546, 619
   and overloading 245                         PowerShell Development Environments 752
   and WSMan shells 511                        PowerShell drive abstraction. See PSDrive
   as management tool 554                      PowerShell foundations 36–70
   based on objects 11                           aliases and elastic syntax 47–50
   case-insensitivity 21                         core concepts 38–46
   categories of commands 39                     formatting and output 64–70
   command structure 13                          language 37–38
   console host 467                              parsing 50–60
   core types 505                                   comment syntax 58–60
   creation of 8                                    expression-mode and command-mode 54–56
   details on supported platforms 14                quoting 51–54
   downloading and installing 13                    statement termination 56–58
   exact vs. partial match 49                    pipelines 60–63
   expressions in 23                                and parameter binding 62–63
   extending language 428–436                       and streaming behavior 61–62


INDEX                                                                                  963
PowerShell Heresy 60                            private key protection, enabling strong 913–915
PowerShell Hosts 467                               .pfx file 915
PowerShell installation directory, $PSHOME         exporting certificate 913
   variable 702                                    specifying file format and password 914
PowerShell interpreter, function of 39             starting CERTMGR.EXE and selecting certifi-
PowerShell Job type, infrastructure extension          cate to export 913–914
   point 482                                    PrivateData element 375, 385–386
PowerShell language 589                         PrivateData field 385
PowerShell Local Certificate Root 912           probing 722
PowerShell provider model 664                   problem-solving pattern 29–30
PowerShell quick start guide 13–21              process blocks, functions with 266–267
   command completion 20–21                     Process clause 228
   console host 14–16                           process clause 61, 267, 397–398
   ISE 17–20                                    Process Id, using $PID variable 468
   obtaining program 14                         process keyword 254
   starting program 14                          Process object 508
PowerShell SDK (software development kit) 546   process streaming 62
PowerShell session, termination 604             process use, in ISE 619
PowerShell sessions 618                         ProcessID property 799
PowerShell tokenizer API 637                    ProcessId property 843
PowerShell.exe 605                              processing 663–718
   launching from ISE 611                          data 25–30
   running from ISE 609                               problem-solving pattern 29–30
   -sta parameter 753                                 selecting properties from objects 27–28
   -WindowStyle parameter 734                         sorting objects 25–27
powershell.exe console host 463                       with ForEach-Object cmdlet 28–29
PowerShellHostName element 367, 467                files 672–681
PowerShellHostVersion element 367, 467             paths 664–672
PowerShellTabs property 625                           containing wildcards 667–668
PowerShellVersion element 367, 369                    LiteralPath parameter 670–671
precision and conversion 73, 102                      providers and core cmdlets 664–665
predefined engine events 875–876                      PSDrives 665–667
predicate expressions 707, 810                        Registry provider 671–672
preference setting 569                                suppressing wildcard processing 668–669
prefix operators 94                                unstructured text 681–693
prescriptive error messages 587                       counting unique words with
PresentationCore, WPF required assemblies 753              hashtables 684–686
PresentationFramework, WPF required                   manipulating text with regular
   assemblies 753                                          expressions 686–688
PrimalForms PowerShell IDE 752                        searching files with Select-String
primary key 814                                            cmdlet 688–693
printf-debugging 260                                  System.String class 681–684
private aliases, in constrained sessions 547       XML structured text 693–718
private certificate, creating 913                     adding elements to objects 695–697
private function, calling 537                         loading and saving files 697–701


964                                                                                     INDEX
processing (continued)                             property checks 586
      processing documents in pipelines 701–702    property dereference operator 173
      processing with XPath 702–709                property names, viewing 557
      rendering objects as 711–718                 property notation 86
      using document elements as objects 693–694   property operators 173–179
      XLinq library 709–710                           dot 174–177
Process-Message cmdlet 49                             indirect method invocation 178–179
ProcessName property 305                              static methods and double-colon
process-object clause 62                                  operator 177–178
processor architecture 498–501                     -Property parameter 727–728, 751, 761
ProcessorArchitecture element 367                  PropertySet type 403
ProcessStartInfo object 922                        protocol layers 504
production elements                                protocol stack
   module manifests 366–370                           remoting 503–509
      module identity 368–370                         representing objects and types in 505–509
      runtime dependencies 368–370                 prototypes 401
ProductVersion property 33                         provider abstraction 672
$PROFILE variable 494                              provider capabilities 665
profiles, and remoting 494–495                     provider cmdlets, with WSMan 510
ProgID 762                                         provider infrastructure 402, 667
   Apple iTunes 763                                provider model 664
   Microsoft Word 763                              Provider paths, PSPath 665
Program Files 376                                  providers
programming constructs 198                            and core cmdlets 664–665
programming languages 393                             home directories 667
Progress Record, serialization in 506                 WSMan implementation 509–511
prompt function, ISE 609                                 establishing remote connection 510–511
prompt line element, ISE 608                             testing connections 510
prompting                                          provider-specific path 665
   for target computer 620                         proxy commands
   using Read-Host cmdlet 581                         creating with steppable pipelines 420–423
prompts 15                                            restricting features with 547
   nested, and Suspend operation 643–647           proxy functions
   while stepping 642                                 implicit remoting 546
properties                                            setting up, in constrained sessions 547
   adding to type system 425–427                   proxy servers, addressing remoting target using 520
   attempts to read nonexistent 585–586            ProxyAccessType setting 520
   compression of in serialization 509             ProxyAuthentication setting 520
   defined 11                                      ProxyCredential setting 520
   in registry 672                                 PS* properties 402
   parameterized 768                               .ps1 extension 44
   selecting from objects 27–28                    .ps1xml extension 434
   shadowing existing 427–428                      PSBase member 427
Properties member 424                              PSBase property 824
property bags 497–498, 506, 508                    $PSBoundParameters variable 254, 312


INDEX                                                                                            965
PSBreakpoint object 654                       $psUnsupportedConsoleApplications variable 617
$PSCmdlet variable 290, 293, 386–387          PSVariable objects, using as references 191–192
$PSCmdlet.SessionState.Module 386             public decryption key 904
$PSCmdlet.ThrowTerminatingError()             public fields 400
   method 293                                 public key cryptography 722
PSComputerName property 34                    public key encryption 904–905
PSCredential object 790                       Public Key Infrastructure (PKI) 905
PSCustomObject type 411                       public keys, use in type names 724
PSCustomType object 433                       public members 400–402
PSDiagnostics module 334, 363                 public methods 400
PSDrives (PowerShell drives) 665–667          public properties 400
psEdit command 612                            pure function 262
PSEventSubscriber objects 859, 861            pure synthetic objects 411, 433
$PSHOME variable 64, 689, 702                 Put() method 828–829
$PSHome variable 434                          -PutType parameter 814
$PSHome/modules directory 362                 Python 180
$PSHome/types.ps1xml 717                         comparison to Visual Basic 39
PSIsContainer property 402                       regular expressions 133
$psISE variable 621–623, 629                     security 889
PSModuleInfo objects 378, 381–382, 388–390,   Python interpreter 271
    535                                       Python lambdas 397
   accessing module exports using 381–382
   invocation in module context 378–381       Q
   methods                                    ql function 239–240
     Invoke() 382–383                         qs function 239–240
     NewboundScriptblock() 383–384            qualifiers 815
PSModuleObject 378                            Qualifiers attribute 815
$PSModuleRoot 358                             -Query parameter, selecting Microsoft WMI objects
PSObject class 423                                using 812–813
   PSBase member 695                          query-based event registrations, Microsoft
   synthetic object root 404                      WMI 871–875
PSObject layer 76                                 aggregating events with GROUP
PSObject property 423                                keyword 874–875
PSParser class 589                                Microsoft WMI intrinsic event classes 871–874
PSPath, provider paths 665                        WITHIN keyword 871
PSScriptMethod object 430                     Queue type, serialization in 507
PSScriptProperty 427                          queued events
$PSScriptRoot variable 358                        and Wait-Event cmdlet 863–866
PSSession attributes 466                      -quiet parameter 690–691
PSSession object, and runspaces 619           quotas, managing resource consumption
PSSessionConfiguration cmdlet 531                 with 523–524
$PSSessionConfigurationName variable 530      quotation marks 41
$PSSessionOption variable 519–520, 523, 526   quote list (ql) 239
PSSessions type 463                           quote removal 669
PSTypeConverter type 106                      quoting 51–54, 669


966                                                                                    INDEX
R                                                 Regex.Replace(String, MatchEvaluator) 852
                                                  Register-EngineEvent cmdlet 854–855, 878
range operator 165, 167, 170–171
                                                  Register-ObjectEvent cmdlet 854–855, 858–860,
rank 172
                                                      879
RBAC (role-based access control) 894
                                                  Register-PSSessionConfiguration cmdlet 523, 532
read method 581
                                                  RegisterTaskDefinition() method 789–790, 792
Read mode, variable breakpoints 657
                                                  Register-WmiEvent cmdlet 854–855, 873
-ReadCount parameter 229–231, 677, 697
                                                  RegistrationInfo property 788
read-evaluate-print loop 6
Read-Host cmdlet 581, 917                         registrations
reading                                               asynchronous events 854
   files 674–679                                      engine events 875–877
      Get-Content cmdlet 674–676, 680–681             Microsoft WMI events
      Get-HexDump function example 676–677               class-based 867–870
      Get-MagicNumber function                           query-based 871–875
          example 677–679                         Registry entry, for
      writing files 679                               LocalAccountTokenFilterPolicy 517
   key strokes 581                                Registry provider 665, 667, 671–672
ReadLine() method 581                             regular expressions 132–134, 218
ReadOnly option 190                                   alternation operator 687
Really Simple Syndication. See RSS                    creating from strings 687
Receive-Job cmdlet 483–484, 492                       default match 135
recording errors 560                                  extracting text with 136
-Recurse parameter 809                                manipulating text with 686–688
-recurse parameter 249                                   splitting strings 687
-Recurse switch 41                                       tokenizing 687–688
recursive definition 262                              Match method 687
recursive directory listing 249                       matching any character 137
red stop button 18                                    matching the beginning of a string 137
redefine functions 645                                parsing command output using 136–137
redirection 276, 278, 568                             quantifier specifications 687
   error stream 555                                   submatches 134
   into variables 556                                 using with switch statement 217–221
   merging output and error streams 556           rehydrated, serialization 505
   redirecting error stream 560                   relative path resolution 667
   stream merge operator 556                      remainder modulus 120
redirection operator 24, 125, 181–184, 187, 555   remote computers, starting background jobs
reducing attack surface 893                           on 489–492
reference types                                   remote connection, starting in ISE 620
   array as 93–94                                 remote debugging, tracing script execution 658
   hash tables as 90–91                           remote output, vs. local output 497–498
references, using PSVariable objects as 191–192   remote session startup directory 494
[regex] alias 97                                  remote sessions 619–622
[regex] class 687, 851                            Remote tab architecture 622
[regex] type 687                                  .REMOTEHELPRUNSPACE <PSSESSION-
-regex flag 218                                       VARIABLE> help tag 320


INDEX                                                                                        967
remoteserver application 546                         sessions and persistent connections 462–473
RemoteSigned policy 337, 899                            additional session attributes 466–468
remoting 32, 46, 447–502                                interactive sessions 469–472
   additional setup steps for workgroup                 managing sessions 472–473
      environments 451                                  New-PSSession cmdlet 468–469
   and event forwarding 877–882                      subsystem 449–450
   applying 454–462                                  target machine 33
     basic remoting examples 454–455                 timeouts 526
     multimachine monitoring 457–462                 transient connections 463
   commands with built-in 448–449                 remoting infrastructure
   configuration elements 530                        buffering 457
   configuration startup script 532                  connection heartbeat 473
   considerations when running                       support for throttling 522
      commands 493–501                            remoting protocols
     executables 495–496                             [MS-PSRP] 504
     processor architecture 498–501                  complete protocol stack 504
     profiles and remoting 494–495                   DCOM 448
     reading and writing to console 496–497          HTTPS 504
     remote output vs. local output 497–498          Web Services for Management (WSMan) 504
     remote session startup directory 494         Remove All Breakpoints debug menu item 649
   cross-domain issues 517                        Remove()method 635
   custom services 502, 527–552                   Remove-Event cmdlet 854, 865
     access controls and endpoints 533–535        Remove-Item cmdlet 670, 672–673
     configurations 530–531                       Remove-Item command 268
     constrained execution environments 543       Remove-Job cmdlet 483, 487
     constraining sessions 535–543                Remove-Module cmdlet 325, 335, 339, 388
     remote service connection patterns 527–530   Remove-PSBreakPoint cmdlet 653
   disabling 897                                  Remove-PSSession cmdlet 472
   enabling 450–451                               Remove-WmiObject cmdlet 822–824
   EventLog access 602                            removing class definition 432
   implicit 473–481                               removing items, hash tables 88
   infrastructure 503–527                         Rename-Item cmdlet 673
     addressing remoting target 518–520           renaming functions 399
     authenticating 511–518                       rendering objects 69
     managing resource consumption 522–527        REPL. See read-evaluate-print loop
     Microsoft Windows connection                 -replace operator 134, 137–139, 632, 687, 732,
          issues 520–522                              881
     remoting protocol stack 503–509              Replace() method 851–852
     WSMan implementation cmdlets and             replacement strings, in event log entries 604
          providers 509–511                       repudiation, defined 892
   interactively 34                               RequiredAssemblies element 370, 372, 375, 722
   performance issues 465                         RequiredAssemblies field 372
   persistent connections 463, 465                RequiredAssemblies module 373
   requirement for elevated sessions 517          RequiredModules element 367, 370, 372
   resource management 472                        RequiredServices property 713


968                                                                                      INDEX
Reset() member 210                                   runtime checks, in scripts 582
Reset-Count command 338, 342                         runtime dependencies, module manifests 368–370
resizing arrays 259                                  runtime type casts 153
resource consumption, managing 522–527               runtime type conversion error 185
resource leaks, handles and garbage collection 701
resource management, using throttling 458–459        S
resources
                                                     sample taxonomy, of classes and subclasses 12
    singleton, vs. enumerations 836–837              sandboxing, defined 897
    updating using Set-WSManInstance                 saving, files 697–701
       cmdlet 840–841                                scalability
restricted execution policy 899                          in scripting 459
restricted language, in constrained sessions 539     scalar arguments 238
RestrictedLanguage Mode 542                          scalar comparisons 125–127
restrictions, in sessions 541                            basic rules for 126
$result variable 259                                     type conversions and comparisons 126–127
resuming execution, after exceptions 574             scalar object 96, 210
return statement 227, 262–263, 280                   scalar value 95, 125, 210–211
returning function objects, ScriptControl 785        scale() method 433
reusable configuration script, for custom remoting   Scaling fan-in remoting, Issues 528
    configurations 544                               Schedule.Service class 786–787
reverse arrays 406                                   scientific notation 75
Reverse member 170                                   scopes
reverse method 140, 406                                  and scripts 281–284
reversed in place, arrays 406                              dot-sourcing scripts and functions 283–284
rich error objects 554                                     simple libraries 283
right aligned 180                                        in script modules 348–350
right operand 126, 153                                   managing with script blocks 572
role-based access control (RBAC) 894                 scoping
roles, authentication, authorization, and 894–895        behavior, F5 vs. F8 615
root directory 111                                       execution policy 900–903
Root module term 326                                     rules 269, 281
rootcimv2 namespace 800                                  variable, in functions 269–274
RootSDDL security descriptor, remoting access        script authoring, control of errors 569
    control 534                                      script block construction 398
RPC server not available error 802                   script block execution, in debug actions 654
RSS (Really Simple Syndication) 4                    script blocks
RSS feeds, processing 742–743                            as event handlers 746
Ruby language 400                                        defines a function 399
Run() method 778                                     script calls, calling another script 562
Run/Continue debug menu item 648                     script checking 582
runas.exe command 920                                script code
running elevated 277                                     building at runtime 436–440
running scripts from ISE, F5 key 649                       $ExecutionContext variable 437
RunspaceId 862                                             creating elements in function drive 439–440
runspaces, defined 619                                     ExpandString() method 437–438


INDEX                                                                                             969
script code (continued)                             scripting languages 553
       Invoke-Expression cmdlet 436–437                 features of 7
       InvokeScript() method 438                        security 890
       script blocks 438–439                            vs. shell, advantages 7
    fragments of 569                                ScriptMethod members, adding to
script commands 39                                      objects 406–407
$script counter variable 863                        ScriptMethod type 403
script editor 18                                    ScriptProperty members, adding to
script line number, getting 559                         objects 407–408
script modules                                      ScriptProperty type 403
    dynamic 412–414                                 scripts 31–32, 44, 275–321
    nesting binary modules in 357–360                   advanced functions and 276–287
    setting module properties from inside 388              documenting 314–321
    writing 337–353                                        dynamic parameters and dynamicParam
       controlling member visibility with Export-               keyword 311–314
            ModuleMember cmdlet 343–347                    exiting scripts and exit statement 280–281
       installing module 347                               managing scripts 284–285
       nested modules 350–353                              passing arguments to scripts 278–280
       review of scripts 338–340                           running scripts from other
       scopes in script modules 348–350                         applications 285–287
       turning into module 340–343                         scopes and scripts 281–284
script name, getting 559                                   writing 287–311
Script Property                                         applying strict mode V2 to 588–589
    getter method 407                                   blocks, handling asynchronous events
    setter method implementation 408                        with 860–863
    setter script block 407                             calling from another script 562
script scope 281                                        controlling access to 541
script tracing 639, 641                                 debugging 638–647
script versioning 49                                       nested prompts and Suspend
[ScriptBlock]::Create() method 642                              operation 643–647
ScriptBlock 506                                            Set-PSDebug cmdlet 638–643
[scriptblock] alias 97                                  enabling with execution policy 898–903
[scriptblock] type accelerator 439                         controlling and scoping 900–903
scriptblock parameter 685                                  settings 899–900
scriptblocks 223, 226, 228, 393–400, 438–439            execution policy 276–278
    creating new scopes 572                             exit code 566
    defining functions at runtime 398–400               flow control in. See flow control
    invoking commands 394–396                           generating events in 876–877
    literals 397–398                                    hello world file 31
    parameters for 108–109                              review of 338–340
    security 923                                        running from cmd.exe 286
    targeted execution in ISE 627                       running in ISE 616–618
    using with remoting 454                                issues with native commands 616–617
    using with -split operator 148                         threading differences between console and
scripting debugger 653                                          ISE 618


970                                                                                            INDEX
scripts (continued)                                secure remoted service, creating 551
    signing 904–916                                secure scripts 888
       authorities 905                                 credentials 919–923
       certificates 905                                SecureString
       enabling strong private key                       class 916–917
            protection 913–915                           cmdlets 918–919
       public key encryption and one-way                 object 917–918
            hashing 904–905                        Secure String, serialization in 506
       using .pfx files 915–916                    securing PowerShell installations 916
    static analysis of 589–593                     security 888–927
    suspending while in step mode 644–645              by default 897–898
    using certificates to sign 909–912                   disabling remoting 897
       setting up test script 909–910                    managing command path 898
       signing test script 910–912                       no execution of scripts 897–898
       testing integrity of script 912                   notepad 897
    wheres                                             introduction to 889–891
       original 923–925                                  Danom virus 890–891
       safer and faster version 925–927                  MSH/Cibyz worm 891
    writing secure 916–927                             modeling 891–897
       avoiding Invoke-Expression cmdlet 923–927         threat 891–892
       credentials 919–923                               threats, assets, and mitigations 893–897
       SecureString 916–919                            modeling concepts 888
Scripts property, From                                 scripts
    $ExecutionContext.SessionState 539                   enabling with execution policy 898–903
scripts, no execution of                                 signing 904–916
    by default 897–898                                   writing secure 916–927
script-scoped 282                                  Security Descriptor Definition Language
ScriptsToProcess element 370, 372–373                  (SDDL) 534
ScriptToProcess 372                                security descriptors, setting on
SDDL (Security Descriptor Definition                   configurations 534–535
    Language) 534                                  security implications
search algorithm, modules 329–330                      Enable-PSRemoting cmdlet 451
search tools, file 754                                 TrustedHosts list 452
    defining appearance 754–756                    security model 893
    specifying behavior 756–758                    Security Options, secpol.msc 521
searcher object 825                                security response, Microsoft 890
Search-Help function 702                           select command 34
searching                                          select elements 410
    files, with Select-String cmdlet 688–693       selected text, executing in ISE 615–616
    with context properties 692                    selecting, instances 838–839
secpol.msc 521                                     Select-Members filter 726
secure by default principle 450                    Select-Object cmdlet 378, 423, 679
secure computer 889                                    defined 27
secure environment 891                                 getting first lines of file with 911
Secure Hash Algorithm version 1 (SHA-1) 907            selecting range of objects 410–412
secure hashing algorithm 889, 904                      using -Property parameter 28


INDEX                                                                                               971
-SelectorSet parameter 838, 840         Service subnode, of WSMan drive 525
Select-String cmdlet 741                ServiceName property 305
    -Quiet switch 690                   Services, ServiceController objects 712
    searching files 688                 servicing. See Application servicing
Select-Xml cmdlet 703–709               session boundary 541
self-describing, .Net object model 10   session isolation, in remoting 530
Self-Remoting Commands                  -Session parameter 492–493
    Clear-EventLog 448                  -SessionOption parameter 520
    Get-Counter 448                     sessions 463
    Get-EventLog 448                        and hosts 467
    Get-HotFix 448                          capturing output 593–596
    Get-Process 448                         configurations 531–532
    Get-Service 448                         constraining 535–543
    Get-WinEvent 448                           controlling command visibility 536–539
    Limit-EventLog 448                         setting language mode 539–543
    New-EventLog 448                        interactive 469–472
    Remove-EventLog 449                     isolation 467
    Restart-Computer 449                    local in-memory 619
    Set-Service 449                         managing 472–473
    Show-EventLog 449                       managing definitions in 267–269
    Stop-Computer 449                       remoting 619–622
    Test-Connection 449                        additional attributes 466–468
    Write-EventLog 449                         and persistent connections 462, 468–473
self-signed certificate 909                 running background jobs in existing 492–493
semicolon character 56, 201, 204, 257   Set-Alias command 48
Sender field 877                        Set-AuthenticodeSignature cmdlet 910
$Sender variable 861                    Set-Content cmdlet 188, 673
$Sender.Event 861                       Set-CountIncrement 384
sending keystrokes 765                  Set-ExecutionPolicy cmdlet 277–278
SendKeys() method 778                   setIncrement function 338, 345
sensitive data, security 916            Set-Item cmdlet 673
separator 280                               in constrained sessions 542
serialization                               setting TrustedHosts list 513
    core types 506                      Set-Location cmdlet 673
    default depth 498, 713              Set-PSBreakPoint cmdlet 653
    IList interface 507                 Set-PSDebug cmdlet 582, 638–643
    in systems management 505               -Off parameter 582
    object fidelity 716                     statement execution 642–643
    of collections 507                  Set-PSDebug, -Trace parameter 582
    shredding objects 716               Set-PSSessionConfiguration command 533
    using property bags 506             Set-Service cmdlet 453
<SerializationDepth> element 717        Set-StrictMode cmdlet 584–589
serialized objects 46                       applying strict mode V2 to scripts 588–589
servers, proxy 520                          attempts to read nonexistent
service architecture 527                        properties 585–586


972                                                                             INDEX
Set-StrictMode cmdlet (continued)                  shutdown command 495
    empty variable references in strings 587–588   side-by-side mode, ISE 610
    functions called like methods 586–587          side-effects, of for statement 206
    uninitialized variable use in string           signature information, security 911
        expansions 584–585                         signatures, decrypting 904
settable property 405                              signing
setting breakpoints, on lines in script 654            authorities 905
setting token colors, syntax highlighting 625          scripts 904–916
setting window styles 734                                certificates 905
Set-Variable cmdlet 379, 387, 651                        enabling strong private key
Set-Variable command 379                                      protection 913–915
Set-WmiInstance cmdlet 813–819                           public key encryption and one-way
    setting instance properties 816–819                       hashing 904–905
    using Microsoft WMI paths to target                  using .pfx files 915–916
        instances 814–816                          simple assignment 89
Set-WSManInstance cmdlet, updating resources       simple matching 145
    using 840–841                                  Simple Object Access Protocol (SOAP) 504
SHA-1 (Secure Hash Algorithm version 1) 907        simplematch option 145
shadowing existing properties 427–428              single precision 74
shared libraries 721                               single quotes 53, 437
shell environments 62                              single-instance objects, modules 326–327
shell function commands 39                         singleline mode 147
shell language 9                                   single-quoted, strings 78–79
Shell.Application class 765–766                    single-threaded apartment. See STA 618
Shell.Application object 772                       Singleton member, creating definitions 730–734
Shell.Automation class 795                         singleton resources, vs. enumerations 836–837
ShellExecute API 922                               Skip3 functions 681
shells                                             slicing 167–171
    as command-line interpreter 6                      arrays 169–170
    reasons for new model 7–8                          multidimensional arrays 172
      managing windows through objects 7–8             using range operator 170
    scripting languages vs. 6–7                    sliding window 803
    text-based 10                                  snap-in modules, binary modules vs. 354–355
Shift-F10, displaying context menu 612             snap-in, MMC extension 32
ShouldProcess() method 290                         Snippets menu
-Show switch 773                                       extending ISE 637
$showCmdlet module 358                                 submenu for 637–638
ShowDialog() method 747, 749, 776                  Snover, Jeffrey, PowerShell architect 118
Show-ErrorDetails function 559                     SOAP (Simple Object Access Protocol) 504
Show-EventLog cmdlet 597                           software development kit (SDK), PowerShell 546
ShowSecurityDescriptorUI parameter 535             sorting
ShowToolBar, ISE menu item 625                         hash tables 87–88
ShowWindow() API 772                                   in descending order 26
ShowWindow() method 734                                objects 25–27
shredding objects 506, 716                             UNIX sort command 26


INDEX                                                                                         973
Sort-Object cmdlet 25, 27, 87, 684                 Start-Transcript cmdlet 593
Soul of a New Machine (Kidder) 9                   startup directories, remote session 494
Source filter 599                                  startup script, remoting 532
-Source parameter, on Get-Eventlog 602             state, event handler 862–863
$SourceArgs variable 861                           statement termination 56–58
$SourceEventArgs variable 861                      <statementList> section 204
SourceIdentifier 856, 859–860, 865, 878            statements
special behaviors operators 112                        as values 231–233
special characters, using backtick 54                  flow-control 223, 231
special variable 209                               static analysis, of scripts 589–593
special-purpose applications, using remoting 530   static checks, in scripts 582
special-purpose endpoint 537                       -Static flag 99
spell checking, using Microsoft Word 781–783       static members 170
Spelling dialog box 783                                accessing 177
spelling errors 782                                    accessing with literal 99–101
splatting 839                                      static methods 177–178
    in proxy functions 478                             calling 819–822
    specifying remote connection settings 519          reference operator 177
    variables 193–197                              static reverse method 406
-split operator 143–148, 631, 638, 681             static script checks 591
    options for 145–148                            static typing 72
    using scriptblocks with 148                    status line, ISE 608
Split() method 681–682, 687                        status variables 564
SplitStringOptions parameters 682–683              stderr 259
splitting strings, with regular expressions 687    Step Into debug menu item 648
spoofing, defined 892                              step mode, suspending scripts while in 644–645
SQL injection attacks 896                          Step Out debug menu item 648
SQL query 896                                      Step Over debug menu item 648
square brackets 174                                -Step parameter 642
ssh. See Invoke-Command cmdlet                     Step-Over debug command 650
STA (single-threaded apartment) 618, 793           steppable pipelines 418–423
-sta parameter 618, 753                                creating proxy command with 420–423
Stack type, serialization in 507                       in proxy functions 478
StackPanel layout control 755                      stepping mode 645
standard classes, WMI 807                          stepping script 644
Start() method 859                                 stepping through scripts 638
Start-Job cmdlet 483, 803                          Stop Debugger debug menu item 648
Start-Job method 882–883                           Stop-Job cmdlet 483
Start-LocalUserManager command 920                 Stop-Job method 883
Start-LocalUserManager function 921                Stop-Process 869
Start-Process cmdlet 734, 743, 869, 921            Stop-Transcript cmdlet 593–594
Start-Program function 666                         stream combiner 183
Start-Sleep cmdlet 456, 526, 627, 875              -Stream parameter 69
StartTime property 128                             streaming behavior 43, 61–62


974                                                                                        INDEX
strict mode 638                                   strong naming 722
    applying V2 to scripts 588–589                strongly typed languages 185
    catching errors with 582–584                  structured error handling 554
      undefined variables 583–584                 structured programming 213
      V1 582                                      structured text, processing 693–718
    In PERL 582                                   subclassing 401
    version 2 584, 588–589                        subdirectories, and dir command 41
-Strict parameter 762, 794                        subexpression expansion, in strings 79
-Strict switch 761                                   complex 79–80
STRIDE model 892                                     considerations for 80
[string] class 681, 686                           subexpression operator 196
[string].Join method 177                          subexpressions 57, 202, 206, 247
string constructor 729                               array 160–162
string context 129                                   function of 157
string expansion 238                                 with throw statement 580
    empty delimited variables 587                 subkeys, in registry 671
    suppressing 437                               submatches 134
    uninitialized variable error 585              Submenus collection, ISE object model 635
string multiplication 116                         SubscriptionId property 860
string operations                                 subscriptions
    convert array to string 677                      .NET events 859–860
    extracting fields from string 682                   listing 859
    formatting hexadecimal numbers 677                  removing 859–860
    joining strings 683                              asynchronous events 854
    padding strings 677                           subshell 645
    parsing arithmetic expressions 687            Substring method 176
    splitting and joining strings 681             subsystem remoting 449–450
    splitting into words 684                      subtraction operation 120
    splitting on Whitespace character class 682   subtraction operator 117–119
    splitting strings 678                         Success Audit type 599
    tokenizing strings 687                        Success property 688
String operations, casting to regular             Sum() method 264, 434–435, 732
    expressions 687                               SumMethod.ps1xml file 435
strings 58, 77–82                                 superclasses 867
    adding together 25                            -SupportEvent 856
    concatenation of 25, 113, 240, 683            SupportEvent switch 856
    empty variable references in 587–588          SupportsShouldProcess property 290–293
    encoding used in 77–78                        Suspend operation, nested prompts and 643–647
    executing 437                                 Suspended shell feature 645
    here-strings 80–82                            suspending sessions 643
    joining 177                                   swapping files 188
    single and double-quoted 78–79                swapping two variables 120
    splitting, with regular expressions 687       [switch] alias 97
    subexpression expansion in                    [switch] type 249
      complex 79–80                               $switch loop enumerator, using in switch
      considerations for 80                          statement 222


INDEX                                                                                       975
switch parameters 41                               System.Diagnostics.EntryWrittenEventArgs 880
   using to define command switches 248–252        System.Diagnostics.Process class 128
   vs. Boolean parameters 252–257                  System.Drawing assembly 748
switch statement 30, 148, 199, 250, 781, 925       System.EventHandler class 746, 850–851
   processing files with 221–222                   System.GUID class 762
   using $switch loop enumerator in 222            System.Int32 type 96
   using regular expressions with 217–221          [System.IO.DirectoryInfo] object 585
   using wildcard patterns with 216–217            [System.IO.FileInfo] object 585
switch value 216                                   System.IO.FileInfo objects 208
$switch variable 222, 263, 701                     [System.IO.FileInfo] type 586
$switch.movenext() method 222                      System.IO.FileSystemWatcher class 864
SwitchParameter type 107                           System.IO.StringReader instance 776
synchronous events 849–853                         System.Management.Automation namespace 96
   delegates and delegation 850–853                System.Management.Automation.CommandInfo
   in GUIs 850                                        type 394
.SYNOPSIS tag 317                                  System.Management.Automation.PSCustomOb-
syntactic analysis 50                                 ject type 409, 411
syntactically complete statement 57                System.Management.Automation.PSEvent-
syntax                                                Args 861
                                                   System.Management.Automation.PSObject 404
   for programmer-style activities 176
                                                   [System.Management.ManagementPath]
   of foreach statement 207
                                                      object 830
syntax checking custom menu item 637
                                                   [System.Math] class 100
syntax errors 201, 592
                                                   [System.Math] type 727
syntax highlighting
                                                   [System.Net.WebClient] type 740
   in ISE panes 614
                                                   System.Object, root of object hierarchy 404
   setting token colors 625
                                                   System.Reflection.Assembly class, loading assem-
synthetic member objects 402, 404, 411, 427, 430      blies with 723–725
synthetic properties 76, 402                       System.Security.SecureString class 916
system dialogs 621                                 System.Security.SecureString type 920
system drives 672                                  System.String class 100, 681–684
system health monitoring, remoting example 462        analyzing word use in documents 683–684
System. ComObject type 767                            SplitStringOptions parameters 682–683
System.Array, extending 435                           testing types 404
System.Collections namespace 720                   System.Text.RegularExpressions.Match class 687
System.Collections.ArrayList class 261             System.Text.RegularExpressions.Regex class 687
System.Collections.ArrayList type 507, 560         System.Timers namespace 726
System.Collections.ArrayList.Add() method 720      System.Timers.ElapsedEventHandler class 726
System.Collections.Generic.List 739                System.Timers.Timer class 856
System.Collections.Hashtable type 86               System.Version 368
System.Collections.IDictionary interface 85, 507   System.Windows.Forms namespace 723
System.Collections.IEnumerator interface 210       System.Windows.Window namespace 756
System.Console APIs 496                            System.XML.XmlDocument class 694
System.DateTime class 119                          System.Xml.XmlReader class 698
System.Datetime type 118                           SystemRoot environment variable 186
System.Delegate class 746, 850–851                 SysWoW64 directory 499


976                                                                                         INDEX
T                                                  telnet. See Invoke-Command cmdlet
                                                   $tempFile 881
$t variable 408
                                                   temporary file 187
tab behavior, ISE 612
                                                   terabytes 83
tab completion 910
                                                   terminate partial operation 569
    auto-correcting of capitalization 21
                                                   Terminate() method 290, 823, 827, 842
    in editor pane 613
                                                   terminating errors 554, 566, 569
    in ISE 617
    on partial cmdlet names 20                         exception 570
    on properties 21                                   generating in script 578
    on properties in variables 20                      rethrowing 571
    on variables 20                                terminating, PowerShell session 604
    on wildcards 20                                terminator characters 56
    user extendable 21                             terminology 38
    within file system 20                          test document 703–704
Tab key                                            test(1) command 125
    for tab completion 13                          Test-ModuleContext module 386
    using 20                                       Test-ModuleManifest cmdlet 325, 365, 377
TabExpansion function 21                           Test-Path cmdlet 184
tablet computers 610                               TestProperty variable 817
tabs 625–629                                       tests, scripts
    Editortabs 18                                      integrity of 912
    expansion in editor pane 613–614                   setting up 909–910
    using multiple 618–622                             signing 910–912
       local in-memory session 619                 Test-Script function 590
       remote session 619–622                      $testv module 387
    working with in ISE 629                        $testv variable 386–387
tags, used in comments 318–321                     Test-WSMan cmdlet 509
tampering with data, defined 892                   text
target computer, prompting for 620                     inserting in ISE editor buffer 630
target object 561                                      processing 663, 693
TargetObject property 558, 564                         processing unstructured 681–693
Task Scheduler window 792                                 counting unique words with
Task Scheduler, Microsoft Windows. See Microsoft              hashtables 684–686
    Windows, Task Scheduler                               manipulating text with regular
tasks                                                         expressions 686–688
    creating new 788–789                                  searching files with Select-String
    credentials and scheduled 789–792                         cmdlet 688–693
    listing running 787                                   System.String class 681–684
    viewing life cycle of 792–793                      selected, executing in ISE 615–616
taskschd.msc 792                                       XML structured, processing 693–718
tb function 252                                    text manipulation, pattern matching and 131–148
TCL/TK (Tool Command Language/Tool                     -join operator 139–143
    Kit) 743                                           -match operator 134–137
Technet website 674                                    regular expressions 133–134
telecommunications 8                                   -replace operator 137–139


INDEX                                                                                         977
text manipulation, pattern matching and (continued)   Tokenizer API 589, 591
   -split operator 143–148                            tokenizing text 687–688
   wildcard patterns and -like operator 132–133       tokens 50, 589, 591
text panes 629–633                                    Tool Command Language/Tool Kit (TCL/
   making changes in editor pane 631–632                  TK) 743
   saving list of open files 632–633                  toolbar object 625
   saving output contents 629–631                     toolkit, for building custom solutions 8
Text property 630, 757                                top-level execution thread 646
text-based shells 10                                  top-level match 135
TextBox controls 757                                  top-level properties, in ISE object model 623
$this member 407                                      ToString() method 418, 429, 433, 438, 508, 572,
$this variable 407, 745                                   641, 679
this.MyInvocation.MyCommand.Module 385                ToUpper() method 427
this.SessionState.Module 386                          trace message format 641
Thompson, Ken 133                                     trace mode 639
threading model                                       -Trace parameter, on Set-Debug cmdlet 582
   defined 618                                        Trace-Command cmdlet 63
   problems in COM 793                                tracing function calls 640
threat modeling 891–892                               traditional dynamic scoping 270
threat to systems, defined 892                        tradnum function 258
threats, assets, mitigation, and 893–897              transcript facility, in ISE 629
   authentication, authorization, and                 transcript file 595
       roles 894–895                                  transcript implementation 593
   avoiding lawn gnome mitigation 893–894             transcript of script traces 641
   blacklisting/whitelisting 894                      transcripts, session output captured with 595–596
   code injection 896–897                             transformation 408
   input validation 895–896                           transitional aliases 48
-ThrottleLimit parameter 522, 803                     transport mechanism, remoting 503
throttling, resource management using 458–459         trap statement 570–575
throw keyword 702                                         control transfer 572
throw statement 248, 578–580                              flow chart 573
timeout interval 526                                      flow of control 573
-Timeout parameter 863                                trees of files 691
timeouts, setting on operations 524–527               triggered clause 219
<TIMER>message 877                                    Trojan Horse attack, defined 898
timer event handler, writing 856–859                  $true variable 184
   binding event action 857–858                       trust relationship, in remoting 511
   creating timer object 856                          trusted certificate authority, role in remoting 512
   enabling 858–859                                   trusted third party organizations 905
   setting parameters 857                             TrustedHosts element 514
$timer.Stop() method 858                              TrustedHosts list
TlntSvr process 870, 872                                  authenticating target computer using 512–514
Toggle Breakpoint debug menu item 649                 try keyword 575
Tokenize() method 589                                 try to pop GUI 496
tokenizer analyzer 50                                 try/catch statement 570, 575, 772


978                                                                                              INDEX
try/catch/finally statement 578                  typeless languages 72
try/finally statement 881                        typeless parameters 101, 243
type accelerators                                typelibs, problems in COM 793–796
   Microsoft WMI 825–828                         TypeNames member 424
      [WMI] type accelerator 826–827             TypeNames property 497
      [WMICLASS] type accelerator 827–828        typeof() operator 178
      [WMISEARCHER] type accelerator 825         types 72–109
   WMI 828                                          arrays 91–96
type aliases 96–98                                     as reference types 93–94
type already exists error 738                          collecting pipeline output as 91–92
type command 47                                        empty arrays 94–96
type configuration files 434                           indexing of 92
type constrained variables 586                         polymorphism in 92–93
type constraints                                    conversions of 101–109
   adding to parameters 243–245                        .NET-based custom 104–107
   multiplication and arrays 117                       built-in 104
type conversion error 114                              in parameter binding 107–109
type conversion operators 112                          overview 101–104
type conversions 245                                creating instances of 727–729
   and comparisons 126–127                          defining 429
   in multiple assignment 123                       defining new with Add-Type cmdlet 729–739
   tracing mechanism 127                               creating Singleton member
   with XML documents 694                                   definitions 730–734
type files, loaded at startup 434                      interoperation with P/Invoke
type inferencing 73                                         signatures 734–735
type library 795                                       -Path parameter set 737–739
type literal 153, 177                                  -TypeDefinition parameter set 736–737
type metadata 505                                   enum, defining new at runtime 442–443
-Type parameter 557                                 explicit operations 152
type parameters 739                                 extending 433–436
Type property 372                                   finding 725–727
type qualifiers, multiple assignment operators      generic 739–740
   with 121–123                                     hash tables 85–91
type references, assembly manifest 721                 as reference types 90–91
type resolution 97                                     enumerating 87–88
   in complied programs 722                            modifying 88–89
   static linking 721                                  sorting 87–88
type system 423–428                                 implicit operations 152
   adding properties to 425–427                     literals 96–101
   shadowing existing properties 427–428               accessing static members with 99–101
   updating definitions 435                            generic types 98–99
type-constrained function 244                          type aliases 96–98
type-constrained variable 96, 115                   management of 72–77
TypeConverter type 106                              numeric 82–85
-TypeDefinition parameter set 736–737                  hexadecimals 84–85


INDEX                                                                                     979
      multiplier suffixes for 83–84               searching files with Select-String
      specifying 83                                   cmdlet 688–693
   operators for working with 152–154             System.String class 681–684
   representing in protocol stack 505–509      Unsubscribe-Event 859
   strings 77–82                               unsupported application list
      complex subexpressions in 79–80             in ISE 617
      encoding used in 77–78                   untrusted directory 898
      expansion considerations for 80          Update-Character function 255
      here-strings 80–82                       Update-TypeData cmdlet 435, 880–881
      single and double-quoted 78–79           updating
      subexpression expansion in 79               TrustedHosts list 513
types files, default installed 434             updating, ISE menu items 635
$typeSpec variable 881                         URIs (Uniform Resource Identifiers)
TypesToProcess element 370, 373                   addressing remoting target using 519
                                                  targeting WS-Man resources using 834
U                                              usability testing 619
                                               User Access Control (UAC) 903
UAC (User Access Control) 903
                                               User Account Control (UAC) 517
UAC (User Account Control) 517
                                               User filter 599
unary comma operator 728
                                               user portability aliases 673
unary operators 154–157
                                               user profile, in remote sessions 470
unauthorized scripts 893
                                               UserName property 922
unconstrained function 244
                                               users
undefined command 592
                                                  authenticating 514–518
undefined variable 208
                                                     enabling remoting for administrators in other
underlying store, WMI 828
                                                         domains 517–518
Unicode 78
                                                     forwarding credentials in multihop
unified namespaces 184
                                                         environments 515–517
Uniform Resource Identifiers. See URIs 519
                                               usesCount module 351–352
uninitialized variables 184, 583
                                               usesCount.psm1 module 350
Universal Execution Model 32
                                               usesCount2 353
UNIX command equivalents 673
                                               using debugger, example 649
UNIX environment 428
                                               -UsingNamespace parameter 730
UNIX shell, convenience aliases 673
                                               UTC time 788
unqualified operators, case insensitive by
                                               $utils variable 738
   default 125
unraveling collections 210
                                               V
Unregister-Event cmdlet 854, 860
Unregister-PSSessionConfiguration cmdlet 531   v2 debugger, graphical 648–652
unrestricted execution policy 900                 executing other commands in debug mode 651
unsigned scripts 909                              hovering over variables to see values 652
unstructured text, processing 681–693          ValidateCount attribute 307–308
   counting unique words with                  ValidateLength attribute 308
      hashtables 684–686                       ValidateNotNull attribute 307
   manipulating text with regular              ValidateNotNullOrEmpty attribute 307
      expressions 686–688                      ValidatePattern attribute 308–309


980                                                                                       INDEX
ValidateRange attribute 309                               cmdlets 188–193
ValidateScript attribute 310–311                            getting and setting variable options 189–191
ValidateSet attribute 310                                   indirectly setting variable 188–189
validating security 925                                     using PSVariable objects as
validation 408, 895–896                                           references 191–192
value expressions 123–124, 232                              variable names vs. variable values 192–193
Value member 425                                          declaring 184, 270–272
-Value parameter 190                                      empty references in strings 587–588
ValueFromPipeline attributes 312                          expanding 438
ValueFromPipeline property 300                            hovering over to see values 652
ValueFromPipeline=true notation 42                        indexing with 173
ValueFromPipelineByPropertyName                           initializing 29
   property 300–301, 305                                  name syntax 186–188
ValueFromRemainingArguments                               saving expressions in 24
   property 301–302                                       setting breakpoints on assignment 657–658
values                                                    splatting 193–197
   in Registry 671                                        swapping 120
   of variables, variable names vs. 192–193               undefined 583–584
   returning from functions 257–263                       uninitialized use in string expansions 584–585
      debugging problems in function                      viewing values of 652
          output 259–262                                  visibility in remoting 535
      return statement 262–263                            visibility of 269
   statements as 231–233                              VariablesToExport element 370
-ValueSet parameter 841, 843                          VariableValue property 817
$var variable 272                                     variant arrays 92
variable assignment, tracing 640                      VBScript 570
variable breakpoints, breaking on read or write 657       embedding code in script 784
variable checks 586                                       regular expressions 133
variable initializer expression 248                       WMI 807
variable interpolation 437                                WScript.Shell class 777
variable name notation 186                            verb-noun pairs 13
variable namespace 111, 197                           -Verbose flag 333–334, 860
variable operations 672                               version file 33
-Variable parameter 334                               version of host, obtaining 581
variable provider 583                                 -Version parameter 584
variable reference 52                                 Version property 369
variable scoping, in functions 269–274                versioning
   declaring variables 270–272                            and assemblies 721–722
   modifiers 272–274                                      managing software changes 721
variable syntax 399                                   View menu, ISE 610
variable type attribute 185                           virtual memory 916
variable: drive 672                                   virtual method 423
variables 184–197                                     VirtualMemorySize property 508
   automatic 860                                      viruses, Danom 890–891
   basic 23–25                                        visibility of variable 208, 269


INDEX                                                                                               981
Visibility property 536, 539                      matching a single character 132
Visual Basic 39, 570, 582                         matching string of characters 132
Visual Studio 610, 648, 652, 749                  using with switch statement 216–217
Visual Studio debugger 648                     wildcards 487, 612
Visual Studio SDK directory 906                   in TrustedHosts list 514
VM property 508                                   limitations constraining scripts and
VMS system 103                                       applications 540
voidable statements 156                           processing paths containing 667–668
VolumeName property 840                           suppressing processing of 668–669
vPro technologies 798                          Win32 applications, In ISE 616
vulnerability 894                              Win32_AddRemovePrograms class 806
vulnerability, defined 892                     Win32_Environment class 815–816
                                               win32_logicaldisk 29
W                                              Win32_LogicalDisk class 840
W3C (World Wide Web Consortium) 504            Win32_NetworkAdapterConfiguration class 805
Wait-Event cmdlet 854, 863–866, 877            Win32_OperatingSystem resource 834–836
Warning type 599                               Win32_Process class 819, 824, 836, 842
web pages, retrieving 740–742                  Win32_ProcessStartTrace 868, 872
Web Services-Management. See WS-Man 830        Win32_ProcessStopTrace 872
well formed string 137                         Win32_ProcessTrace 868, 872
-WhatIf parameter 108                          WIN32_ProcessTrace events 868–870
where alias 128                                Win32_Service class 872
Where-Object cmdlet 223, 225, 228–231,         WindowName property 772
   393–394, 849, 923                           Windows 7, enabling remoting 453
wheres function                                Windows calculator application 778
   original version 924                        Windows commands, native 39
   safe version 925                            Windows Console APIs, and remoting 495
wheres script                                  Windows dialog box 747
   original 923–925                            Windows Forms application 750
   safer and faster version 925–927            Windows Forms library 4
while loop 30, 203–204, 258                    Windows GUI application 778
while statement 201, 203                       Windows Management Instrumentation. See Mi-
whipupitude quotient 38                           crosoft WMI 8
whitelisting, blacklisting and 894             Windows management surface 7
whitespace 65, 201                             Windows Presentation Foundation. See WPF 753
Whitespace character class, splitting on 682   Windows server applications 798
widening                                       Windows Vista
   defined 74                                     enabling remoting 453
   rules 116, 126                              Windows XP
Width property 755                                enabling remoting 453
Wiktionary website 779                            supporting IIS-hosted remoting 530
-wildcard option 217                           windows, managing through objects 7–8
wildcard patterns                              Windows, Microsoft. See Microsoft Windows
   and -like operator 132–133                  Windows.Forms 4
   character ranges 132                        Windows() method 767, 772


982                                                                                 INDEX
-WindowStyle parameter 734                           WPIAForms module 750, 752
WindowsUpdate.log file 221                           WQL (WMI Query Language) 810
WinForms 4                                           wrapper functions, role in constrained sessions 538
winforms assembly 723, 745                           wrappers, problems in COM 793–796
WinForms library 744–750                             wrapping objects, object adaptation 423
   simple dialog boxes 747–750                       Write 657
winforms modules 750–753                             write method 581
WinRM (Windows Remote Management) 452                Write-EventLog cmdlet 597
   changing configurations 533                       Write-Host cmdlet 195, 580–581, 596, 641, 654
   restarting service 533                            Write-InputObject 356
winrm help uris command 837                          Write-Output cmdlet 39, 51, 212
WinRM listener 452                                   writing
WITHIN keyword 871                                      error objects 564
[WMI] type accelerator 826–827                          files
WMI (Windows Management Instrumentation),                  Get-Content cmdlet 674–676, 680–681
   Microsoft. See Microsoft WMI                            Get-HexDump function example 676–677
WMI Query Language (WQL) 810                               Get-MagicNumber function
WMI/CIM namespace 808                                           example 677–679
WMIC (WMI command-line) 799                             secure code 926
[WMICLASS] type accelerator 827–828                     secure scripts 916–927
WmiObject 870                                              avoiding Invoke-Expression cmdlet 923–927
[WMISEARCHER] type accelerator 825                         credentials 919–923
wof function 358                                           SecureString 916–919
Word, Microsoft. See Microsoft Word                     timer event handler 856–859
Word.Application object 783, 794                           binding event action 857–858
words                                                      creating timer object 856
   analyzing use in documents 683–684                      enabling 858–859
   counting unique with hashtables 684–686                 setting parameters 857
worker function 431                                  Writing Secure Code (Howard and LeBlanc) 892
workgroup environments, additional setup steps for   WScript.Shell class 777–779
   remoting in 451                                   WSH ScriptControl class 783–786
World Wide Web Consortium (W3C) 504                     embedding JScript code 785–786
worms, MSH/Cibyz 891                                    embedding VBScript code 784
WPF (Windows Presentation                            WS-Man (Web Services-Management) 797,
   Foundation) 753–759                                  830–846
   advantages of 758                                    cmdlets 831–832
   file search tool                                        and providers 509–511
      defining appearance 754–756                          invoking methods with Invoke-
      specifying behavior 756–758                               WSManAction 841–846
   frameworks for 758–759                                  retrieving management data with Get-
   preconditions 753                                            WSManInstance 832–839
WPF XAML GUI builders 758                                  updating resources using Set-
WPIA namespace 732                                              WSManInstance 840–841
WPIA.ConsoleUtils class 737                             Remoting protocol 504
WPIA.Utils class 737                                 WSMan configuration, TrustedHosts 511


INDEX                                                                                              983
WSMan drive 509, 524                              Select-Xml cmdlet 703
WSMan provider 451                                structured text, processing 693–718
WSMan shell 511                                   System.XML.XmlDocument class 694
WS-Man Specification 831                          System.Xml.XmlReader class 698
WSMan-based transport 493                         using as objects 693–694
wsmprovhost process 467                           XML document structure 712
wsmprovhost.exe, PowerShell remoting host         XmlNode class 695
  process 528                                   XML attributes 697
                                                XML configuration files 434
X                                               XML data 401
                                                XML Document class 695
x parameter 195
                                                XML DOM (Document Object Model) 698
$x variable 271, 416
                                                XML object adapter 694
x86 processor 500
                                                XML Path Language. See XPat 702
XAML (Extensible Application Markup Language)
                                                XML processing 663
   defining GUI in 774–775
                                                Xml property 790
   loading from here-string 776–777
                                                XML provider 664
XAML loader 758
                                                XmlDocument class 693–694
XamlReader class 776
                                                XmlDocument object 697
XDocument objects, loading from file 710
                                                XmlDocument, properties and navigation 694
XLinq
                                                XmlNode object 697
   Language Integrated Queries for XML 709
                                                XMLReader class, loading and saving files
   loading XDocument objects from file 710
                                                  using 698–701
   XDocument class 710
                                                XPath (XML Path Language)
[xml] alias 97
                                                  attribute syntax 708
XML (Extensible Markup Language)
                                                  example patterns 703
   .NET framework classes 702
                                                  predicate expression syntax 707
   adding attributes to node 696
                                                  processing XML structured text with 702–709
   adding child nodes 696
                                                     basics of 703
   bookstore inventory example 703
                                                     select-Xml cmdlet 704–709
   format-XmlDocument example 700
                                                     test document 703–704
   item property on XML object 696
                                                  used in pipeline 706
   loading XML documents 698
                                                XPath operators 708
   objects, adding elements to 695–697
                                                XSLT (Extensible Stylesheet Language Transforma-
   rendering objects as 711–718
                                                  tions) language 710
      ConvertTo-Xml cmdlet 711–714
      Import-Clixml and Export-Clixml
                                                Z
          cmdlets 714–718
   representation of new tasks 791              Zbikowski, Mark 678
   Root property on XML object 696              zone of influence 888
   saving document to file 695                  zsh shell 6, 38




984                                                                                     INDEX

				
DOCUMENT INFO
Categories:
Tags:
Stats:
views:3
posted:2/20/2013
language:Unknown
pages:56