├── .gitignore ├── Chapter01 ├── 10.0.0.1.Parser modes.ps1 ├── 10.0.0.2.Parser modes.ps1 ├── 10.0.0.3.Parser modes.ps1 ├── 10.0.0.4.Parser modes.ps1 ├── 10.0.0.5.Parser modes.ps1 ├── 11.0.0.1.Experimental features.ps1 ├── 11.0.0.2.Experimental features.ps1 ├── 11.0.0.3.Experimental features.ps1 ├── 11.0.0.4.Experimental features.ps1 ├── 11.0.0.5.Experimental features.ps1 ├── 2.0.0.1.The command line.ps1 ├── 2.0.0.2.The command line.ps1 ├── 2.0.0.3.The command line.ps1 ├── 4.1.1.1.Updatable help.ps1 ├── 4.1.1.2.Updatable help.ps1 ├── 4.2.1.1.The Get-Help command.ps1 ├── 4.2.1.2.The Get-Help command.ps1 ├── 4.2.1.3.The Get-Help command.ps1 ├── 4.2.1.4.The Get-Help command.ps1 ├── 4.2.1.5.The Get-Help command.ps1 ├── 4.2.1.6.The Get-Help command.ps1 ├── 4.2.1.7.The Get-Help command.ps1 ├── 4.2.2.1.Syntax.ps1 ├── 4.2.3.1.Examples.ps1 ├── 4.2.4.1.Parameter.ps1 ├── 4.2.5.1.Detailed and Full switches.ps1 ├── 4.3.1.1.Save-Help.ps1 ├── 4.3.1.2.Save-Help.ps1 ├── 4.3.1.3.Save-Help.ps1 ├── 4.3.1.4.Save-Help.ps1 ├── 4.3.1.5.Save-Help.ps1 ├── 4.3.1.6.Save-Help.ps1 ├── 4.4.1.1.Update-Help.ps1 ├── 4.4.1.2.Update-Help.ps1 ├── 4.4.1.3.Update-Help.ps1 ├── 4.4.1.4.Update-Help.ps1 ├── 4.4.1.5.Update-Help.ps1 ├── 4.4.1.6.Update-Help.ps1 ├── 4.5.1.1.About_ help files.ps1 ├── 4.5.1.2.About_ help files.ps1 ├── 5.1.1.1.Verbs.ps1 ├── 5.3.1.1.Finding commands.ps1 ├── 5.3.1.2.Finding commands.ps1 ├── 5.3.1.3.Finding commands.ps1 ├── 5.4.1.1.Aliases.ps1 ├── 5.4.1.2.Aliases.ps1 ├── 5.4.1.3.Aliases.ps1 ├── 5.4.1.4.Aliases.ps1 ├── 5.4.1.5.Aliases.ps1 ├── 5.4.1.6.Aliases.ps1 ├── 5.4.1.7.Aliases.ps1 ├── 5.4.1.8.Aliases.ps1 ├── 6.0.0.1.About profile scripts.ps1 ├── 6.0.0.2.About profile scripts.ps1 ├── 6.0.0.3.About profile scripts.ps1 ├── 7.1.2.1.Optional parameters.ps1 ├── 7.1.3.1.Optional positional parameters.ps1 ├── 7.1.4.1.Mandatory parameters.ps1 ├── 7.1.5.1.Mandatory positional parameters.ps1 ├── 7.1.5.2.Mandatory positional parameters.ps1 ├── 7.1.6.1.Switch parameters.ps1 ├── 7.1.6.2.Switch parameters.ps1 ├── 7.2.1.1.Parameter values.ps1 ├── 7.2.1.2.Parameter values.ps1 ├── 7.2.1.3.Parameter values.ps1 ├── 7.2.1.4.Parameter values.ps1 ├── 7.2.1.5.Parameter values.ps1 ├── 7.3.1.1.Parameter sets.ps1 ├── 7.3.1.2.Parameter sets.ps1 ├── 7.4.1.1.Common parameters.ps1 ├── 7.4.1.2.Common parameters.ps1 ├── 7.5.1.1.Confirm and WhatIf.ps1 ├── 7.5.2.1.Confirm and ConfirmPreference.ps1 ├── 7.5.2.2.Confirm and ConfirmPreference.ps1 ├── 7.5.2.3.Confirm and ConfirmPreference.ps1 ├── 7.5.2.4.Confirm and ConfirmPreference.ps1 ├── 7.5.2.5.Confirm and ConfirmPreference.ps1 ├── 7.5.2.6.Confirm and ConfirmPreference.ps1 ├── 7.5.3.1.WhatIf and WhatIfPreference.ps1 ├── 7.5.3.2.WhatIf and WhatIfPreference.ps1 ├── 7.5.3.3.WhatIf and WhatIfPreference.ps1 ├── 7.5.3.4.WhatIf and WhatIfPreference.ps1 ├── 7.6.1.1.Force parameter.ps1 ├── 7.6.1.2.Force parameter.ps1 ├── 7.6.1.3.Force parameter.ps1 ├── 7.6.1.4.Force parameter.ps1 ├── 7.7.1.1.PassThru parameter.ps1 ├── 7.7.1.2.PassThru parameter.ps1 ├── 8.0.0.1.Introduction to providers.ps1 ├── 8.0.0.10.Introduction to providers.ps1 ├── 8.0.0.2.Introduction to providers.ps1 ├── 8.0.0.3.Introduction to providers.ps1 ├── 8.0.0.4.Introduction to providers.ps1 ├── 8.0.0.5.Introduction to providers.ps1 ├── 8.0.0.6.Introduction to providers.ps1 ├── 8.0.0.7.Introduction to providers.ps1 ├── 8.0.0.8.Introduction to providers.ps1 ├── 8.0.0.9.Introduction to providers.ps1 ├── 8.1.1.1.Drives and providers.ps1 ├── 8.1.1.2.Drives and providers.ps1 ├── 8.1.1.3.Drives and providers.ps1 ├── 8.1.1.4.Drives and providers.ps1 ├── 8.1.1.5.Drives and providers.ps1 ├── 9.0.0.1.Introduction to splatting.ps1 ├── 9.0.0.2.Introduction to splatting.ps1 ├── 9.1.1.1.Splatting to avoid long lines.ps1 ├── 9.1.1.2.Splatting to avoid long lines.ps1 ├── 9.2.1.1.Conditional use of parameters.ps1 ├── 9.2.1.2.Conditional use of parameters.ps1 ├── 9.3.1.1.Splatting to avoid repetition.ps1 ├── 9.4.1.1.Splatting and positional parameters.ps1 ├── 9.4.1.2.Splatting and positional parameters.ps1 └── 9.4.1.3.Splatting and positional parameters.ps1 ├── Chapter02 ├── 1.1.1.1.The Get-Module command.ps1 ├── 1.1.1.2.The Get-Module command.ps1 ├── 1.2.1.1.The Import-Module command.ps1 ├── 1.2.1.2.The Import-Module command.ps1 ├── 1.2.1.3.The Import-Module command.ps1 ├── 1.2.1.4.The Import-Module command.ps1 ├── 1.2.1.5.The Import-Module command.ps1 ├── 1.4.1.1.PSModulePath in PowerShell.ps1 ├── 1.6.1.1.Using Windows PowerShell modules in PowerShell 7.ps1 ├── 1.6.1.10.Using Windows PowerShell modules in PowerShell 7.ps1 ├── 1.6.1.2.Using Windows PowerShell modules in PowerShell 7.ps1 ├── 1.6.1.3.Using Windows PowerShell modules in PowerShell 7.ps1 ├── 1.6.1.4.Using Windows PowerShell modules in PowerShell 7.ps1 ├── 1.6.1.5.Using Windows PowerShell modules in PowerShell 7.ps1 ├── 1.6.1.6.Using Windows PowerShell modules in PowerShell 7.ps1 ├── 1.6.1.7.Using Windows PowerShell modules in PowerShell 7.ps1 ├── 1.6.1.8.Using Windows PowerShell modules in PowerShell 7.ps1 ├── 1.6.1.9.Using Windows PowerShell modules in PowerShell 7.ps1 ├── 2.2.1.1.The Find-Module command.ps1 ├── 2.2.1.2.The Find-Module command.ps1 ├── 2.3.1.1.The Install-Module command.ps1 ├── 2.3.1.2.The Install-Module command.ps1 ├── 2.3.1.3.The Install-Module command.ps1 ├── 2.5.1.1.The Save-Module command.ps1 ├── 3.0.0.1.Microsoft.PowerShell.PSResourceGet.ps1 ├── 3.0.0.2.Microsoft.PowerShell.PSResourceGet.ps1 ├── 3.0.0.3.Microsoft.PowerShell.PSResourceGet.ps1 ├── 3.1.1.1.Repositories.ps1 ├── 3.1.1.2.Repositories.ps1 ├── 3.2.1.1.Version ranges.ps1 ├── 3.2.1.2.Version ranges.ps1 ├── 3.2.1.3.Version ranges.ps1 ├── 4.1.1.1.Creating an SMB repository.ps1 ├── 4.1.1.2.Creating an SMB repository.ps1 ├── 5.0.0.1.About snap-ins.ps1 ├── 5.0.0.2.About snap-ins.ps1 └── 5.0.0.3.About snap-ins.ps1 ├── Chapter03 ├── 1.0.0.1.Naming and creating variables.ps1 ├── 1.0.0.2.Naming and creating variables.ps1 ├── 1.0.0.3.Naming and creating variables.ps1 ├── 1.0.0.4.Naming and creating variables.ps1 ├── 1.1.1.1.Provider variables.ps1 ├── 1.1.1.2.Provider variables.ps1 ├── 1.1.1.3.Provider variables.ps1 ├── 1.1.1.4.Provider variables.ps1 ├── 2.0.0.1.Variables in strings.ps1 ├── 2.0.0.2.Variables in strings.ps1 ├── 2.0.0.3.Variables in strings.ps1 ├── 2.0.0.4.Variables in strings.ps1 ├── 2.0.0.5.Variables in strings.ps1 ├── 2.0.0.6.Variables in strings.ps1 ├── 3.0.0.1.Variable types.ps1 ├── 3.0.0.2.Variable types.ps1 ├── 3.0.0.3.Variable types.ps1 ├── 3.0.0.4.Variable types.ps1 ├── 3.0.0.5.Variable types.ps1 ├── 3.1.1.1.Assignment with types on the right.ps1 ├── 3.1.1.2.Assignment with types on the right.ps1 ├── 3.2.1.1.Assignment with types on the left.ps1 ├── 3.2.1.2.Assignment with types on the left.ps1 ├── 3.2.1.3.Assignment with types on the left.ps1 ├── 3.3.1.1.Value and reference types.ps1 ├── 3.3.1.2.Value and reference types.ps1 ├── 3.3.1.3.Value and reference types.ps1 ├── 3.3.1.4.Value and reference types.ps1 ├── 3.3.1.5.Value and reference types.ps1 ├── 3.3.1.6.Value and reference types.ps1 ├── 3.3.1.7.Value and reference types.ps1 ├── 3.4.1.1.Type conversion.ps1 ├── 3.4.1.2.Type conversion.ps1 ├── 3.4.1.3.Type conversion.ps1 ├── 4.1.1.1.Get-Variable.ps1 ├── 4.1.1.2.Get-Variable.ps1 ├── 4.1.1.3.Get-Variable.ps1 ├── 4.2.1.1.New-Variable.ps1 ├── 4.2.1.2.New-Variable.ps1 ├── 4.2.1.3.New-Variable.ps1 ├── 4.2.1.4.New-Variable.ps1 ├── 4.2.1.5.New-Variable.ps1 ├── 4.3.1.1.Set-Variable.ps1 ├── 4.3.1.2.Set-Variable.ps1 ├── 4.3.1.3.Set-Variable.ps1 ├── 4.3.1.4.Set-Variable.ps1 ├── 4.4.1.1.Remove-Variable.ps1 ├── 4.4.1.2.Remove-Variable.ps1 ├── 4.5.1.1.Clear-Variable.ps1 ├── 4.5.1.2.Clear-Variable.ps1 ├── 4.5.1.3.Clear-Variable.ps1 ├── 4.5.1.4.Clear-Variable.ps1 ├── 5.0.0.1.Variable provider.ps1 ├── 5.0.0.2.Variable provider.ps1 ├── 5.0.0.3.Variable provider.ps1 ├── 5.0.0.4.Variable provider.ps1 ├── 5.0.0.5.Variable provider.ps1 ├── 5.0.0.6.Variable provider.ps1 ├── 6.1.1.1.Accessing variables.ps1 ├── 6.1.1.2.Accessing variables.ps1 ├── 6.1.1.3.Accessing variables.ps1 ├── 6.2.1.1.Scope modifiers.ps1 ├── 6.3.1.1.Numeric scopes.ps1 ├── 6.3.1.2.Numeric scopes.ps1 ├── 6.3.1.3.Numeric scopes.ps1 ├── 6.3.1.4.Numeric scopes.ps1 ├── 6.4.1.1.Private variables.ps1 ├── 6.4.1.2.Private variables.ps1 ├── 6.4.1.3.Private variables.ps1 ├── 7.0.0.1.About arrays.ps1 ├── 7.1.1.1.Array type.ps1 ├── 7.1.1.2.Array type.ps1 ├── 7.1.1.3.Array type.ps1 ├── 7.1.1.4.Array type.ps1 ├── 7.10.1.1.Filling variables from arrays.ps1 ├── 7.10.1.2.Filling variables from arrays.ps1 ├── 7.10.1.3.Filling variables from arrays.ps1 ├── 7.10.1.4.Filling variables from arrays.ps1 ├── 7.10.1.5.Filling variables from arrays.ps1 ├── 7.10.1.6.Filling variables from arrays.ps1 ├── 7.10.1.7.Filling variables from arrays.ps1 ├── 7.11.1.1.Multi-dimensional and jagged arrays.ps1 ├── 7.11.1.2.Multi-dimensional and jagged arrays.ps1 ├── 7.11.1.3.Multi-dimensional and jagged arrays.ps1 ├── 7.11.1.4.Multi-dimensional and jagged arrays.ps1 ├── 7.11.1.5.Multi-dimensional and jagged arrays.ps1 ├── 7.2.1.1.Creation by assignment.ps1 ├── 7.2.1.2.Creation by assignment.ps1 ├── 7.3.1.1.Creating an array.ps1 ├── 7.3.1.2.Creating an array.ps1 ├── 7.3.1.3.Creating an array.ps1 ├── 7.3.1.4.Creating an array.ps1 ├── 7.3.1.5.Creating an array.ps1 ├── 7.3.1.6.Creating an array.ps1 ├── 7.3.1.7.Creating an array.ps1 ├── 7.3.1.8.Creating an array.ps1 ├── 7.4.1.1.Arrays with a type.ps1 ├── 7.4.1.2.Arrays with a type.ps1 ├── 7.4.1.3.Arrays with a type.ps1 ├── 7.5.1.1.Adding elements to an array.ps1 ├── 7.5.1.2.Adding elements to an array.ps1 ├── 7.5.1.3.Adding elements to an array.ps1 ├── 7.5.1.4.Adding elements to an array.ps1 ├── 7.5.1.5.Adding elements to an array.ps1 ├── 7.6.1.1.List and ArrayList.ps1 ├── 7.6.1.10.List and ArrayList.ps1 ├── 7.6.1.11.List and ArrayList.ps1 ├── 7.6.1.2.List and ArrayList.ps1 ├── 7.6.1.3.List and ArrayList.ps1 ├── 7.6.1.4.List and ArrayList.ps1 ├── 7.6.1.5.List and ArrayList.ps1 ├── 7.6.1.6.List and ArrayList.ps1 ├── 7.6.1.7.List and ArrayList.ps1 ├── 7.6.1.8.List and ArrayList.ps1 ├── 7.6.1.9.List and ArrayList.ps1 ├── 7.7.1.1.Selecting elements from an array.ps1 ├── 7.7.1.10.Selecting elements from an array.ps1 ├── 7.7.1.11.Selecting elements from an array.ps1 ├── 7.7.1.12.Selecting elements from an array.ps1 ├── 7.7.1.13.Selecting elements from an array.ps1 ├── 7.7.1.2.Selecting elements from an array.ps1 ├── 7.7.1.3.Selecting elements from an array.ps1 ├── 7.7.1.4.Selecting elements from an array.ps1 ├── 7.7.1.5.Selecting elements from an array.ps1 ├── 7.7.1.6.Selecting elements from an array.ps1 ├── 7.7.1.7.Selecting elements from an array.ps1 ├── 7.7.1.8.Selecting elements from an array.ps1 ├── 7.7.1.9.Selecting elements from an array.ps1 ├── 7.8.1.1.Changing element values in an array.ps1 ├── 7.8.1.2.Changing element values in an array.ps1 ├── 7.9.1.1.Removing elements.ps1 ├── 7.9.1.2.Removing elements.ps1 ├── 7.9.2.1.Removing elements by index.ps1 ├── 7.9.2.2.Removing elements by index.ps1 ├── 7.9.2.3.Removing elements by index.ps1 ├── 8.1.1.1.Creating a Hashtable.ps1 ├── 8.1.1.2.Creating a Hashtable.ps1 ├── 8.1.1.3.Creating a Hashtable.ps1 ├── 8.1.1.4.Creating a Hashtable.ps1 ├── 8.2.1.1.Adding, changing and removing keys.ps1 ├── 8.2.1.2.Adding, changing and removing keys.ps1 ├── 8.2.1.3.Adding, changing and removing keys.ps1 ├── 8.2.1.4.Adding, changing and removing keys.ps1 ├── 8.2.1.5.Adding, changing and removing keys.ps1 ├── 8.2.1.6.Adding, changing and removing keys.ps1 ├── 8.3.1.1.Using a hashtable to filter.ps1 ├── 8.3.1.2.Using a hashtable to filter.ps1 ├── 8.3.1.3.Using a hashtable to filter.ps1 ├── 8.3.1.4.Using a hashtable to filter.ps1 ├── 8.3.1.5.Using a hashtable to filter.ps1 ├── 8.3.1.6.Using a hashtable to filter.ps1 ├── 8.3.1.7.Using a hashtable to filter.ps1 ├── 8.3.1.8.Using a hashtable to filter.ps1 ├── 8.4.1.1.Enumerating a Hashtable.ps1 ├── 8.4.1.2.Enumerating a Hashtable.ps1 ├── 8.4.1.3.Enumerating a Hashtable.ps1 ├── 8.4.1.4.Enumerating a Hashtable.ps1 ├── 8.4.1.5.Enumerating a Hashtable.ps1 ├── 8.4.1.6.Enumerating a Hashtable.ps1 ├── 8.4.1.7.Enumerating a Hashtable.ps1 ├── 9.0.0.1.About Ordered.ps1 ├── 9.0.0.2.About Ordered.ps1 ├── 9.0.0.3.About Ordered.ps1 ├── 9.0.0.4.About Ordered.ps1 ├── 9.0.0.5.About Ordered.ps1 └── 9.0.0.6.About Ordered.ps1 ├── Chapter04 ├── 1.1.1.1.Standard output.ps1 ├── 1.2.1.1.Non-standard output.ps1 ├── 1.2.1.2.Non-standard output.ps1 ├── 1.3.1.1.The object pipeline.ps1 ├── 1.3.1.2.The object pipeline.ps1 ├── 1.3.1.3.The object pipeline.ps1 ├── 2.1.1.1.The Get-Member command.ps1 ├── 2.1.1.2.The Get-Member command.ps1 ├── 2.1.1.3.The Get-Member command.ps1 ├── 2.2.1.1.Accessing object properties.ps1 ├── 2.2.1.2.Accessing object properties.ps1 ├── 2.2.1.3.Accessing object properties.ps1 ├── 2.2.1.4.Accessing object properties.ps1 ├── 2.2.1.5.Accessing object properties.ps1 ├── 2.2.1.6.Accessing object properties.ps1 ├── 2.2.1.7.Accessing object properties.ps1 ├── 2.3.1.1.Access modifiers.ps1 ├── 2.3.1.2.Access modifiers.ps1 ├── 2.3.1.3.Access modifiers.ps1 ├── 2.3.1.4.Access modifiers.ps1 ├── 2.3.1.5.Access modifiers.ps1 ├── 2.4.1.1.Using methods.ps1 ├── 2.4.1.10.Using methods.ps1 ├── 2.4.1.11.Using methods.ps1 ├── 2.4.1.12.Using methods.ps1 ├── 2.4.1.13.Using methods.ps1 ├── 2.4.1.2.Using methods.ps1 ├── 2.4.1.3.Using methods.ps1 ├── 2.4.1.4.Using methods.ps1 ├── 2.4.1.5.Using methods.ps1 ├── 2.4.1.6.Using methods.ps1 ├── 2.4.1.7.Using methods.ps1 ├── 2.4.1.8.Using methods.ps1 ├── 2.4.1.9.Using methods.ps1 ├── 2.4.2.1.Return types and argument types.ps1 ├── 2.4.2.2.Return types and argument types.ps1 ├── 2.4.2.3.Return types and argument types.ps1 ├── 2.5.2.1.Using PSCustomObject.ps1 ├── 2.5.2.2.Using PSCustomObject.ps1 ├── 2.5.2.3.Using PSCustomObject.ps1 ├── 2.5.2.4.Using PSCustomObject.ps1 ├── 2.5.3.1.The New-Object command.ps1 ├── 2.6.1.1.The Add-Member command.ps1 ├── 2.6.1.2.The Add-Member command.ps1 ├── 2.6.2.1.Add-Member and custom objects.ps1 ├── 2.6.2.2.Add-Member and custom objects.ps1 ├── 2.6.2.3.Add-Member and custom objects.ps1 ├── 2.6.2.4.Add-Member and custom objects.ps1 ├── 3.0.0.1.Enumerating and filtering.ps1 ├── 3.1.1.1.The ForEach-Object command.ps1 ├── 3.1.1.2.The ForEach-Object command.ps1 ├── 3.1.2.1.Begin and End parameters.ps1 ├── 3.1.2.2.Begin and End parameters.ps1 ├── 3.1.3.1.The Parallel parameter.ps1 ├── 3.1.3.2.The Parallel parameter.ps1 ├── 3.1.3.3.The Parallel parameter.ps1 ├── 3.1.3.4.The Parallel parameter.ps1 ├── 3.1.3.5.The Parallel parameter.ps1 ├── 3.1.3.6.The Parallel parameter.ps1 ├── 3.1.3.7.The Parallel parameter.ps1 ├── 3.1.4.1.The MemberName parameter.ps1 ├── 3.1.4.2.The MemberName parameter.ps1 ├── 3.1.4.3.The MemberName parameter.ps1 ├── 3.2.1.1.The Where-Object command.ps1 ├── 3.2.1.2.The Where-Object command.ps1 ├── 3.2.1.3.The Where-Object command.ps1 ├── 4.1.1.1.The Select-Object command.ps1 ├── 4.1.1.10.The Select-Object command.ps1 ├── 4.1.1.11.The Select-Object command.ps1 ├── 4.1.1.2.The Select-Object command.ps1 ├── 4.1.1.3.The Select-Object command.ps1 ├── 4.1.1.4.The Select-Object command.ps1 ├── 4.1.1.5.The Select-Object command.ps1 ├── 4.1.1.6.The Select-Object command.ps1 ├── 4.1.1.7.The Select-Object command.ps1 ├── 4.1.1.8.The Select-Object command.ps1 ├── 4.1.1.9.The Select-Object command.ps1 ├── 4.1.2.1.Calculated properties.ps1 ├── 4.1.2.2.Calculated properties.ps1 ├── 4.1.2.3.Calculated properties.ps1 ├── 4.1.2.4.Calculated properties.ps1 ├── 4.1.2.5.Calculated properties.ps1 ├── 4.1.2.6.Calculated properties.ps1 ├── 4.1.3.1.The ExpandProperty parameter.ps1 ├── 4.1.3.2.The ExpandProperty parameter.ps1 ├── 4.1.3.3.The ExpandProperty parameter.ps1 ├── 4.1.3.4.The ExpandProperty parameter.ps1 ├── 4.1.4.1.The Unique parameter.ps1 ├── 4.1.4.2.The Unique parameter.ps1 ├── 4.1.4.3.The Unique parameter.ps1 ├── 4.1.4.4.The Unique parameter.ps1 ├── 4.1.5.1.Property sets.ps1 ├── 4.1.5.2.Property sets.ps1 ├── 4.2.1.1.The Sort-Object command.ps1 ├── 4.2.1.2.The Sort-Object command.ps1 ├── 4.2.1.3.The Sort-Object command.ps1 ├── 4.2.1.4.The Sort-Object command.ps1 ├── 4.2.1.5.The Sort-Object command.ps1 ├── 4.2.1.6.The Sort-Object command.ps1 ├── 4.2.1.7.The Sort-Object command.ps1 ├── 4.2.1.8.The Sort-Object command.ps1 ├── 4.2.2.1.The Unique parameter.ps1 ├── 5.1.1.1.The Group-Object command.ps1 ├── 5.1.1.10.The Group-Object command.ps1 ├── 5.1.1.2.The Group-Object command.ps1 ├── 5.1.1.3.The Group-Object command.ps1 ├── 5.1.1.4.The Group-Object command.ps1 ├── 5.1.1.5.The Group-Object command.ps1 ├── 5.1.1.6.The Group-Object command.ps1 ├── 5.1.1.7.The Group-Object command.ps1 ├── 5.1.1.8.The Group-Object command.ps1 ├── 5.1.1.9.The Group-Object command.ps1 ├── 5.2.1.1.The Measure-Object command.ps1 ├── 5.2.1.2.The Measure-Object command.ps1 ├── 5.2.1.3.The Measure-Object command.ps1 ├── 5.2.1.4.The Measure-Object command.ps1 ├── 5.2.1.5.The Measure-Object command.ps1 ├── 6.0.0.1.Comparing.ps1 ├── 6.0.0.2.Comparing.ps1 ├── 6.0.0.3.Comparing.ps1 ├── 6.0.0.4.Comparing.ps1 ├── 6.0.0.5.Comparing.ps1 ├── 6.0.0.6.Comparing.ps1 ├── 6.0.0.7.Comparing.ps1 ├── 7.1.1.1.The Export-Csv command.ps1 ├── 7.1.1.10.The Export-Csv command.ps1 ├── 7.1.1.11.The Export-Csv command.ps1 ├── 7.1.1.2.The Export-Csv command.ps1 ├── 7.1.1.3.The Export-Csv command.ps1 ├── 7.1.1.4.The Export-Csv command.ps1 ├── 7.1.1.5.The Export-Csv command.ps1 ├── 7.1.1.6.The Export-Csv command.ps1 ├── 7.1.1.7.The Export-Csv command.ps1 ├── 7.1.1.8.The Export-Csv command.ps1 ├── 7.1.1.9.The Export-Csv command.ps1 ├── 7.2.1.1.The Import-Csv command.ps1 ├── 7.2.1.2.The Import-Csv command.ps1 ├── 7.2.1.3.The Import-Csv command.ps1 ├── 7.2.1.4.The Import-Csv command.ps1 ├── 7.2.1.5.The Import-Csv command.ps1 ├── 7.2.1.6.The Import-Csv command.ps1 ├── 7.3.1.1.Export-Clixml and Import-Clixml.ps1 ├── 7.3.1.2.Export-Clixml and Import-Clixml.ps1 ├── 7.3.1.3.Export-Clixml and Import-Clixml.ps1 ├── 7.3.1.4.Export-Clixml and Import-Clixml.ps1 ├── 7.3.1.5.Export-Clixml and Import-Clixml.ps1 ├── 7.3.1.6.Export-Clixml and Import-Clixml.ps1 ├── 7.3.1.7.Export-Clixml and Import-Clixml.ps1 ├── 7.4.1.1.The Tee-Object command.ps1 ├── 7.4.1.2.The Tee-Object command.ps1 ├── 7.4.1.3.The Tee-Object command.ps1 ├── 8.1.1.1.Formatting and exporting.ps1 ├── 8.2.1.1.The Format-Table command.ps1 ├── 8.2.1.2.The Format-Table command.ps1 ├── 8.2.1.3.The Format-Table command.ps1 ├── 8.2.1.4.The Format-Table command.ps1 ├── 8.2.1.5.The Format-Table command.ps1 ├── 8.2.1.6.The Format-Table command.ps1 ├── 8.3.1.1.The Format-List command.ps1 ├── 8.3.1.2.The Format-List command.ps1 ├── 8.3.1.3.The Format-List command.ps1 ├── 8.4.1.1.Select-Object, Write-Host, and inline output.ps1 ├── 8.4.1.2.Select-Object, Write-Host, and inline output.ps1 ├── 8.4.1.3.Select-Object, Write-Host, and inline output.ps1 ├── 8.5.1.1.Format-only properties.ps1 ├── 8.5.1.2.Format-only properties.ps1 ├── 8.5.1.3.Format-only properties.ps1 ├── 8.5.1.4.Format-only properties.ps1 ├── 8.5.1.5.Format-only properties.ps1 ├── 8.5.1.6.Format-only properties.ps1 ├── 8.5.1.7.Format-only properties.ps1 └── 8.5.1.8.Format-only properties.ps1 ├── Chapter05 ├── 1.1.1.1.Operator precedence.ps1 ├── 1.1.1.2.Operator precedence.ps1 ├── 1.2.1.1.Grouping.ps1 ├── 1.2.1.2.Grouping.ps1 ├── 1.3.1.1.Sub-expression operator.ps1 ├── 1.3.1.2.Sub-expression operator.ps1 ├── 1.3.1.3.Sub-expression operator.ps1 ├── 1.4.1.1.Array sub-expression operator.ps1 ├── 1.4.1.2.Array sub-expression operator.ps1 ├── 1.4.1.3.Array sub-expression operator.ps1 ├── 10.0.0.1.Redirection operators.ps1 ├── 10.2.1.1.Redirection to a file.ps1 ├── 10.2.1.2.Redirection to a file.ps1 ├── 10.2.1.3.Redirection to a file.ps1 ├── 10.2.1.4.Redirection to a file.ps1 ├── 10.4.1.1.Redirecting streams to standard output.ps1 ├── 10.4.1.2.Redirecting streams to standard output.ps1 ├── 10.4.1.3.Redirecting streams to standard output.ps1 ├── 10.5.1.1.Redirection to null.ps1 ├── 10.5.1.2.Redirection to null.ps1 ├── 11.1.1.1.Comma.ps1 ├── 11.1.1.2.Comma.ps1 ├── 11.10.1.1.Background.ps1 ├── 11.10.1.2.Background.ps1 ├── 11.10.1.3.Background.ps1 ├── 11.2.1.1.Index.ps1 ├── 11.2.1.2.Index.ps1 ├── 11.2.1.3.Index.ps1 ├── 11.2.1.4.Index.ps1 ├── 11.3.1.1.Range.ps1 ├── 11.3.1.2.Range.ps1 ├── 11.3.1.3.Range.ps1 ├── 11.3.1.4.Range.ps1 ├── 11.3.1.5.Range.ps1 ├── 11.4.1.1.Call.ps1 ├── 11.4.1.2.Call.ps1 ├── 11.4.1.3.Call.ps1 ├── 11.4.1.4.Call.ps1 ├── 11.4.1.5.Call.ps1 ├── 11.5.1.1.Format.ps1 ├── 11.5.1.10.Format.ps1 ├── 11.5.1.11.Format.ps1 ├── 11.5.1.12.Format.ps1 ├── 11.5.1.2.Format.ps1 ├── 11.5.1.3.Format.ps1 ├── 11.5.1.4.Format.ps1 ├── 11.5.1.5.Format.ps1 ├── 11.5.1.6.Format.ps1 ├── 11.5.1.7.Format.ps1 ├── 11.5.1.8.Format.ps1 ├── 11.5.1.9.Format.ps1 ├── 11.6.1.1.join.ps1 ├── 11.6.1.2.join.ps1 ├── 11.7.1.1.Null coalescing.ps1 ├── 11.7.1.2.Null coalescing.ps1 ├── 11.7.1.3.Null coalescing.ps1 ├── 11.7.1.4.Null coalescing.ps1 ├── 11.7.1.5.Null coalescing.ps1 ├── 11.7.1.6.Null coalescing.ps1 ├── 11.7.2.1.Null coalescing assignment.ps1 ├── 11.7.2.2.Null coalescing assignment.ps1 ├── 11.7.2.3.Null coalescing assignment.ps1 ├── 11.7.2.4.Null coalescing assignment.ps1 ├── 11.8.1.1.Null conditional.ps1 ├── 11.8.1.2.Null conditional.ps1 ├── 11.8.1.3.Null conditional.ps1 ├── 11.8.1.4.Null conditional.ps1 ├── 11.8.1.5.Null conditional.ps1 ├── 11.8.1.6.Null conditional.ps1 ├── 11.9.1.1.Pipeline chain.ps1 ├── 11.9.1.2.Pipeline chain.ps1 ├── 11.9.1.3.Pipeline chain.ps1 ├── 11.9.1.4.Pipeline chain.ps1 ├── 11.9.1.5.Pipeline chain.ps1 ├── 11.9.1.6.Pipeline chain.ps1 ├── 11.9.1.7.Pipeline chain.ps1 ├── 2.0.0.1.Unary, Binary, and Ternary operators.ps1 ├── 2.0.0.2.Unary, Binary, and Ternary operators.ps1 ├── 2.0.0.3.Unary, Binary, and Ternary operators.ps1 ├── 2.1.1.1.About the ternary operator.ps1 ├── 2.1.1.2.About the ternary operator.ps1 ├── 2.1.1.3.About the ternary operator.ps1 ├── 3.1.1.1.Addition operator.ps1 ├── 3.1.1.10.Addition operator.ps1 ├── 3.1.1.11.Addition operator.ps1 ├── 3.1.1.12.Addition operator.ps1 ├── 3.1.1.13.Addition operator.ps1 ├── 3.1.1.14.Addition operator.ps1 ├── 3.1.1.2.Addition operator.ps1 ├── 3.1.1.3.Addition operator.ps1 ├── 3.1.1.4.Addition operator.ps1 ├── 3.1.1.5.Addition operator.ps1 ├── 3.1.1.6.Addition operator.ps1 ├── 3.1.1.7.Addition operator.ps1 ├── 3.1.1.8.Addition operator.ps1 ├── 3.1.1.9.Addition operator.ps1 ├── 3.2.1.1.Subtraction operator.ps1 ├── 3.2.1.2.Subtraction operator.ps1 ├── 3.3.1.1.Multiplication operator.ps1 ├── 3.3.1.2.Multiplication operator.ps1 ├── 3.3.1.3.Multiplication operator.ps1 ├── 3.3.1.4.Multiplication operator.ps1 ├── 3.4.1.1.Division operator.ps1 ├── 3.4.1.2.Division operator.ps1 ├── 3.5.1.1.Remainder operator.ps1 ├── 3.5.1.2.Remainder operator.ps1 ├── 3.6.1.1.Increment and decrement operators.ps1 ├── 3.6.1.2.Increment and decrement operators.ps1 ├── 3.6.1.3.Increment and decrement operators.ps1 ├── 3.6.1.4.Increment and decrement operators.ps1 ├── 3.6.1.5.Increment and decrement operators.ps1 ├── 3.6.1.6.Increment and decrement operators.ps1 ├── 3.6.1.7.Increment and decrement operators.ps1 ├── 3.6.1.8.Increment and decrement operators.ps1 ├── 3.6.1.9.Increment and decrement operators.ps1 ├── 4.1.1.1.eq and ne.ps1 ├── 4.1.1.2.eq and ne.ps1 ├── 4.1.1.3.eq and ne.ps1 ├── 4.1.1.4.eq and ne.ps1 ├── 4.1.1.5.eq and ne.ps1 ├── 4.1.1.6.eq and ne.ps1 ├── 4.1.1.7.eq and ne.ps1 ├── 4.1.1.8.eq and ne.ps1 ├── 4.2.1.1.like and notlike.ps1 ├── 4.2.1.2.like and notlike.ps1 ├── 4.2.1.3.like and notlike.ps1 ├── 4.2.1.4.like and notlike.ps1 ├── 4.2.1.5.like and notlike.ps1 ├── 4.2.1.6.like and notlike.ps1 ├── 4.2.1.7.like and notlike.ps1 ├── 4.2.1.8.like and notlike.ps1 ├── 4.3.1.1.Greater than and less than.ps1 ├── 4.3.1.2.Greater than and less than.ps1 ├── 4.3.1.3.Greater than and less than.ps1 ├── 4.4.1.1.Case sensitivity.ps1 ├── 4.4.1.2.Case sensitivity.ps1 ├── 4.4.1.3.Case sensitivity.ps1 ├── 4.5.1.1.Comparison operators and arrays.ps1 ├── 4.5.1.2.Comparison operators and arrays.ps1 ├── 4.5.1.3.Comparison operators and arrays.ps1 ├── 4.5.1.4.Comparison operators and arrays.ps1 ├── 4.5.1.5.Comparison operators and arrays.ps1 ├── 4.5.1.6.Comparison operators and arrays.ps1 ├── 4.5.1.7.Comparison operators and arrays.ps1 ├── 4.6.1.1.Comparisons to null.ps1 ├── 4.6.1.2.Comparisons to null.ps1 ├── 4.6.1.3.Comparisons to null.ps1 ├── 4.6.1.4.Comparisons to null.ps1 ├── 4.7.1.1.contains and in.ps1 ├── 4.7.1.2.contains and in.ps1 ├── 5.1.1.1.match and notmatch.ps1 ├── 5.1.1.2.match and notmatch.ps1 ├── 5.1.1.3.match and notmatch.ps1 ├── 5.1.1.4.match and notmatch.ps1 ├── 5.1.1.5.match and notmatch.ps1 ├── 5.2.1.1.replace.ps1 ├── 5.2.1.2.replace.ps1 ├── 5.2.1.3.replace.ps1 ├── 5.2.1.4.replace.ps1 ├── 5.2.1.5.replace.ps1 ├── 5.2.1.6.replace.ps1 ├── 5.2.1.7.replace.ps1 ├── 5.2.1.8.replace.ps1 ├── 5.2.1.9.replace.ps1 ├── 5.3.1.1.split.ps1 ├── 5.3.1.2.split.ps1 ├── 5.3.1.3.split.ps1 ├── 5.3.1.4.split.ps1 ├── 5.3.1.5.split.ps1 ├── 5.3.1.6.split.ps1 ├── 5.3.1.7.split.ps1 ├── 5.3.1.8.split.ps1 ├── 5.3.1.9.split.ps1 ├── 6.1.1.1.and.ps1 ├── 6.2.1.1.or.ps1 ├── 6.3.1.1.not.ps1 ├── 6.3.1.2.not.ps1 ├── 6.3.1.3.not.ps1 ├── 6.3.1.4.not.ps1 ├── 6.4.1.1.xor (eXclusive OR).ps1 ├── 7.0.0.1.Bitwise operators.ps1 ├── 7.0.0.2.Bitwise operators.ps1 ├── 7.0.0.3.Bitwise operators.ps1 ├── 7.1.1.1.band (Bitwise AND).ps1 ├── 7.2.1.1.bor (Bitwise OR).ps1 ├── 7.3.1.1.bxor (Bitwise eXclusive OR).ps1 ├── 7.3.1.2.bxor (Bitwise eXclusive OR).ps1 ├── 7.4.1.1.bnot (Bitwise NOT).ps1 ├── 7.5.1.1.shl and shr (Shift left and right operators).ps1 ├── 7.5.1.2.shl and shr (Shift left and right operators).ps1 ├── 7.5.1.3.shl and shr (Shift left and right operators).ps1 ├── 7.5.1.4.shl and shr (Shift left and right operators).ps1 ├── 7.5.1.5.shl and shr (Shift left and right operators).ps1 ├── 7.5.1.6.shl and shr (Shift left and right operators).ps1 ├── 7.5.1.7.shl and shr (Shift left and right operators).ps1 ├── 7.5.1.8.shl and shr (Shift left and right operators).ps1 ├── 8.1.1.1.Assign, add and assign, and subtract and assign.ps1 ├── 8.1.1.10.Assign, add and assign, and subtract and assign.ps1 ├── 8.1.1.2.Assign, add and assign, and subtract and assign.ps1 ├── 8.1.1.3.Assign, add and assign, and subtract and assign.ps1 ├── 8.1.1.4.Assign, add and assign, and subtract and assign.ps1 ├── 8.1.1.5.Assign, add and assign, and subtract and assign.ps1 ├── 8.1.1.6.Assign, add and assign, and subtract and assign.ps1 ├── 8.1.1.7.Assign, add and assign, and subtract and assign.ps1 ├── 8.1.1.8.Assign, add and assign, and subtract and assign.ps1 ├── 8.1.1.9.Assign, add and assign, and subtract and assign.ps1 ├── 8.2.1.1.Multiply and assign, divide and assign, and modulus and assign.ps1 ├── 8.2.1.2.Multiply and assign, divide and assign, and modulus and assign.ps1 ├── 8.2.1.3.Multiply and assign, divide and assign, and modulus and assign.ps1 ├── 8.2.1.4.Multiply and assign, divide and assign, and modulus and assign.ps1 ├── 8.2.1.5.Multiply and assign, divide and assign, and modulus and assign.ps1 ├── 8.2.1.6.Multiply and assign, divide and assign, and modulus and assign.ps1 ├── 8.2.1.7.Multiply and assign, divide and assign, and modulus and assign.ps1 ├── 8.3.1.1.Statements can be assigned to a variable.ps1 ├── 8.4.1.1.Assignment and other operators.ps1 ├── 8.4.1.2.Assignment and other operators.ps1 ├── 8.4.1.3.Assignment and other operators.ps1 ├── 9.1.1.1.as.ps1 ├── 9.1.1.2.as.ps1 ├── 9.1.1.3.as.ps1 └── 9.2.1.1.is and isnot.ps1 ├── Chapter06 ├── 1.0.0.1.if, else, and elseif.ps1 ├── 1.1.1.1.Assignment within If statements.ps1 ├── 1.1.1.2.Assignment within If statements.ps1 ├── 2.0.0.1.Implicit Boolean.ps1 ├── 2.0.0.2.Implicit Boolean.ps1 ├── 3.0.0.1.Switch statement.ps1 ├── 3.1.1.1.Switch and arrays.ps1 ├── 3.1.1.2.Switch and arrays.ps1 ├── 3.1.1.3.Switch and arrays.ps1 ├── 3.3.1.1.Wildcard and Regex parameters.ps1 ├── 3.3.1.2.Wildcard and Regex parameters.ps1 ├── 3.4.1.1.Script block cases.ps1 ├── 3.4.1.2.Script block cases.ps1 ├── 3.4.1.3.Script block cases.ps1 ├── 3.4.1.4.Script block cases.ps1 ├── 3.5.1.1.Switch and Enum.ps1 ├── 3.5.1.2.Switch and Enum.ps1 ├── 3.5.1.3.Switch and Enum.ps1 ├── 3.5.1.4.Switch and Enum.ps1 ├── 3.5.1.5.Switch and Enum.ps1 ├── 4.0.0.1.Switch, break, and continue.ps1 ├── 4.0.0.2.Switch, break, and continue.ps1 ├── 4.0.0.3.Switch, break, and continue.ps1 ├── 4.0.0.4.Switch, break, and continue.ps1 ├── 4.0.0.5.Switch, break, and continue.ps1 ├── 5.1.1.1.foreach loop.ps1 ├── 5.1.2.1.ForEach keyword and ForEach alias.ps1 ├── 5.1.2.2.ForEach keyword and ForEach alias.ps1 ├── 5.2.1.1.For loop.ps1 ├── 5.2.1.2.For loop.ps1 ├── 5.2.1.3.For loop.ps1 ├── 5.2.1.4.For loop.ps1 ├── 5.2.1.5.For loop.ps1 ├── 5.2.1.6.For loop.ps1 ├── 5.2.1.7.For loop.ps1 ├── 5.3.1.1.do-until and do-while loops.ps1 ├── 5.3.1.2.do-until and do-while loops.ps1 ├── 5.3.1.3.do-until and do-while loops.ps1 ├── 5.3.1.4.do-until and do-while loops.ps1 ├── 5.3.1.5.do-until and do-while loops.ps1 ├── 5.4.1.1.while loop.ps1 ├── 5.4.1.2.while loop.ps1 ├── 6.0.0.1.Loops, break, and continue.ps1 ├── 6.0.0.2.Loops, break, and continue.ps1 ├── 6.0.0.3.Loops, break, and continue.ps1 ├── 6.0.0.4.Loops, break, and continue.ps1 ├── 6.1.1.1.break and continue outside loops.ps1 ├── 6.1.1.2.break and continue outside loops.ps1 ├── 7.0.0.1.Loops and labels.ps1 ├── 7.0.0.2.Loops and labels.ps1 ├── 7.0.0.3.Loops and labels.ps1 ├── 8.0.0.1.Loops, Queues, and Stacks.ps1 ├── 8.0.0.2.Loops, Queues, and Stacks.ps1 ├── 8.0.0.3.Loops, Queues, and Stacks.ps1 ├── 8.0.0.4.Loops, Queues, and Stacks.ps1 ├── 8.0.0.5.Loops, Queues, and Stacks.ps1 ├── 8.0.0.6.Loops, Queues, and Stacks.ps1 └── 8.0.0.7.Loops, Queues, and Stacks.ps1 ├── Chapter07 ├── 1.0.0.1.Assemblies.ps1 ├── 1.0.0.2.Assemblies.ps1 ├── 1.0.0.3.Assemblies.ps1 ├── 1.0.0.4.Assemblies.ps1 ├── 1.0.0.5.Assemblies.ps1 ├── 1.0.0.6.Assemblies.ps1 ├── 1.1.1.1.About the Global Assembly Cache.ps1 ├── 1.1.1.2.About the Global Assembly Cache.ps1 ├── 1.1.1.3.About the Global Assembly Cache.ps1 ├── 2.0.0.1.Types.ps1 ├── 2.0.0.2.Types.ps1 ├── 2.0.0.3.Types.ps1 ├── 2.1.1.1.Type descriptions are objects in PowerShell.ps1 ├── 2.2.1.1.Enumerations.ps1 ├── 2.2.1.2.Enumerations.ps1 ├── 2.4.1.1.Namespaces.ps1 ├── 2.4.1.2.Namespaces.ps1 ├── 2.4.1.3.Namespaces.ps1 ├── 3.1.1.1.Using namespaces.ps1 ├── 3.1.1.2.Using namespaces.ps1 ├── 3.1.1.3.Using namespaces.ps1 ├── 3.1.1.4.Using namespaces.ps1 ├── 3.1.1.5.Using namespaces.ps1 ├── 3.1.1.6.Using namespaces.ps1 ├── 3.1.1.7.Using namespaces.ps1 ├── 3.2.1.1.Using assemblies.ps1 ├── 3.2.1.2.Using assemblies.ps1 ├── 4.0.0.1.Type accelerators.ps1 ├── 4.0.0.2.Type accelerators.ps1 ├── 4.0.0.3.Type accelerators.ps1 ├── 4.0.0.4.Type accelerators.ps1 ├── 4.1.1.1.About PSCustomObject and Ordered.ps1 ├── 4.1.1.2.About PSCustomObject and Ordered.ps1 ├── 4.1.1.3.About PSCustomObject and Ordered.ps1 ├── 4.1.1.4.About PSCustomObject and Ordered.ps1 ├── 4.1.1.5.About PSCustomObject and Ordered.ps1 ├── 4.1.1.6.About PSCustomObject and Ordered.ps1 ├── 4.1.1.7.About PSCustomObject and Ordered.ps1 ├── 4.1.1.8.About PSCustomObject and Ordered.ps1 ├── 5.1.1.1.Constructors.ps1 ├── 5.1.1.2.Constructors.ps1 ├── 5.1.1.3.Constructors.ps1 ├── 5.2.1.1.Properties.ps1 ├── 5.2.1.2.Properties.ps1 ├── 5.2.1.3.Properties.ps1 ├── 5.3.1.1.Methods.ps1 ├── 5.3.1.2.Methods.ps1 ├── 5.3.1.3.Methods.ps1 ├── 5.3.1.4.Methods.ps1 ├── 5.3.1.5.Methods.ps1 ├── 5.3.2.1.Fluent interfaces.ps1 ├── 5.3.2.2.Fluent interfaces.ps1 ├── 5.3.2.3.Fluent interfaces.ps1 ├── 5.3.3.1.Static methods.ps1 ├── 5.3.3.2.Static methods.ps1 ├── 5.3.3.3.Static methods.ps1 ├── 5.3.3.4.Static methods.ps1 ├── 5.3.4.1.About the new() method.ps1 ├── 5.3.4.2.About the new() method.ps1 ├── 5.4.1.1.Static properties.ps1 ├── 5.4.1.2.Static properties.ps1 ├── 6.1.1.1.The TypeAccelerators type.ps1 ├── 6.1.1.2.The TypeAccelerators type.ps1 ├── 6.1.1.3.The TypeAccelerators type.ps1 ├── 6.1.1.4.The TypeAccelerators type.ps1 ├── 6.1.1.5.The TypeAccelerators type.ps1 ├── 6.1.1.6.The TypeAccelerators type.ps1 ├── 6.1.1.7.The TypeAccelerators type.ps1 ├── 6.2.1.1.The ArgumentTypeConverterAttribute type.ps1 ├── 6.2.1.10.The ArgumentTypeConverterAttribute type.ps1 ├── 6.2.1.11.The ArgumentTypeConverterAttribute type.ps1 ├── 6.2.1.2.The ArgumentTypeConverterAttribute type.ps1 ├── 6.2.1.3.The ArgumentTypeConverterAttribute type.ps1 ├── 6.2.1.4.The ArgumentTypeConverterAttribute type.ps1 ├── 6.2.1.5.The ArgumentTypeConverterAttribute type.ps1 ├── 6.2.1.6.The ArgumentTypeConverterAttribute type.ps1 ├── 6.2.1.7.The ArgumentTypeConverterAttribute type.ps1 ├── 6.2.1.8.The ArgumentTypeConverterAttribute type.ps1 ├── 6.2.1.9.The ArgumentTypeConverterAttribute type.ps1 ├── 7.1.1.1.Generic classes.ps1 ├── 7.1.1.2.Generic classes.ps1 ├── 7.1.1.3.Generic classes.ps1 ├── 7.1.1.4.Generic classes.ps1 ├── 7.2.1.1.Generic methods.ps1 ├── 7.2.1.2.Generic methods.ps1 ├── 7.2.1.3.Generic methods.ps1 ├── 7.2.1.4.Generic methods.ps1 └── 7.2.1.5.Generic methods.ps1 ├── Chapter08 ├── 1.1.1.1.Indexing into strings.ps1 ├── 1.1.1.2.Indexing into strings.ps1 ├── 1.1.1.3.Indexing into strings.ps1 ├── 1.1.1.4.Indexing into strings.ps1 ├── 1.10.1.1.Contains, StartsWith, and EndsWith.ps1 ├── 1.10.1.2.Contains, StartsWith, and EndsWith.ps1 ├── 1.10.1.3.Contains, StartsWith, and EndsWith.ps1 ├── 1.2.1.1.Substring.ps1 ├── 1.2.1.2.Substring.ps1 ├── 1.2.1.3.Substring.ps1 ├── 1.2.1.4.Substring.ps1 ├── 1.2.1.5.Substring.ps1 ├── 1.2.1.6.Substring.ps1 ├── 1.3.1.1.Split.ps1 ├── 1.3.1.2.Split.ps1 ├── 1.3.1.3.Split.ps1 ├── 1.3.1.4.Split.ps1 ├── 1.3.1.5.Split.ps1 ├── 1.3.1.6.Split.ps1 ├── 1.3.1.7.Split.ps1 ├── 1.3.1.8.Split.ps1 ├── 1.3.1.9.Split.ps1 ├── 1.4.1.1.Replace.ps1 ├── 1.4.1.2.Replace.ps1 ├── 1.4.1.3.Replace.ps1 ├── 1.4.1.4.Replace.ps1 ├── 1.4.1.5.Replace.ps1 ├── 1.5.1.1.Trim, TrimStart, and TrimEnd.ps1 ├── 1.5.1.2.Trim, TrimStart, and TrimEnd.ps1 ├── 1.5.1.3.Trim, TrimStart, and TrimEnd.ps1 ├── 1.5.1.4.Trim, TrimStart, and TrimEnd.ps1 ├── 1.6.1.1.Insert and Remove.ps1 ├── 1.6.1.2.Insert and Remove.ps1 ├── 1.6.1.3.Insert and Remove.ps1 ├── 1.7.1.1.IndexOf and LastIndexOf.ps1 ├── 1.7.1.2.IndexOf and LastIndexOf.ps1 ├── 1.7.1.3.IndexOf and LastIndexOf.ps1 ├── 1.8.1.1.PadLeft and PadRight.ps1 ├── 1.8.1.2.PadLeft and PadRight.ps1 ├── 1.8.1.3.PadLeft and PadRight.ps1 ├── 1.8.1.4.PadLeft and PadRight.ps1 ├── 1.9.1.1.ToUpper, ToLower, and ToTitleCase.ps1 ├── 1.9.1.2.ToUpper, ToLower, and ToTitleCase.ps1 ├── 1.9.1.3.ToUpper, ToLower, and ToTitleCase.ps1 ├── 1.9.1.4.ToUpper, ToLower, and ToTitleCase.ps1 ├── 2.0.0.1.String methods and arrays.ps1 ├── 2.0.0.2.String methods and arrays.ps1 ├── 2.1.1.1.Properties and methods of array elements.ps1 ├── 2.1.1.2.Properties and methods of array elements.ps1 ├── 2.1.1.3.Properties and methods of array elements.ps1 ├── 2.2.1.1.Chaining methods.ps1 ├── 2.2.1.2.Chaining methods.ps1 ├── 2.2.1.3.Chaining methods.ps1 ├── 2.2.1.4.Chaining methods.ps1 ├── 2.2.1.5.Chaining methods.ps1 ├── 3.1.2.1.CSV header.ps1 ├── 3.1.2.2.CSV header.ps1 ├── 3.1.3.1.CSV values.ps1 ├── 3.1.3.2.CSV values.ps1 ├── 3.1.3.3.CSV values.ps1 ├── 3.1.4.1.CSV array values.ps1 ├── 3.1.4.2.CSV array values.ps1 ├── 3.1.5.1.UseCulture and Delimiter.ps1 ├── 3.1.5.2.UseCulture and Delimiter.ps1 ├── 3.1.5.3.UseCulture and Delimiter.ps1 ├── 3.1.6.1.About type information.ps1 ├── 3.1.6.2.About type information.ps1 ├── 3.1.7.1.About quoting.ps1 ├── 3.1.7.2.About quoting.ps1 ├── 3.1.7.3.About quoting.ps1 ├── 3.1.7.4.About quoting.ps1 ├── 3.1.7.5.About quoting.ps1 ├── 3.1.7.6.About quoting.ps1 ├── 3.2.1.1.ConvertFrom-StringData.ps1 ├── 3.2.1.2.ConvertFrom-StringData.ps1 ├── 3.2.1.3.ConvertFrom-StringData.ps1 ├── 3.2.1.4.ConvertFrom-StringData.ps1 ├── 3.2.1.5.ConvertFrom-StringData.ps1 ├── 3.2.1.6.ConvertFrom-StringData.ps1 ├── 3.3.1.1.Convert-String.ps1 ├── 3.3.1.2.Convert-String.ps1 ├── 3.3.1.3.Convert-String.ps1 ├── 3.4.1.1.ConvertFrom-String.ps1 ├── 3.4.1.2.ConvertFrom-String.ps1 ├── 3.5.1.1.Working with Base64.ps1 ├── 3.5.1.2.Working with Base64.ps1 ├── 3.5.1.3.Working with Base64.ps1 ├── 3.5.1.4.Working with Base64.ps1 ├── 4.0.0.1.Manipulating numbers.ps1 ├── 4.1.1.1.Hexadecimal.ps1 ├── 4.2.1.1.Numeric literals.ps1 ├── 4.2.1.2.Numeric literals.ps1 ├── 4.2.1.3.Numeric literals.ps1 ├── 4.2.1.4.Numeric literals.ps1 ├── 4.2.1.5.Numeric literals.ps1 ├── 4.3.1.1.Power of 10.ps1 ├── 4.4.1.1.Using System.Math.ps1 ├── 4.4.1.2.Using System.Math.ps1 ├── 4.4.1.3.Using System.Math.ps1 ├── 4.4.1.4.Using System.Math.ps1 ├── 4.4.1.5.Using System.Math.ps1 ├── 4.4.1.6.Using System.Math.ps1 ├── 4.4.1.7.Using System.Math.ps1 ├── 4.4.1.8.Using System.Math.ps1 ├── 4.4.1.9.Using System.Math.ps1 ├── 4.5.1.1.Converting strings into numeric values.ps1 ├── 4.5.1.2.Converting strings into numeric values.ps1 ├── 4.5.1.3.Converting strings into numeric values.ps1 ├── 4.5.1.4.Converting strings into numeric values.ps1 ├── 5.1.1.1.Parsing dates.ps1 ├── 5.1.1.2.Parsing dates.ps1 ├── 5.1.1.3.Parsing dates.ps1 ├── 5.1.1.4.Parsing dates.ps1 ├── 5.1.1.5.Parsing dates.ps1 ├── 5.1.1.6.Parsing dates.ps1 ├── 5.2.1.1.Changing dates.ps1 ├── 5.2.1.10.Changing dates.ps1 ├── 5.2.1.11.Changing dates.ps1 ├── 5.2.1.12.Changing dates.ps1 ├── 5.2.1.13.Changing dates.ps1 ├── 5.2.1.14.Changing dates.ps1 ├── 5.2.1.15.Changing dates.ps1 ├── 5.2.1.2.Changing dates.ps1 ├── 5.2.1.3.Changing dates.ps1 ├── 5.2.1.4.Changing dates.ps1 ├── 5.2.1.5.Changing dates.ps1 ├── 5.2.1.6.Changing dates.ps1 ├── 5.2.1.7.Changing dates.ps1 ├── 5.2.1.8.Changing dates.ps1 ├── 5.2.1.9.Changing dates.ps1 ├── 5.3.1.1.DateTime parameters.ps1 ├── 5.3.1.2.DateTime parameters.ps1 ├── 5.3.1.3.DateTime parameters.ps1 ├── 5.3.1.4.DateTime parameters.ps1 ├── 5.3.1.5.DateTime parameters.ps1 ├── 5.3.1.6.DateTime parameters.ps1 ├── 5.4.1.1.Comparing dates.ps1 ├── 5.4.1.2.Comparing dates.ps1 └── 5.4.1.3.Comparing dates.ps1 ├── Chapter09 ├── 1.0.0.1.Regex basics.ps1 ├── 1.0.0.2.Regex basics.ps1 ├── 1.0.0.3.Regex basics.ps1 ├── 1.1.1.1.Literal characters.ps1 ├── 1.1.1.2.Literal characters.ps1 ├── 1.1.1.3.Literal characters.ps1 ├── 1.2.1.1.Any character (.).ps1 ├── 1.2.1.2.Any character (.).ps1 ├── 1.2.1.3.Any character (.).ps1 ├── 1.3.1.1.Repetition with and +.ps1 ├── 1.3.1.2.Repetition with and +.ps1 ├── 1.3.1.3.Repetition with and +.ps1 ├── 1.3.1.4.Repetition with and +.ps1 ├── 1.3.1.5.Repetition with and +.ps1 ├── 1.3.1.6.Repetition with and +.ps1 ├── 1.4.1.1.The escape character ().ps1 ├── 1.4.1.10.The escape character ().ps1 ├── 1.4.1.11.The escape character ().ps1 ├── 1.4.1.2.The escape character ().ps1 ├── 1.4.1.3.The escape character ().ps1 ├── 1.4.1.4.The escape character ().ps1 ├── 1.4.1.5.The escape character ().ps1 ├── 1.4.1.6.The escape character ().ps1 ├── 1.4.1.7.The escape character ().ps1 ├── 1.4.1.8.The escape character ().ps1 ├── 1.4.1.9.The escape character ().ps1 ├── 1.5.1.1.Regex is context sensitive.ps1 ├── 1.5.1.2.Regex is context sensitive.ps1 ├── 1.5.1.3.Regex is context sensitive.ps1 ├── 1.5.1.4.Regex is context sensitive.ps1 ├── 1.6.1.1.Optional characters.ps1 ├── 1.8.1.1.Debugging regular expressions.ps1 ├── 2.0.0.1.Anchors.ps1 ├── 2.0.0.2.Anchors.ps1 ├── 2.0.0.3.Anchors.ps1 ├── 2.0.0.4.Anchors.ps1 ├── 2.0.0.5.Anchors.ps1 ├── 3.1.1.1.Exploring the quantifiers.ps1 ├── 3.1.1.2.Exploring the quantifiers.ps1 ├── 4.0.0.1.Character classes.ps1 ├── 4.1.1.1.Ranges.ps1 ├── 4.1.1.10.Ranges.ps1 ├── 4.1.1.2.Ranges.ps1 ├── 4.1.1.3.Ranges.ps1 ├── 4.1.1.4.Ranges.ps1 ├── 4.1.1.5.Ranges.ps1 ├── 4.1.1.6.Ranges.ps1 ├── 4.1.1.7.Ranges.ps1 ├── 4.1.1.8.Ranges.ps1 ├── 4.1.1.9.Ranges.ps1 ├── 4.2.1.1.Negated character class.ps1 ├── 4.3.1.1.Character class subtraction.ps1 ├── 4.3.1.2.Character class subtraction.ps1 ├── 4.3.1.3.Character class subtraction.ps1 ├── 4.3.1.4.Character class subtraction.ps1 ├── 4.5.1.1.Unicode category class.ps1 ├── 4.5.1.2.Unicode category class.ps1 ├── 4.5.1.3.Unicode category class.ps1 ├── 4.5.1.4.Unicode category class.ps1 ├── 5.0.0.1.Alternation.ps1 ├── 5.0.0.2.Alternation.ps1 ├── 5.0.0.3.Alternation.ps1 ├── 5.0.0.4.Alternation.ps1 ├── 6.1.1.1.Repeating groups.ps1 ├── 6.1.1.2.Repeating groups.ps1 ├── 6.1.1.3.Repeating groups.ps1 ├── 6.2.1.1.Restricting alternation.ps1 ├── 6.2.1.2.Restricting alternation.ps1 ├── 6.2.1.3.Restricting alternation.ps1 ├── 6.3.1.1.Capturing values.ps1 ├── 6.3.1.2.Capturing values.ps1 ├── 6.3.1.3.Capturing values.ps1 ├── 6.4.1.1.Named capture groups.ps1 ├── 6.4.1.2.Named capture groups.ps1 ├── 6.5.1.1.Non-capturing groups.ps1 ├── 6.5.1.2.Non-capturing groups.ps1 ├── 6.5.1.3.Non-capturing groups.ps1 ├── 7.0.0.1.Look-ahead and look-behind.ps1 ├── 7.0.0.2.Look-ahead and look-behind.ps1 ├── 8.0.0.1.The .NET Regex type.ps1 ├── 8.0.0.2.The .NET Regex type.ps1 ├── 8.0.0.3.The .NET Regex type.ps1 ├── 8.0.0.4.The .NET Regex type.ps1 ├── 8.1.1.1.Regex options.ps1 ├── 8.1.1.2.Regex options.ps1 ├── 8.1.1.3.Regex options.ps1 ├── 8.1.1.4.Regex options.ps1 ├── 8.1.1.5.Regex options.ps1 ├── 8.1.1.6.Regex options.ps1 ├── 8.1.1.7.Regex options.ps1 ├── 8.1.1.8.Regex options.ps1 ├── 9.1.1.1.MAC addresses.ps1 ├── 9.1.1.10.MAC addresses.ps1 ├── 9.1.1.2.MAC addresses.ps1 ├── 9.1.1.3.MAC addresses.ps1 ├── 9.1.1.4.MAC addresses.ps1 ├── 9.1.1.5.MAC addresses.ps1 ├── 9.1.1.6.MAC addresses.ps1 ├── 9.1.1.7.MAC addresses.ps1 ├── 9.1.1.8.MAC addresses.ps1 ├── 9.1.1.9.MAC addresses.ps1 ├── 9.2.1.1.IP addresses.ps1 ├── 9.2.1.2.IP addresses.ps1 ├── 9.2.1.3.IP addresses.ps1 ├── 9.2.1.4.IP addresses.ps1 ├── 9.2.1.5.IP addresses.ps1 ├── 9.2.1.6.IP addresses.ps1 ├── 9.2.1.7.IP addresses.ps1 ├── 9.2.1.8.IP addresses.ps1 ├── 9.3.1.1.The netstat command.ps1 ├── 9.3.1.2.The netstat command.ps1 ├── 9.3.1.3.The netstat command.ps1 ├── 9.3.1.4.The netstat command.ps1 ├── 9.3.1.5.The netstat command.ps1 ├── 9.3.1.6.The netstat command.ps1 ├── 9.3.1.7.The netstat command.ps1 ├── 9.4.1.1.Formatting certificates.ps1 └── 9.4.1.2.Formatting certificates.ps1 ├── Chapter10 ├── 1.0.0.1.Working with providers.ps1 ├── 1.0.0.2.Working with providers.ps1 ├── 1.0.0.3.Working with providers.ps1 ├── 1.0.0.4.Working with providers.ps1 ├── 1.1.1.1.Navigating.ps1 ├── 1.1.1.2.Navigating.ps1 ├── 1.1.1.3.Navigating.ps1 ├── 1.1.1.4.Navigating.ps1 ├── 1.1.1.5.Navigating.ps1 ├── 1.1.1.6.Navigating.ps1 ├── 1.2.1.1.Getting items.ps1 ├── 1.2.1.2.Getting items.ps1 ├── 1.2.1.3.Getting items.ps1 ├── 1.2.1.4.Getting items.ps1 ├── 1.3.1.1.Drives.ps1 ├── 1.3.1.2.Drives.ps1 ├── 2.1.1.1.Paths and .NET.ps1 ├── 2.1.1.2.Paths and .NET.ps1 ├── 2.1.1.3.Paths and .NET.ps1 ├── 2.1.1.4.Paths and .NET.ps1 ├── 2.1.1.5.Paths and .NET.ps1 ├── 2.1.1.6.Paths and .NET.ps1 ├── 2.1.1.7.Paths and .NET.ps1 ├── 2.1.1.8.Paths and .NET.ps1 ├── 2.1.1.9.Paths and .NET.ps1 ├── 2.2.1.1.Testing for existing items.ps1 ├── 2.2.1.2.Testing for existing items.ps1 ├── 2.2.2.1.Testing FileSystem paths.ps1 ├── 2.2.2.2.Testing FileSystem paths.ps1 ├── 2.2.2.3.Testing FileSystem paths.ps1 ├── 2.2.2.4.Testing FileSystem paths.ps1 ├── 2.2.2.5.Testing FileSystem paths.ps1 ├── 2.2.2.6.Testing FileSystem paths.ps1 ├── 2.2.3.1.Testing Registry paths.ps1 ├── 2.2.3.2.Testing Registry paths.ps1 ├── 2.2.3.3.Testing Registry paths.ps1 ├── 2.2.3.4.Testing Registry paths.ps1 ├── 2.2.3.5.Testing Registry paths.ps1 ├── 2.2.4.1.Testing path type.ps1 ├── 2.2.4.2.Testing path type.ps1 ├── 2.2.4.3.Testing path type.ps1 ├── 2.2.4.4.Testing path type.ps1 ├── 2.2.4.5.Testing path type.ps1 ├── 2.3.1.1.Creating items.ps1 ├── 2.3.1.2.Creating items.ps1 ├── 2.3.1.3.Creating items.ps1 ├── 2.3.1.4.Creating items.ps1 ├── 2.4.1.1.Reading and writing content.ps1 ├── 2.4.1.2.Reading and writing content.ps1 ├── 2.4.2.1.Reading and writing in a pipeline.ps1 ├── 2.4.2.2.Reading and writing in a pipeline.ps1 ├── 2.4.2.3.Reading and writing in a pipeline.ps1 ├── 2.4.3.1.Reading all content.ps1 ├── 2.4.3.2.Reading all content.ps1 ├── 2.4.4.1.Writing content.ps1 ├── 2.4.4.2.Writing content.ps1 ├── 2.4.4.3.Writing content.ps1 ├── 2.4.5.1.About text file encoding.ps1 ├── 2.4.5.2.About text file encoding.ps1 ├── 2.4.5.3.About text file encoding.ps1 ├── 2.4.5.4.About text file encoding.ps1 ├── 2.4.5.5.About text file encoding.ps1 ├── 2.4.5.6.About text file encoding.ps1 ├── 2.4.5.7.About text file encoding.ps1 ├── 2.5.1.1.Temporary files.ps1 ├── 2.5.1.2.Temporary files.ps1 ├── 2.6.1.1.Removing items.ps1 ├── 2.7.1.1.Invoking items.ps1 ├── 2.8.2.1.Properties and the File System.ps1 ├── 2.8.2.2.Properties and the File System.ps1 ├── 2.8.3.1.Adding and removing file attributes.ps1 ├── 2.8.3.10.Adding and removing file attributes.ps1 ├── 2.8.3.11.Adding and removing file attributes.ps1 ├── 2.8.3.2.Adding and removing file attributes.ps1 ├── 2.8.3.3.Adding and removing file attributes.ps1 ├── 2.8.3.4.Adding and removing file attributes.ps1 ├── 2.8.3.5.Adding and removing file attributes.ps1 ├── 2.8.3.6.Adding and removing file attributes.ps1 ├── 2.8.3.7.Adding and removing file attributes.ps1 ├── 2.8.3.8.Adding and removing file attributes.ps1 ├── 2.8.3.9.Adding and removing file attributes.ps1 ├── 2.8.4.1.Registry values.ps1 ├── 2.8.4.2.Registry values.ps1 ├── 2.8.4.3.Registry values.ps1 ├── 2.8.4.4.Registry values.ps1 ├── 2.8.4.5.Registry values.ps1 ├── 2.8.4.6.Registry values.ps1 ├── 2.8.5.1.Registry values and Environment variables.ps1 ├── 2.8.5.2.Registry values and Environment variables.ps1 ├── 2.8.5.3.Registry values and Environment variables.ps1 ├── 2.8.5.4.Registry values and Environment variables.ps1 ├── 2.9.1.1.Searching for items.ps1 ├── 2.9.1.2.Searching for items.ps1 ├── 2.9.1.3.Searching for items.ps1 ├── 2.9.1.4.Searching for items.ps1 ├── 3.0.0.1.Windows permissions.ps1 ├── 3.1.1.1.Access and audit.ps1 ├── 3.2.1.1.Rule protection.ps1 ├── 3.2.1.2.Rule protection.ps1 ├── 3.2.1.3.Rule protection.ps1 ├── 3.2.1.4.Rule protection.ps1 ├── 3.2.1.5.Rule protection.ps1 ├── 3.2.1.6.Rule protection.ps1 ├── 3.2.1.7.Rule protection.ps1 ├── 3.4.1.1.Removing ACEs.ps1 ├── 3.4.1.2.Removing ACEs.ps1 ├── 3.4.1.3.Removing ACEs.ps1 ├── 3.4.1.4.Removing ACEs.ps1 ├── 3.5.1.1.Copying lists and entries.ps1 ├── 3.5.1.2.Copying lists and entries.ps1 ├── 3.5.1.3.Copying lists and entries.ps1 ├── 3.6.2.1.FileSystem rights.ps1 ├── 3.6.2.2.FileSystem rights.ps1 ├── 3.6.2.3.FileSystem rights.ps1 ├── 3.6.2.4.FileSystem rights.ps1 ├── 3.6.3.1.Registry rights.ps1 ├── 3.6.3.2.Registry rights.ps1 ├── 3.7.1.1.Numeric values in the ACL.ps1 ├── 3.7.1.2.Numeric values in the ACL.ps1 ├── 3.8.1.1.Ownership.ps1 ├── 3.8.1.2.Ownership.ps1 ├── 4.0.0.1.Transactions.ps1 ├── 4.0.0.2.Transactions.ps1 ├── 4.0.0.3.Transactions.ps1 ├── 4.0.0.4.Transactions.ps1 ├── 4.0.0.5.Transactions.ps1 ├── 5.1.1.1.About hashing.ps1 ├── 5.2.1.1.New-FileCatalog.ps1 ├── 5.3.1.1.Test-FileCatalog.ps1 ├── 5.3.1.10.Test-FileCatalog.ps1 ├── 5.3.1.11.Test-FileCatalog.ps1 ├── 5.3.1.12.Test-FileCatalog.ps1 ├── 5.3.1.2.Test-FileCatalog.ps1 ├── 5.3.1.3.Test-FileCatalog.ps1 ├── 5.3.1.4.Test-FileCatalog.ps1 ├── 5.3.1.5.Test-FileCatalog.ps1 ├── 5.3.1.6.Test-FileCatalog.ps1 ├── 5.3.1.7.Test-FileCatalog.ps1 ├── 5.3.1.8.Test-FileCatalog.ps1 └── 5.3.1.9.Test-FileCatalog.ps1 ├── Chapter11 ├── 1.3.2.1.Getting instances.ps1 ├── 1.3.2.2.Getting instances.ps1 ├── 1.3.2.3.Getting instances.ps1 ├── 1.3.2.4.Getting instances.ps1 ├── 1.3.3.1.Getting classes.ps1 ├── 1.3.3.2.Getting classes.ps1 ├── 1.3.3.3.Getting classes.ps1 ├── 1.3.4.1.Calling methods.ps1 ├── 1.3.4.2.Calling methods.ps1 ├── 1.3.4.3.Calling methods.ps1 ├── 1.3.4.4.Calling methods.ps1 ├── 1.3.4.5.Calling methods.ps1 ├── 1.3.4.6.Calling methods.ps1 ├── 1.3.5.1.Creating instances.ps1 ├── 1.3.5.2.Creating instances.ps1 ├── 1.3.5.3.Creating instances.ps1 ├── 1.3.5.4.Creating instances.ps1 ├── 1.3.6.1.Removing instances.ps1 ├── 1.3.6.2.Removing instances.ps1 ├── 1.3.6.3.Removing instances.ps1 ├── 1.3.7.1.Working with CIM sessions.ps1 ├── 1.3.7.2.Working with CIM sessions.ps1 ├── 1.3.8.1.Associated classes.ps1 ├── 1.3.8.2.Associated classes.ps1 ├── 1.3.8.3.Associated classes.ps1 ├── 2.1.1.1.Understanding SELECT, WHERE, and FROM.ps1 ├── 2.1.1.2.Understanding SELECT, WHERE, and FROM.ps1 ├── 2.2.1.1.Escape sequences and wildcards.ps1 ├── 2.2.1.2.Escape sequences and wildcards.ps1 ├── 2.3.1.1.Comparison operators.ps1 ├── 2.3.2.1.WQL filters and Dates.ps1 ├── 2.3.2.2.WQL filters and Dates.ps1 ├── 2.3.2.3.WQL filters and Dates.ps1 ├── 2.4.1.1.Logic operators.ps1 ├── 2.5.1.1.Quoting values.ps1 ├── 2.5.1.2.Quoting values.ps1 ├── 2.5.1.3.Quoting values.ps1 ├── 2.5.1.4.Quoting values.ps1 ├── 2.6.1.1.Associated classes.ps1 ├── 2.6.2.1.WMI object paths.ps1 ├── 2.6.2.2.WMI object paths.ps1 ├── 2.6.3.1.Using ASSOCIATORS OF.ps1 ├── 2.6.3.2.Using ASSOCIATORS OF.ps1 ├── 2.6.3.3.Using ASSOCIATORS OF.ps1 ├── 2.6.3.4.Using ASSOCIATORS OF.ps1 ├── 3.0.0.1.WMI Type Accelerators.ps1 ├── 3.1.1.1.Getting instances.ps1 ├── 3.2.1.1.Working with dates.ps1 ├── 3.2.1.2.Working with dates.ps1 ├── 3.3.1.1.Getting classes.ps1 ├── 3.4.1.1.Calling methods.ps1 ├── 3.4.1.2.Calling methods.ps1 ├── 3.4.1.3.Calling methods.ps1 ├── 3.4.1.4.Calling methods.ps1 ├── 3.4.1.5.Calling methods.ps1 ├── 3.4.1.6.Calling methods.ps1 ├── 3.5.1.1.Creating instances.ps1 ├── 3.6.1.1.Associated classes.ps1 ├── 4.1.2.1.Creating a shared directory.ps1 ├── 4.1.2.2.Creating a shared directory.ps1 ├── 4.1.3.1.Getting a security descriptor.ps1 ├── 4.1.3.2.Getting a security descriptor.ps1 ├── 4.1.3.3.Getting a security descriptor.ps1 ├── 4.1.3.4.Getting a security descriptor.ps1 ├── 4.1.3.5.Getting a security descriptor.ps1 ├── 4.1.3.6.Getting a security descriptor.ps1 ├── 4.1.3.7.Getting a security descriptor.ps1 ├── 4.1.3.8.Getting a security descriptor.ps1 ├── 4.1.3.9.Getting a security descriptor.ps1 ├── 4.1.4.1.Adding an access control entry.ps1 ├── 4.1.4.2.Adding an access control entry.ps1 ├── 4.1.4.3.Adding an access control entry.ps1 ├── 4.1.5.1.Setting the security descriptor.ps1 ├── 4.1.5.2.Setting the security descriptor.ps1 ├── 4.2.1.1.WMI permissions.ps1 ├── 4.2.2.1.Getting a security descriptor.ps1 ├── 4.3.1.1.WMI and SDDL.ps1 ├── 4.3.1.2.WMI and SDDL.ps1 ├── 4.3.1.3.WMI and SDDL.ps1 ├── 4.3.1.4.WMI and SDDL.ps1 ├── 4.3.1.5.WMI and SDDL.ps1 ├── 4.3.1.6.WMI and SDDL.ps1 └── 4.3.1.7.WMI and SDDL.ps1 ├── Chapter12 ├── 1.0.0.1.ConvertTo-Html.ps1 ├── 1.1.1.1.Multiple tables.ps1 ├── 1.2.1.1.Adding style.ps1 ├── 1.2.1.2.Adding style.ps1 ├── 1.3.1.1.ConvertTo-Html and Send-MailMessage.ps1 ├── 1.4.1.1.Windows PowerShell and ConvertTo-Html.ps1 ├── 1.4.1.2.Windows PowerShell and ConvertTo-Html .ps1 ├── 1.5.1.1.Modifying HTML content.ps1 ├── 1.5.1.2.Modifying HTML content.ps1 ├── 1.5.1.3.Modifying HTML content.ps1 ├── 1.5.1.4.Modifying HTML content.ps1 ├── 1.5.1.5.Modifying HTML content.ps1 ├── 2.5.1.1.Select-Xml.ps1 ├── 2.5.1.2.Select-Xml.ps1 ├── 2.5.2.1.Select-Xml and namespaces.ps1 ├── 2.5.2.2.Select-Xml and namespaces.ps1 ├── 2.6.1.1.ConvertTo-Xml.ps1 ├── 2.6.1.2.ConvertTo-Xml.ps1 ├── 2.6.1.3.ConvertTo-Xml.ps1 ├── 3.1.1.1.The XML type accelerator.ps1 ├── 3.1.1.2.The XML type accelerator.ps1 ├── 3.1.1.3.The XML type accelerator.ps1 ├── 3.10.1.1.Schema validation.ps1 ├── 3.10.1.2.Schema validation.ps1 ├── 3.10.1.3.Schema validation.ps1 ├── 3.10.1.4.Schema validation.ps1 ├── 3.11.1.1.Infer a schema.ps1 ├── 3.11.1.2.Infer a schema.ps1 ├── 3.11.1.3.Infer a schema.ps1 ├── 3.11.1.4.Infer a schema.ps1 ├── 3.11.1.5.Infer a schema.ps1 ├── 3.2.1.1.XPath and XmlDocument.ps1 ├── 3.3.1.1.SelectNodes and XPathNodeList.ps1 ├── 3.3.1.2.SelectNodes and XPathNodeList.ps1 ├── 3.3.1.3.SelectNodes and XPathNodeList.ps1 ├── 3.4.1.1.Working with namespaces.ps1 ├── 3.4.1.2.Working with namespaces.ps1 ├── 3.4.1.3.Working with namespaces.ps1 ├── 3.4.1.4.Working with namespaces.ps1 ├── 3.4.1.5.Working with namespaces.ps1 ├── 3.4.1.6.Working with namespaces.ps1 ├── 3.4.1.7.Working with namespaces.ps1 ├── 3.5.1.1.Creating XML documents.ps1 ├── 3.5.1.2.Creating XML documents.ps1 ├── 3.6.1.1.Modifying element and attribute values.ps1 ├── 3.6.1.2.Modifying element and attribute values.ps1 ├── 3.6.1.3.Modifying element and attribute values.ps1 ├── 3.6.1.4.Modifying element and attribute values.ps1 ├── 3.7.1.1.Adding elements.ps1 ├── 3.7.1.2.Adding elements.ps1 ├── 3.8.1.1.Removing elements and attributes.ps1 ├── 3.8.1.2.Removing elements and attributes.ps1 ├── 3.8.1.3.Removing elements and attributes.ps1 ├── 3.9.1.1.Copying nodes between documents.ps1 ├── 3.9.1.2.Copying nodes between documents.ps1 ├── 3.9.1.3.Copying nodes between documents.ps1 ├── 4.0.0.1.System.Xml.Linq.ps1 ├── 4.1.1.1.Opening documents.ps1 ├── 4.1.1.2.Opening documents.ps1 ├── 4.2.1.1.Selecting nodes.ps1 ├── 4.2.1.2.Selecting nodes.ps1 ├── 4.3.1.1.Creating documents.ps1 ├── 4.3.1.2.Creating documents.ps1 ├── 4.3.1.3.Creating documents.ps1 ├── 4.3.1.4.Creating documents.ps1 ├── 4.4.1.1.Working with namespaces.ps1 ├── 4.4.1.2.Working with namespaces.ps1 ├── 4.4.1.3.Working with namespaces.ps1 ├── 4.5.1.1.Modifying element and attribute values.ps1 ├── 4.5.1.2.Modifying element and attribute values.ps1 ├── 4.5.1.3.Modifying element and attribute values.ps1 ├── 4.5.1.4.Modifying element and attribute values.ps1 ├── 4.6.1.1.Adding nodes.ps1 ├── 4.6.1.2.Adding nodes.ps1 ├── 4.7.1.1.Removing nodes.ps1 ├── 4.8.1.1.Schema validation.ps1 ├── 5.0.0.1.JSON.ps1 ├── 5.1.1.1.ConvertTo-Json.ps1 ├── 5.1.1.2.ConvertTo-Json.ps1 ├── 5.1.2.1.EnumsAsStrings.ps1 ├── 5.1.2.2.EnumsAsStrings.ps1 ├── 5.1.3.1.AsArray.ps1 ├── 5.1.3.2.AsArray.ps1 ├── 5.1.3.3.AsArray.ps1 ├── 5.1.4.1.EscapeHandling.ps1 ├── 5.1.4.2.EscapeHandling.ps1 ├── 5.2.1.1.ConvertFrom-Json.ps1 ├── 5.2.1.2.ConvertFrom-Json.ps1 ├── 5.2.1.3.ConvertFrom-Json.ps1 ├── 5.2.1.4.ConvertFrom-Json.ps1 ├── 5.2.1.5.ConvertFrom-Json.ps1 ├── 5.2.1.6.ConvertFrom-Json.ps1 ├── 5.2.1.7.ConvertFrom-Json.ps1 ├── 5.2.1.8.ConvertFrom-Json.ps1 ├── 5.2.2.1.AsHashtable.ps1 ├── 5.2.2.2.AsHashtable.ps1 ├── 5.2.2.3.AsHashtable.ps1 ├── 5.2.3.1.NoEnumerate.ps1 ├── 5.2.3.2.NoEnumerate.ps1 ├── 5.2.3.3.NoEnumerate.ps1 ├── 5.2.3.4.NoEnumerate.ps1 ├── 5.3.1.1.Test-Json.ps1 ├── 5.3.1.2.Test-Json.ps1 ├── 5.3.1.3.Test-Json.ps1 ├── 5.3.1.4.Test-Json.ps1 ├── 5.3.1.5.Test-Json.ps1 ├── 5.3.1.6.Test-Json.ps1 └── 5.3.1.7.Test-Json.ps1 ├── Chapter13 ├── 2.2.1.1.Using Invoke-WebRequest.ps1 ├── 2.3.1.1.About parsing web pages.ps1 ├── 2.4.1.1.Downloading files.ps1 ├── 2.4.1.2.Downloading files.ps1 ├── 2.5.1.1.Using the HEAD method.ps1 ├── 2.6.2.1.Security Protocols.ps1 ├── 2.6.2.2.Security Protocols.ps1 ├── 2.6.3.1.Certificate validation.ps1 ├── 2.6.3.2.Certificate validation.ps1 ├── 2.6.4.1.Windows PowerShell and certificate validation.ps1 ├── 2.6.4.2.Windows PowerShell and certificate validation.ps1 ├── 2.6.4.3.Windows PowerShell and certificate validation.ps1 ├── 2.6.4.4.Windows PowerShell and certificate validation.ps1 ├── 2.6.5.1.Capturing SSL errors.ps1 ├── 2.6.5.2.Capturing SSL errors.ps1 ├── 2.6.5.3.Capturing SSL errors.ps1 ├── 2.6.5.4.Capturing SSL errors.ps1 ├── 3.0.0.1.Working with REST.ps1 ├── 3.0.0.2.Working with REST.ps1 ├── 3.1.1.1.Simple requests.ps1 ├── 3.2.1.1.Using basic authentication.ps1 ├── 3.2.1.2.Using basic authentication.ps1 ├── 3.3.1.1.Requests with arguments.ps1 ├── 3.3.1.2.Requests with arguments.ps1 ├── 3.3.1.3.Requests with arguments.ps1 ├── 3.3.1.4.Requests with arguments.ps1 ├── 3.3.1.5.Requests with arguments.ps1 ├── 3.4.1.1.Working with paging.ps1 ├── 3.4.1.2.Working with paging.ps1 ├── 3.4.1.3.Working with paging.ps1 ├── 3.4.1.4.Working with paging.ps1 ├── 3.5.2.1.Creating an application.ps1 ├── 3.5.3.1.Getting an authorization code.ps1 ├── 3.5.4.1.Implementing an HTTP listener.ps1 ├── 3.5.5.1.Requesting an access token.ps1 ├── 3.5.6.1.Using a token.ps1 ├── 3.5.6.2.Using a token.ps1 ├── 4.2.2.1.New-WebServiceProxy.ps1 ├── 4.2.2.2.New-WebServiceProxy.ps1 ├── 4.2.3.1.Methods.ps1 ├── 4.2.3.2.Methods.ps1 ├── 4.2.3.3.Methods.ps1 ├── 4.2.4.1.Methods and enumerations.ps1 ├── 4.2.4.2.Methods and enumerations.ps1 ├── 4.2.4.3.Methods and enumerations.ps1 ├── 4.2.4.4.Methods and enumerations.ps1 ├── 4.2.5.1.Methods and SOAP objects.ps1 ├── 4.2.5.2.Methods and SOAP objects.ps1 ├── 4.2.5.3.Methods and SOAP objects.ps1 ├── 4.2.5.4.Methods and SOAP objects.ps1 ├── 4.2.6.1.Overlapping services.ps1 ├── 4.2.6.2.Overlapping services.ps1 ├── 4.2.6.3.Overlapping services.ps1 ├── 4.2.6.4.Overlapping services.ps1 ├── 4.3.2.1.Getting the WSDL document.ps1 ├── 4.3.3.1.Discovering methods and enumerations.ps1 ├── 4.3.3.2.Discovering methods and enumerations.ps1 ├── 4.3.4.1.Running methods.ps1 ├── 4.3.4.2.Running methods.ps1 ├── 4.3.4.3.Running methods.ps1 ├── 4.3.4.4.Running methods.ps1 └── SimpleSOAP │ ├── Readme.md │ ├── SimpleSOAP.sln │ ├── SimpleSOAP │ ├── App_Code │ │ ├── ComparisonOperator.cs │ │ ├── Element.cs │ │ ├── Group.cs │ │ ├── SearchCondition.cs │ │ └── Service.cs │ ├── Service.asmx │ ├── Web.Debug.config │ ├── Web.config │ ├── elements.json │ └── packages.config │ └── packages.config ├── Chapter14 ├── 2.0.0.1.Executing remote commands.ps1 ├── 2.1.1.1.Enter-PSSession.ps1 ├── 2.1.1.2.Enter-PSSession.ps1 ├── 2.1.1.3.Enter-PSSession.ps1 ├── 2.1.1.4.Enter-PSSession.ps1 ├── 2.1.1.5.Enter-PSSession.ps1 ├── 2.2.1.1.Invoke-Command.ps1 ├── 2.2.1.2.Invoke-Command.ps1 ├── 2.2.2.1.Parallel execution.ps1 ├── 2.2.2.2.Parallel execution.ps1 ├── 2.2.2.3.Parallel execution.ps1 ├── 2.2.2.4.Parallel execution.ps1 ├── 2.2.3.1.Catching remoting failures.ps1 ├── 2.2.3.2.Catching remoting failures.ps1 ├── 2.2.4.1.Local functions and remote sessions.ps1 ├── 2.2.4.2.Local functions and remote sessions.ps1 ├── 2.2.5.1.Using ArgumentList.ps1 ├── 2.2.5.2.Using ArgumentList.ps1 ├── 2.2.5.3.Using ArgumentList.ps1 ├── 2.2.6.1.The using scope modifier.ps1 ├── 2.2.6.2.The using scope modifier.ps1 ├── 3.1.1.1.New-PSSession and Get-PSSession.ps1 ├── 3.1.1.2.New-PSSession and Get-PSSession.ps1 ├── 3.1.1.3.New-PSSession and Get-PSSession.ps1 ├── 3.1.1.4.New-PSSession and Get-PSSession.ps1 ├── 3.2.1.1.Disconnected sessions.ps1 ├── 3.2.1.2.Disconnected sessions.ps1 ├── 3.2.1.3.Disconnected sessions.ps1 ├── 3.2.1.4.Disconnected sessions.ps1 ├── 3.3.1.1.Import-PSSession.ps1 ├── 3.4.1.1.Export-PSSession.ps1 ├── 3.4.1.2.Export-PSSession.ps1 ├── 3.5.1.1.Copying items between sessions.ps1 ├── 3.5.1.2.Copying items between sessions.ps1 ├── 4.1.1.1.Enabling and configuring remoting.ps1 ├── 4.2.1.1.The WSMan drive.ps1 ├── 4.2.1.2.The WSMan drive.ps1 ├── 4.3.1.1.Remoting and SSL.ps1 ├── 4.3.1.2.Remoting and SSL.ps1 ├── 4.3.1.3.Remoting and SSL.ps1 ├── 4.3.1.4.Remoting and SSL.ps1 ├── 4.3.1.5.Remoting and SSL.ps1 ├── 4.3.1.6.Remoting and SSL.ps1 ├── 4.3.1.7.Remoting and SSL.ps1 ├── 4.3.1.8.Remoting and SSL.ps1 ├── 4.4.1.1.User Account Control.ps1 ├── 4.4.1.2.User Account Control.ps1 ├── 4.5.1.1.Trusted hosts.ps1 ├── 4.5.1.2.Trusted hosts.ps1 ├── 4.5.1.3.Trusted hosts.ps1 ├── 4.5.1.4.Trusted hosts.ps1 ├── 5.0.0.1.Remoting on Linux.ps1 ├── 5.0.0.2.Remoting on Linux.ps1 ├── 5.0.0.3.Remoting on Linux.ps1 ├── 5.0.0.4.Remoting on Linux.ps1 ├── 5.0.0.5.Remoting on Linux.ps1 ├── 5.2.1.1.Connecting from Windows to Linux.ps1 ├── 5.2.1.2.Connecting from Windows to Linux.ps1 ├── 5.2.1.3.Connecting from Windows to Linux.ps1 ├── 5.2.1.4.Connecting from Windows to Linux.ps1 ├── 5.2.1.5.Connecting from Windows to Linux.ps1 ├── 5.2.1.6.Connecting from Windows to Linux.ps1 ├── 5.3.1.1.Connecting from Linux to Windows.ps1 ├── 5.3.1.10.Connecting from Linux to Windows.ps1 ├── 5.3.1.11.Connecting from Linux to Windows.ps1 ├── 5.3.1.2.Connecting from Linux to Windows.ps1 ├── 5.3.1.3.Connecting from Linux to Windows.ps1 ├── 5.3.1.4.Connecting from Linux to Windows.ps1 ├── 5.3.1.5.Connecting from Linux to Windows.ps1 ├── 5.3.1.6.Connecting from Linux to Windows.ps1 ├── 5.3.1.7.Connecting from Linux to Windows.ps1 ├── 5.3.1.8.Connecting from Linux to Windows.ps1 ├── 5.3.1.9.Connecting from Linux to Windows.ps1 ├── 6.0.0.1.The double-hop problem.ps1 ├── 6.0.0.2.The double-hop problem.ps1 ├── 6.1.1.1.CredSSP.ps1 ├── 6.1.1.2.CredSSP.ps1 ├── 6.1.1.3.CredSSP.ps1 ├── 6.1.1.4.CredSSP.ps1 ├── 6.1.1.5.CredSSP.ps1 ├── 6.2.1.1.Passing credentials.ps1 ├── 7.0.0.1.CIM sessions.ps1 ├── 7.0.0.2.CIM sessions.ps1 ├── 7.0.0.3.CIM sessions.ps1 ├── 7.0.0.4.CIM sessions.ps1 ├── 7.0.0.5.CIM sessions.ps1 ├── 7.1.1.1.Get-CimSession.ps1 ├── 7.2.1.1.Using CIM sessions.ps1 ├── 8.1.1.1.Session configuration.ps1 ├── 8.1.1.2.Session configuration.ps1 ├── 8.1.1.3.Session configuration.ps1 ├── 8.1.1.4.Session configuration.ps1 ├── 8.2.1.1.Role capabilities.ps1 ├── 8.2.1.2.Role capabilities.ps1 ├── 8.2.1.3.Role capabilities.ps1 └── 8.2.1.4.Role capabilities.ps1 ├── Chapter15 ├── 1.1.1.1.Start-Job, Get-Job, and Remove-Job.ps1 ├── 1.1.1.2.Start-Job, Get-Job, and Remove-Job.ps1 ├── 1.1.1.3.Start-Job, Get-Job, and Remove-Job.ps1 ├── 1.1.1.4.Start-Job, Get-Job, and Remove-Job.ps1 ├── 1.1.1.5.Start-Job, Get-Job, and Remove-Job.ps1 ├── 1.1.1.6.Start-Job, Get-Job, and Remove-Job.ps1 ├── 1.2.1.1.Receive-Job.ps1 ├── 1.3.1.1.Wait-Job.ps1 ├── 1.3.1.2.Wait-Job.ps1 ├── 1.3.1.3.Wait-Job.ps1 ├── 1.4.1.1.Jobs and the using scope modifier.ps1 ├── 1.4.1.2.Jobs and the using scope modifier.ps1 ├── 1.4.1.3.Jobs and the using scope modifier.ps1 ├── 1.4.1.4.Jobs and the using scope modifier.ps1 ├── 1.5.1.1.The background operator.ps1 ├── 1.5.1.2.The background operator.ps1 ├── 1.5.1.3.The background operator.ps1 ├── 1.6.1.1.The ThreadJob module.ps1 ├── 1.7.1.1.Batching jobs.ps1 ├── 1.7.1.2.Batching jobs.ps1 ├── 2.0.0.1.Reacting to events.ps1 ├── 2.0.0.2.Reacting to events.ps1 ├── 2.1.1.1.The Register-ObjectEvent and -Event commands.ps1 ├── 2.1.1.2.The Register-ObjectEvent and -Event commands.ps1 ├── 2.1.1.3.The Register-ObjectEvent and -Event commands.ps1 ├── 2.1.1.4.The Register-ObjectEvent and -Event commands.ps1 ├── 2.1.1.5.The Register-ObjectEvent and -Event commands.ps1 ├── 2.2.1.1.Action, Event, EventArgs, and MessageData parameters.ps1 ├── 2.2.1.2.Action, Event, EventArgs, and MessageData parameters.ps1 ├── 2.2.1.3.Action, Event, EventArgs, and MessageData parameters.ps1 ├── 2.2.1.4.Action, Event, EventArgs, and MessageData parameters.ps1 ├── 2.2.1.5.Action, Event, EventArgs, and MessageData parameters.ps1 ├── 2.3.1.1.Get-EventSubscriber and Unregister-Event.ps1 ├── 2.3.1.2.Get-EventSubscriber and Unregister-Event.ps1 ├── 3.1.1.1.Creating a PowerShell instance.ps1 ├── 3.1.1.2.Creating a PowerShell instance.ps1 ├── 3.1.1.3.Creating a PowerShell instance.ps1 ├── 3.1.1.4.Creating a PowerShell instance.ps1 ├── 3.1.1.5.Creating a PowerShell instance.ps1 ├── 3.1.1.6.Creating a PowerShell instance.ps1 ├── 3.2.1.1.The Invoke and BeginInvoke methods.ps1 ├── 3.2.1.10.The Invoke and BeginInvoke methods.ps1 ├── 3.2.1.11.The Invoke and BeginInvoke methods.ps1 ├── 3.2.1.12.The Invoke and BeginInvoke methods.ps1 ├── 3.2.1.2.The Invoke and BeginInvoke methods.ps1 ├── 3.2.1.3.The Invoke and BeginInvoke methods.ps1 ├── 3.2.1.4.The Invoke and BeginInvoke methods.ps1 ├── 3.2.1.5.The Invoke and BeginInvoke methods.ps1 ├── 3.2.1.6.The Invoke and BeginInvoke methods.ps1 ├── 3.2.1.7.The Invoke and BeginInvoke methods.ps1 ├── 3.2.1.8.The Invoke and BeginInvoke methods.ps1 ├── 3.2.1.9.The Invoke and BeginInvoke methods.ps1 ├── 3.3.1.1.About Streams and InvocationStateInfo.ps1 ├── 3.3.1.2.About Streams and InvocationStateInfo.ps1 ├── 3.3.1.3.About Streams and InvocationStateInfo.ps1 ├── 3.3.1.4.About Streams and InvocationStateInfo.ps1 ├── 3.3.1.5.About Streams and InvocationStateInfo.ps1 ├── 3.3.1.6.About Streams and InvocationStateInfo.ps1 ├── 3.3.1.7.About Streams and InvocationStateInfo.ps1 ├── 3.3.1.8.About Streams and InvocationStateInfo.ps1 ├── 3.4.1.1.Running multiple instances.ps1 ├── 3.4.1.2.Running multiple instances.ps1 ├── 3.4.1.3.Running multiple instances.ps1 ├── 3.4.1.4.Running multiple instances.ps1 ├── 3.5.1.1.Using the RunspacePool object.ps1 ├── 3.5.1.2.Using the RunspacePool object.ps1 ├── 3.5.1.3.Using the RunspacePool object.ps1 ├── 3.5.1.4.Using the RunspacePool object.ps1 ├── 3.5.1.5.Using the RunspacePool object.ps1 ├── 3.6.1.1.About the InitialSessionState object.ps1 ├── 3.6.1.2.About the InitialSessionState object.ps1 ├── 3.6.1.3.About the InitialSessionState object.ps1 ├── 3.6.2.1.Adding modules and snap-ins.ps1 ├── 3.6.2.2.Adding modules and snap-ins.ps1 ├── 3.6.2.3.Adding modules and snap-ins.ps1 ├── 3.6.3.1.Adding variables.ps1 ├── 3.6.3.2.Adding variables.ps1 ├── 3.6.3.3.Adding variables.ps1 ├── 3.6.3.4.Adding variables.ps1 ├── 3.6.4.1.Adding functions.ps1 ├── 3.6.4.2.Adding functions.ps1 ├── 3.6.4.3.Adding functions.ps1 ├── 3.7.1.1.Using the InitialSessionState and RunspacePool objects.ps1 ├── 3.7.1.2.Using the InitialSessionState and RunspacePool objects.ps1 ├── 4.0.0.1.Using thread-safe objects.ps1 ├── 4.0.0.2.Using thread-safe objects.ps1 ├── 4.0.0.3.Using thread-safe objects.ps1 ├── 4.0.0.4.Using thread-safe objects.ps1 ├── 4.0.0.5.Using thread-safe objects.ps1 ├── 5.0.0.1.Managing concurrent access.ps1 ├── 5.0.0.10.Managing concurrent access.ps1 ├── 5.0.0.11.Managing concurrent access.ps1 ├── 5.0.0.12.Managing concurrent access.ps1 ├── 5.0.0.13.Managing concurrent access.ps1 ├── 5.0.0.14.Managing concurrent access.ps1 ├── 5.0.0.15.Managing concurrent access.ps1 ├── 5.0.0.2.Managing concurrent access.ps1 ├── 5.0.0.3.Managing concurrent access.ps1 ├── 5.0.0.4.Managing concurrent access.ps1 ├── 5.0.0.5.Managing concurrent access.ps1 ├── 5.0.0.6.Managing concurrent access.ps1 ├── 5.0.0.7.Managing concurrent access.ps1 ├── 5.0.0.8.Managing concurrent access.ps1 └── 5.0.0.9.Managing concurrent access.ps1 ├── Chapter16 ├── 1.0.0.1.About Windows Presentation Foundation (WPF).ps1 ├── 3.0.0.1.About XAML.ps1 ├── 4.0.0.1.Displaying the UI.ps1 ├── 4.0.0.2.Displaying the UI.ps1 ├── 4.0.0.3.Displaying the UI.ps1 ├── 4.0.0.4.Displaying the UI.ps1 ├── 5.1.1.1.Using the Grid control.ps1 ├── 5.1.1.2.Using the Grid control.ps1 ├── 5.1.1.3.Using the Grid control.ps1 ├── 5.1.1.4.Using the Grid control.ps1 ├── 5.2.1.1.Using the StackPanel control.ps1 ├── 5.2.1.2.Using the StackPanel control.ps1 ├── 5.2.1.3.Using the StackPanel control.ps1 ├── 5.2.1.4.Using the StackPanel control.ps1 ├── 5.3.1.1.Using the DockPanel control.ps1 ├── 5.4.1.1.About Margin and Padding.ps1 ├── 5.4.1.2.About Margin and Padding.ps1 ├── 5.4.1.5.About Margin and Padding.ps1 ├── 6.0.0.1.Naming and locating controls.ps1 ├── 6.0.0.2.Naming and locating controls.ps1 ├── 6.0.0.3.Naming and locating controls.ps1 ├── 6.0.0.4.Naming and locating controls.ps1 ├── 6.0.0.5.Naming and locating controls.ps1 ├── 6.0.0.6.Naming and locating controls.ps1 ├── 6.0.0.7.Naming and locating controls.ps1 ├── 6.0.0.8.Naming and locating controls.ps1 ├── 7.0.0.1.Handling events.ps1 ├── 7.0.0.2.Handling events.ps1 ├── 7.0.0.3.Handling events.ps1 ├── 7.0.0.4.Handling events.ps1 ├── 7.1.1.1.Buttons and the Click event.ps1 ├── 7.1.1.2.Buttons and the Click event.ps1 ├── 7.1.1.3.Buttons and the Click event.ps1 ├── 7.2.1.1.ComboBox and SelectionChanged.ps1 ├── 7.3.1.1.Adding elements programmatically.ps1 ├── 7.3.1.2.Adding elements programmatically.ps1 ├── 7.4.1.1.Sorting a ListView.ps1 ├── 7.4.1.2.Sorting a ListView.ps1 ├── 7.4.1.3.Sorting a ListView.ps1 ├── 7.4.1.4.Sorting a ListView.ps1 ├── 7.4.1.5.Sorting a ListView.ps1 ├── 7.4.1.6.Sorting a ListView.ps1 ├── 7.4.1.7.Sorting a ListView.ps1 ├── 7.4.1.8.Sorting a ListView.ps1 ├── 7.4.1.9.Sorting a ListView.ps1 ├── 8.0.0.1.Responsive interfaces.ps1 ├── 8.1.1.1.Import-Xaml and Runspace support.ps1 ├── 8.2.1.1.Errors in the background.ps1 ├── 8.2.1.2.Errors in the background.ps1 ├── 8.3.1.1.Using the Dispatcher.ps1 ├── 8.3.1.2.Using the Dispatcher.ps1 ├── 8.3.1.3.Using the Dispatcher.ps1 ├── 8.3.1.4.Using the Dispatcher.ps1 ├── 8.3.1.5.Using the Dispatcher.ps1 ├── 8.3.1.6.Using the Dispatcher.ps1 ├── 8.3.1.7.Using the Dispatcher.ps1 ├── 8.4.1.1.ScriptBlock runspace affinity.ps1 ├── 8.4.1.2.ScriptBlock runspace affinity.ps1 ├── 8.5.1.1.Using the Action delegate.ps1 ├── 8.5.1.2.Using the Action delegate.ps1 ├── 8.5.1.3.Using the Action delegate.ps1 ├── 8.6.1.1.Using the Func delegate.ps1 ├── 8.6.1.2.Using the Func delegate.ps1 └── 8.6.1.3.Using the Func delegate.ps1 ├── Chapter17 ├── 2.1.1.1.Scripts and using statements.ps1 ├── 2.2.1.1.Scripts and Requires statement.ps1 ├── 2.2.1.2.Scripts and Requires statement.ps1 ├── 2.3.1.1.Nesting functions.ps1 ├── 2.4.1.1.Script blocks and closures.ps1 ├── 2.4.1.2.Script blocks and closures.ps1 ├── 2.4.1.3.Script blocks and closures.ps1 ├── 3.0.0.1.Parameters and the param block.ps1 ├── 3.0.0.2.Parameters and the param block.ps1 ├── 3.0.0.3.Parameters and the param block.ps1 ├── 3.0.0.4.Parameters and the param block.ps1 ├── 3.1.1.1.Parameter types.ps1 ├── 3.2.1.1.Default values.ps1 ├── 3.2.1.2.Default values.ps1 ├── 3.2.1.3.Default values.ps1 ├── 3.2.2.1.Cross-referencing parameters.ps1 ├── 4.0.0.1.The CmdletBinding attribute.ps1 ├── 4.1.1.1.Common parameters.ps1 ├── 4.1.1.2.Common parameters.ps1 ├── 4.1.1.3.Common parameters.ps1 ├── 4.1.1.4.Common parameters.ps1 ├── 4.2.1.1.CmdletBinding properties.ps1 ├── 4.2.1.2.CmdletBinding properties.ps1 ├── 4.2.1.3.CmdletBinding properties.ps1 ├── 4.3.1.1.ShouldProcess and ShouldContinue.ps1 ├── 4.3.2.1.ShouldProcess.ps1 ├── 4.3.2.2.ShouldProcess.ps1 ├── 4.3.2.3.ShouldProcess.ps1 ├── 4.3.2.4.ShouldProcess.ps1 ├── 4.3.2.5.ShouldProcess.ps1 ├── 4.3.2.6.ShouldProcess.ps1 ├── 4.3.2.7.ShouldProcess.ps1 ├── 4.3.2.8.ShouldProcess.ps1 ├── 4.3.3.1.ShouldContinue.ps1 ├── 4.3.3.2.ShouldContinue.ps1 ├── 4.3.3.3.ShouldContinue.ps1 ├── 4.3.3.4.ShouldContinue.ps1 ├── 4.3.3.5.ShouldContinue.ps1 ├── 5.0.0.1.The Alias attribute.ps1 ├── 5.0.0.2.The Alias attribute.ps1 ├── 5.0.0.3.The Alias attribute.ps1 ├── 6.0.0.1.begin, process, end, and clean.ps1 ├── 6.0.0.2.begin, process, end, and clean.ps1 ├── 6.1.1.1.begin.ps1 ├── 6.2.1.1.process.ps1 ├── 6.2.1.2.process.ps1 ├── 6.2.1.3.process.ps1 ├── 6.3.1.1.end.ps1 ├── 6.3.1.2.end.ps1 ├── 6.3.1.3.end.ps1 ├── 6.4.1.1.clean.ps1 ├── 6.4.1.2.clean.ps1 ├── 6.5.1.1.Named blocks and return.ps1 ├── 6.5.1.2.Named blocks and return.ps1 ├── 6.5.1.3.Named blocks and return.ps1 ├── 7.0.0.1.Managing output.ps1 ├── 7.0.0.2.Managing output.ps1 ├── 7.0.0.3.Managing output.ps1 ├── 7.1.1.1.The Out-Null command.ps1 ├── 7.2.1.1.Assigning to null.ps1 ├── 7.3.1.1.Redirecting to null.ps1 ├── 7.4.1.1.Casting to Void.ps1 ├── 7.4.1.2.Casting to Void.ps1 ├── 7.4.1.3.Casting to Void.ps1 ├── 8.0.0.1.Working with long lines.ps1 ├── 8.0.0.2.Working with long lines.ps1 ├── 8.1.1.1.Line break after a pipe.ps1 ├── 8.1.1.2.Line break after a pipe.ps1 ├── 8.1.1.3.Line break after a pipe.ps1 ├── 8.2.1.1.Line break after an operator.ps1 ├── 8.2.1.2.Line break after an operator.ps1 ├── 8.3.1.1.Using the array sub-expression operator to break up lines.ps1 ├── 8.3.1.2.Using the array sub-expression operator to break up lines.ps1 ├── 8.3.1.3.Using the array sub-expression operator to break up lines.ps1 ├── 8.3.1.4.Using the array sub-expression operator to break up lines.ps1 ├── 9.0.0.1.Comment-based help.ps1 ├── 9.0.0.2.Comment-based help.ps1 ├── 9.0.0.3.Comment-based help.ps1 ├── 9.1.1.1.Output help.ps1 ├── 9.1.1.2.Output help.ps1 ├── 9.1.1.3.Output help.ps1 ├── 9.1.1.4.Output help.ps1 ├── 9.1.1.5.Output help.ps1 ├── 9.2.1.1.Parameter help.ps1 ├── 9.2.1.2.Parameter help.ps1 ├── 9.2.1.3.Parameter help.ps1 ├── 9.2.1.4.Parameter help.ps1 ├── 9.2.1.5.Parameter help.ps1 ├── 9.2.1.6.Parameter help.ps1 ├── 9.2.1.7.Parameter help.ps1 ├── 9.2.1.8.Parameter help.ps1 ├── 9.3.1.1.Examples.ps1 └── 9.3.1.2.Examples.ps1 ├── Chapter18 ├── 1.0.0.1.The Parameter attribute.ps1 ├── 1.0.0.2.The Parameter attribute.ps1 ├── 1.0.0.3.The Parameter attribute.ps1 ├── 1.0.0.4.The Parameter attribute.ps1 ├── 1.0.0.5.The Parameter attribute.ps1 ├── 1.1.1.1.Position and positional binding.ps1 ├── 1.1.1.2.Position and positional binding.ps1 ├── 1.1.1.3.Position and positional binding.ps1 ├── 1.1.1.4.Position and positional binding.ps1 ├── 1.1.1.5.Position and positional binding.ps1 ├── 1.2.1.1.The DontShow property.ps1 ├── 1.3.1.1.The ValueFromRemainingArguments property.ps1 ├── 1.3.1.2.The ValueFromRemainingArguments property.ps1 ├── 1.3.1.3.The ValueFromRemainingArguments property.ps1 ├── 1.4.1.1.The HelpMessage property.ps1 ├── 1.4.1.2.The HelpMessage property.ps1 ├── 2.1.1.1.The PSTypeName attribute.ps1 ├── 2.1.1.2.The PSTypeName attribute.ps1 ├── 2.1.1.3.The PSTypeName attribute.ps1 ├── 2.1.1.4.The PSTypeName attribute.ps1 ├── 2.1.1.5.The PSTypeName attribute.ps1 ├── 2.1.1.6.The PSTypeName attribute.ps1 ├── 2.1.1.7.The PSTypeName attribute.ps1 ├── 2.1.1.8.The PSTypeName attribute.ps1 ├── 2.2.1.1.Validation attributes.ps1 ├── 2.2.10.1.The ValidateSet attribute.ps1 ├── 2.2.10.2.The ValidateSet attribute.ps1 ├── 2.2.11.1.The ValidateDrive attribute.ps1 ├── 2.2.12.1.The ValidateUserDrive attribute.ps1 ├── 2.2.12.2.The ValidateUserDrive attribute.ps1 ├── 2.2.2.1.The ValidateNotNull attribute.ps1 ├── 2.2.2.2.The ValidateNotNull attribute.ps1 ├── 2.2.2.3.The ValidateNotNull attribute.ps1 ├── 2.2.2.4.The ValidateNotNull attribute.ps1 ├── 2.2.2.5.The ValidateNotNull attribute.ps1 ├── 2.2.2.6.The ValidateNotNull attribute.ps1 ├── 2.2.2.7.The ValidateNotNull attribute.ps1 ├── 2.2.2.8.The ValidateNotNull attribute.ps1 ├── 2.2.2.9.The ValidateNotNull attribute.ps1 ├── 2.2.3.1.The ValidateNotNullOrEmpty attribute.ps1 ├── 2.2.4.1.The ValidateNotNullOrWhitespace attribute.ps1 ├── 2.2.5.1.The ValidateCount attribute.ps1 ├── 2.2.5.2.The ValidateCount attribute.ps1 ├── 2.2.5.3.The ValidateCount attribute.ps1 ├── 2.2.6.1.The ValidateLength attribute.ps1 ├── 2.2.6.2.The ValidateLength attribute.ps1 ├── 2.2.7.1.The ValidatePattern attribute.ps1 ├── 2.2.7.2.The ValidatePattern attribute.ps1 ├── 2.2.7.3.The ValidatePattern attribute.ps1 ├── 2.2.7.4.The ValidatePattern attribute.ps1 ├── 2.2.7.5.The ValidatePattern attribute.ps1 ├── 2.2.7.6.The ValidatePattern attribute.ps1 ├── 2.2.7.7.The ValidatePattern attribute.ps1 ├── 2.2.7.8.The ValidatePattern attribute.ps1 ├── 2.2.7.9.The ValidatePattern attribute.ps1 ├── 2.2.8.1.The ValidateRange attribute.ps1 ├── 2.2.9.1.The ValidateScript attribute.ps1 ├── 2.2.9.2.The ValidateScript attribute.ps1 ├── 2.2.9.3.The ValidateScript attribute.ps1 ├── 2.2.9.4.The ValidateScript attribute.ps1 ├── 2.3.2.1.The AllowNull attribute.ps1 ├── 2.3.3.1.The AllowEmptyString attribute.ps1 ├── 2.3.4.1.The AllowEmptyCollection attribute.ps1 ├── 2.3.4.2.The AllowEmptyCollection attribute.ps1 ├── 2.4.1.1.PSReference parameters.ps1 ├── 2.4.1.2.PSReference parameters.ps1 ├── 2.4.1.3.PSReference parameters.ps1 ├── 2.4.1.4.PSReference parameters.ps1 ├── 3.1.1.1.About ValueFromPipeline.ps1 ├── 3.2.1.1.Accepting null input.ps1 ├── 3.2.1.2.Accepting null input.ps1 ├── 3.2.1.3.Accepting null input.ps1 ├── 3.2.1.4.Accepting null input.ps1 ├── 3.3.1.1.Input object types.ps1 ├── 3.3.1.2.Input object types.ps1 ├── 3.4.1.1.Using ValueFromPipeline for multiple parameters.ps1 ├── 3.4.1.2.Using ValueFromPipeline for multiple parameters.ps1 ├── 3.4.1.3.Using ValueFromPipeline for multiple parameters.ps1 ├── 3.4.1.4.Using ValueFromPipeline for multiple parameters.ps1 ├── 3.5.1.1.About ValueFromPipelineByPropertyName.ps1 ├── 3.5.1.2.About ValueFromPipelineByPropertyName.ps1 ├── 3.5.1.3.About ValueFromPipelineByPropertyName.ps1 ├── 3.6.1.1.ValueFromPipelineByPropertyName and parameter aliases.ps1 ├── 3.6.1.2.ValueFromPipelineByPropertyName and parameter aliases.ps1 ├── 4.0.0.1.Defining parameter sets.ps1 ├── 4.0.0.2.Defining parameter sets.ps1 ├── 4.0.0.3.Defining parameter sets.ps1 ├── 4.0.0.4.Defining parameter sets.ps1 ├── 4.0.0.5.Defining parameter sets.ps1 ├── 4.0.0.6.Defining parameter sets.ps1 ├── 4.0.0.7.Defining parameter sets.ps1 ├── 4.0.0.8.Defining parameter sets.ps1 ├── 4.0.0.9.Defining parameter sets.ps1 ├── 5.0.0.1.Argument completers.ps1 ├── 5.1.1.1.The ArgumentCompleter attribute.ps1 ├── 5.2.1.1.Using Register-ArgumentCompleter.ps1 ├── 5.2.1.2.Using Register-ArgumentCompleter.ps1 ├── 5.3.1.1.About CompletionResult.ps1 ├── 5.4.1.1.Non-literal values.ps1 ├── 5.4.1.2.Non-literal values.ps1 ├── 5.4.1.3.Non-literal values.ps1 ├── 5.4.1.4.Non-literal values.ps1 ├── 5.4.1.5.Non-literal values.ps1 ├── 5.4.1.6.Non-literal values.ps1 ├── 5.5.1.1.Listing registered argument completers.ps1 ├── 6.0.0.1.Dynamic parameters.ps1 ├── 6.0.0.2.Dynamic parameters.ps1 ├── 6.1.1.1.Creating a RuntimeDefinedParameter object.ps1 ├── 6.1.1.2.Creating a RuntimeDefinedParameter object.ps1 ├── 6.1.1.3.Creating a RuntimeDefinedParameter object.ps1 ├── 6.2.1.1.Using RuntimeDefinedParameterDictionary.ps1 ├── 6.3.2.1.PSBoundParameters.ps1 ├── 6.3.2.2.PSBoundParameters.ps1 ├── 6.3.2.3.PSBoundParameters.ps1 ├── 6.3.3.1.RuntimeDefinedParameterDictionary.ps1 ├── 6.3.3.2.RuntimeDefinedParameterDictionary.ps1 ├── 6.4.1.1.Conditional parameters.ps1 └── scripts │ └── Get-ArgumentCompleter.ps1 ├── Chapter19 ├── 1.0.0.1.Defining an enumeration.ps1 ├── 1.0.0.2.Defining an enumeration.ps1 ├── 1.1.1.1.Enum and underlying types.ps1 ├── 1.1.1.2.Enum and underlying types.ps1 ├── 1.1.1.3.Enum and underlying types.ps1 ├── 1.1.1.4.Enum and underlying types.ps1 ├── 1.1.1.5.Enum and underlying types.ps1 ├── 1.1.1.6.Enum and underlying types.ps1 ├── 1.2.1.1.Automatic value assignment.ps1 ├── 1.2.1.2.Automatic value assignment.ps1 ├── 1.2.1.3.Automatic value assignment.ps1 ├── 1.2.1.4.Automatic value assignment.ps1 ├── 1.3.1.1.Enum or ValidateSet.ps1 ├── 1.3.1.2.Enum or ValidateSet.ps1 ├── 1.3.1.3.Enum or ValidateSet.ps1 ├── 1.3.1.4.Enum or ValidateSet.ps1 ├── 1.3.1.5.Enum or ValidateSet.ps1 ├── 1.4.1.1.The Flags attribute.ps1 ├── 1.4.1.10.The Flags attribute.ps1 ├── 1.4.1.11.The Flags attribute.ps1 ├── 1.4.1.12.The Flags attribute.ps1 ├── 1.4.1.2.The Flags attribute.ps1 ├── 1.4.1.3.The Flags attribute.ps1 ├── 1.4.1.4.The Flags attribute.ps1 ├── 1.4.1.5.The Flags attribute.ps1 ├── 1.4.1.6.The Flags attribute.ps1 ├── 1.4.1.7.The Flags attribute.ps1 ├── 1.4.1.8.The Flags attribute.ps1 ├── 1.4.1.9.The Flags attribute.ps1 ├── 1.5.1.1.Using enumerations to convert a value.ps1 ├── 1.5.1.2.Using enumerations to convert a value.ps1 ├── 1.5.1.3.Using enumerations to convert a value.ps1 ├── 2.0.0.1.Creating a class.ps1 ├── 2.0.0.2.Creating a class.ps1 ├── 2.0.0.3.Creating a class.ps1 ├── 2.0.0.4.Creating a class.ps1 ├── 2.1.1.1.Properties.ps1 ├── 2.1.1.2.Properties.ps1 ├── 2.1.1.3.Properties.ps1 ├── 2.10.1.1.Supporting casting.ps1 ├── 2.10.1.2.Supporting casting.ps1 ├── 2.10.1.3.Supporting casting.ps1 ├── 2.10.1.4.Supporting casting.ps1 ├── 2.10.1.5.Supporting casting.ps1 ├── 2.10.1.6.Supporting casting.ps1 ├── 2.10.1.7.Supporting casting.ps1 ├── 2.10.1.8.Supporting casting.ps1 ├── 2.2.1.1.Constructors.ps1 ├── 2.2.1.2.Constructors.ps1 ├── 2.2.1.3.Constructors.ps1 ├── 2.2.1.4.Constructors.ps1 ├── 2.3.1.1.Methods.ps1 ├── 2.3.1.2.Methods.ps1 ├── 2.3.1.3.Methods.ps1 ├── 2.3.1.4.Methods.ps1 ├── 2.4.1.1.The Hidden modifier.ps1 ├── 2.4.1.2.The Hidden modifier.ps1 ├── 2.5.1.1.The Static modifier.ps1 ├── 2.5.1.2.The Static modifier.ps1 ├── 2.6.1.1.Inheritance.ps1 ├── 2.6.1.2.Inheritance.ps1 ├── 2.6.1.3.Inheritance.ps1 ├── 2.6.1.4.Inheritance.ps1 ├── 2.6.1.5.Inheritance.ps1 ├── 2.7.1.1.Constructors and inheritance.ps1 ├── 2.7.1.10.Constructors and inheritance.ps1 ├── 2.7.1.2.Constructors and inheritance.ps1 ├── 2.7.1.3.Constructors and inheritance.ps1 ├── 2.7.1.4.Constructors and inheritance.ps1 ├── 2.7.1.5.Constructors and inheritance.ps1 ├── 2.7.1.6.Constructors and inheritance.ps1 ├── 2.7.1.7.Constructors and inheritance.ps1 ├── 2.7.1.8.Constructors and inheritance.ps1 ├── 2.7.1.9.Constructors and inheritance.ps1 ├── 2.8.1.1.Calling methods in a parent class.ps1 ├── 2.8.1.2.Calling methods in a parent class.ps1 ├── 2.9.1.1.Working with interfaces.ps1 ├── 2.9.2.1.Implementing IComparable.ps1 ├── 2.9.2.2.Implementing IComparable.ps1 ├── 2.9.2.3.Implementing IComparable.ps1 ├── 2.9.2.4.Implementing IComparable.ps1 ├── 2.9.2.5.Implementing IComparable.ps1 ├── 2.9.3.1.Implementing IEquatable.ps1 ├── 2.9.3.2.Implementing IEquatable.ps1 ├── 2.9.3.3.Implementing IEquatable.ps1 ├── 3.0.0.1.Classes and Runspace affinity.ps1 ├── 3.0.0.2.Classes and Runspace affinity.ps1 ├── 3.0.0.3.Classes and Runspace affinity.ps1 ├── 3.0.0.4.Classes and Runspace affinity.ps1 ├── 4.1.1.1.Argument-transformation attribute classes.ps1 ├── 4.1.1.2.Argument-transformation attribute classes.ps1 ├── 4.1.1.3.Argument-transformation attribute classes.ps1 ├── 4.1.1.4.Argument-transformation attribute classes.ps1 ├── 4.2.2.1.ValidateArgumentsAttribute.ps1 ├── 4.2.2.2.ValidateArgumentsAttribute.ps1 ├── 4.2.2.3.ValidateArgumentsAttribute.ps1 ├── 4.2.2.4.ValidateArgumentsAttribute.ps1 ├── 4.2.3.1.ValidateEnumeratedArgumentsAttribute.ps1 ├── 4.2.3.2.ValidateEnumeratedArgumentsAttribute.ps1 ├── 4.2.3.3.ValidateEnumeratedArgumentsAttribute.ps1 ├── 4.2.3.4.ValidateEnumeratedArgumentsAttribute.ps1 ├── 4.2.3.5.ValidateEnumeratedArgumentsAttribute.ps1 ├── 4.3.1.1.ValidateSet value generator.ps1 ├── 4.3.1.2.ValidateSet value generator.ps1 ├── 4.4.2.1.IArgumentCompleter.ps1 ├── 4.4.2.2.IArgumentCompleter.ps1 ├── 4.4.2.3.IArgumentCompleter.ps1 ├── 4.4.3.1.IArgumentCompleterFactory.ps1 ├── 4.4.3.2.IArgumentCompleterFactory.ps1 ├── 4.4.3.3.IArgumentCompleterFactory.ps1 ├── 4.4.3.4.IArgumentCompleterFactory.ps1 ├── 5.0.0.1.Classes and Microsoft Desired State Configuration.ps1 ├── 5.0.0.2.Classes and Microsoft Desired State Configuration.ps1 ├── 5.1.1.1.Implementing Get.ps1 ├── 5.1.1.2.Implementing Get.ps1 ├── 5.2.1.1.Implementing Set.ps1 ├── 5.2.1.2.Implementing Set.ps1 ├── 5.3.1.1.Implementing Test.ps1 ├── 5.3.1.2.Implementing Test.ps1 ├── 5.3.1.3.Implementing Test.ps1 ├── 5.4.1.1.Using the resource.ps1 ├── 5.4.1.2.Using the resource.ps1 ├── 5.4.1.3.Using the resource.ps1 ├── 5.4.1.4.Using the resource.ps1 ├── 5.4.1.5.Using the resource.ps1 └── 5.4.1.6.Using the resource.ps1 ├── Chapter20 ├── 2.1.1.1.The root module.ps1 ├── 2.1.1.2.The root module.ps1 ├── 2.1.1.3.The root module.ps1 ├── 2.1.1.4.The root module.ps1 ├── 2.2.1.1.Export-ModuleMember.ps1 ├── 2.2.1.2.Export-ModuleMember.ps1 ├── 2.2.1.3.Export-ModuleMember.ps1 ├── 2.2.1.4.Export-ModuleMember.ps1 ├── 2.2.1.5.Export-ModuleMember.ps1 ├── 2.2.1.6.Export-ModuleMember.ps1 ├── 2.2.1.7.Export-ModuleMember.ps1 ├── 2.2.1.8.Export-ModuleMember.ps1 ├── 2.3.1.1.Module manifests.ps1 ├── 2.3.2.1.Test-ModuleManifest.ps1 ├── 2.3.3.1.Update-ModuleManifest.ps1 ├── 2.3.3.2.Update-ModuleManifest.ps1 ├── 2.3.3.3.Update-ModuleManifest.ps1 ├── 3.0.0.1.Publishing a module.ps1 ├── 3.0.0.2.Publishing a module.ps1 ├── 3.0.0.3.Publishing a module.ps1 ├── 3.0.0.4.Publishing a module.ps1 ├── 3.0.0.5.Publishing a module.ps1 ├── 3.0.0.6.Publishing a module.ps1 ├── 3.1.1.1.Publishing and side-by-side versioning.ps1 ├── 4.1.1.1.Dot sourcing module content.ps1 ├── 4.1.1.2.Dot sourcing module content.ps1 ├── 4.1.1.3.Dot sourcing module content.ps1 ├── 4.2.1.1.Merging module content.ps1 ├── 4.2.1.2.Merging module content.ps1 ├── 4.2.1.3.Merging module content.ps1 ├── 4.3.1.1.ModuleBuilder and DSC resources.ps1 ├── 4.3.1.2.ModuleBuilder and DSC resources.ps1 ├── 5.0.0.1.Module scope.ps1 ├── 5.0.0.2.Module scope.ps1 ├── 5.0.0.3.Module scope.ps1 ├── 5.1.1.1.Accessing module scope.ps1 ├── 5.1.1.2.Accessing module scope.ps1 ├── 5.1.1.3.Accessing module scope.ps1 ├── 5.1.1.4.Accessing module scope.ps1 ├── 5.1.1.5.Accessing module scope.ps1 ├── 5.1.1.6.Accessing module scope.ps1 ├── 5.2.1.1.Modules, classes, and enumerations.ps1 ├── 5.2.1.2.Modules, classes, and enumerations.ps1 ├── 5.2.1.3.Modules, classes, and enumerations.ps1 ├── 5.2.1.4.Modules, classes, and enumerations.ps1 ├── 5.2.1.5.Modules, classes, and enumerations.ps1 ├── 5.2.1.6.Modules, classes, and enumerations.ps1 ├── 5.2.1.7.Modules, classes, and enumerations.ps1 ├── 6.1.1.1.The ScriptsToProcess property.ps1 ├── 6.1.1.2.The ScriptsToProcess property.ps1 ├── 6.1.1.3.The ScriptsToProcess property.ps1 ├── 6.1.1.4.The ScriptsToProcess property.ps1 ├── 6.2.1.1.The OnRemove event.ps1 ├── 6.2.1.2.The OnRemove event.ps1 ├── 6.2.1.3.The OnRemove event.ps1 ├── 6.2.1.4.The OnRemove event.ps1 ├── 6.2.1.5.The OnRemove event.ps1 ├── 6.2.1.6.The OnRemove event.ps1 └── LocalMachine │ ├── MultiFile │ └── LocalMachine │ │ ├── LocalMachine.psd1 │ │ ├── LocalMachine.psm1 │ │ ├── private │ │ └── GetRegistryParameter.ps1 │ │ ├── public │ │ ├── Get-ComputerDescription.ps1 │ │ ├── Remove-ComputerDescription.ps1 │ │ └── Set-ComputerDescription.ps1 │ │ └── test.ps1 │ ├── MultiFileWithModuleBuilder │ ├── LocalMachine │ │ ├── LocalMachine.psd1 │ │ ├── LocalMachine.psm1 │ │ ├── build.psd1 │ │ ├── classes │ │ │ └── ComputerDescription.ps1 │ │ ├── enum │ │ │ └── Ensure.ps1 │ │ ├── private │ │ │ └── GetRegistryParameter.ps1 │ │ └── public │ │ │ ├── Get-ComputerDescription.ps1 │ │ │ ├── Remove-ComputerDescription.ps1 │ │ │ └── Set-ComputerDescription.ps1 │ ├── build.ps1 │ └── build │ │ └── LocalMachine │ │ └── 1.0.0 │ │ ├── LocalMachine.psd1 │ │ └── LocalMachine.psm1 │ ├── SingleFile │ └── LocalMachine │ │ └── LocalMachine.psm1 │ └── SingleFileWithManifest │ └── LocalMachine │ ├── LocalMachine.psd1 │ └── LocalMachine.psm1 ├── Chapter21 ├── 2.0.0.1.Static analysis.ps1 ├── 2.1.1.1.PSScriptAnalyzer.ps1 ├── 2.1.1.2.PSScriptAnalyzer.ps1 ├── 2.1.1.3.PSScriptAnalyzer.ps1 ├── 2.1.2.1.Configurable rules.ps1 ├── 2.1.2.2.Configurable rules.ps1 ├── 2.1.2.3.Configurable rules.ps1 ├── 2.1.2.4.Configurable rules.ps1 ├── 2.1.3.1.Suppressing rules.ps1 ├── 2.1.3.2.Suppressing rules.ps1 ├── 2.1.3.3.Suppressing rules.ps1 ├── 2.1.3.4.Suppressing rules.ps1 ├── 2.1.3.5.Suppressing rules.ps1 ├── 2.1.3.6.Suppressing rules.ps1 ├── 2.1.3.7.Suppressing rules.ps1 ├── 2.2.1.1.Using AST.ps1 ├── 2.2.1.2.Using AST.ps1 ├── 2.2.1.3.Using AST.ps1 ├── 2.2.1.4.Using AST.ps1 ├── 2.2.1.5.Using AST.ps1 ├── 2.2.1.6.Using AST.ps1 ├── 2.2.1.7.Using AST.ps1 ├── 2.2.1.8.Using AST.ps1 ├── 2.2.2.1.Visualizing the AST.ps1 ├── 2.2.2.2.Visualizing the AST.ps1 ├── 2.2.3.1.Searching the AST.ps1 ├── 2.2.3.2.Searching the AST.ps1 ├── 2.2.3.3.Searching the AST.ps1 ├── 2.2.3.4.Searching the AST.ps1 ├── 2.2.3.5.Searching the AST.ps1 ├── 2.2.3.6.Searching the AST.ps1 ├── 2.2.3.7.Searching the AST.ps1 ├── 2.3.1.1.Tokenizer.ps1 ├── 2.3.1.2.Tokenizer.ps1 ├── 2.4.3.1.AST-based rules.ps1 ├── 2.4.3.2.AST-based rules.ps1 ├── 2.4.3.3.AST-based rules.ps1 ├── 2.4.4.1.Token-based rules.ps1 ├── 2.4.4.2.Token-based rules.ps1 ├── 2.4.4.3.Token-based rules.ps1 ├── 3.0.0.1.Testing with Pester.ps1 ├── 3.0.0.2.Testing with Pester.ps1 ├── 3.0.0.3.Testing with Pester.ps1 ├── 3.0.0.4.Testing with Pester.ps1 ├── 3.0.0.5.Testing with Pester.ps1 ├── 3.10.2.1.Adding methods to PSCustomObject.ps1 ├── 3.10.2.2.Adding methods to PSCustomObject.ps1 ├── 3.10.2.3.Adding methods to PSCustomObject.ps1 ├── 3.10.3.1.Disarming .NET types.ps1 ├── 3.10.3.2.Disarming .NET types.ps1 ├── 3.10.3.3.Disarming .NET types.ps1 ├── 3.10.3.4.Disarming .NET types.ps1 ├── 3.10.3.5.Disarming .NET types.ps1 ├── 3.10.3.6.Disarming .NET types.ps1 ├── 3.10.4.1.Mocking CIM objects.ps1 ├── 3.10.4.2.Mocking CIM objects.ps1 ├── 3.10.4.3.Mocking CIM objects.ps1 ├── 3.10.4.4.Mocking CIM objects.ps1 ├── 3.10.4.5.Mocking CIM objects.ps1 ├── 3.10.4.6.Mocking CIM objects.ps1 ├── 3.10.4.7.Mocking CIM objects.ps1 ├── 3.11.1.1.InModuleScope.ps1 ├── 3.11.1.2.InModuleScope.ps1 ├── 3.11.1.3.InModuleScope.ps1 ├── 3.11.1.4.InModuleScope.ps1 ├── 3.12.1.1.Pester in scripts.ps1 ├── 3.12.1.2.Pester in scripts.ps1 ├── 3.12.1.3.Pester in scripts.ps1 ├── 3.12.1.4.Pester in scripts.ps1 ├── 3.12.1.5.Pester in scripts.ps1 ├── 3.12.1.6.Pester in scripts.ps1 ├── 3.3.2.1.About the Describe and Context keywords.ps1 ├── 3.3.3.1.About the It keyword.ps1 ├── 3.4.1.1.Should and assertions.ps1 ├── 3.4.2.1.Testing for errors.ps1 ├── 3.4.2.2.Testing for errors.ps1 ├── 3.4.2.3.Testing for errors.ps1 ├── 3.4.2.4.Testing for errors.ps1 ├── 3.4.2.5.Testing for errors.ps1 ├── 3.4.2.6.Testing for errors.ps1 ├── 3.5.2.1.Using the ForEach parameter.ps1 ├── 3.5.2.2.Using the ForEach parameter.ps1 ├── 3.5.2.3.Using the ForEach parameter.ps1 ├── 3.5.2.4.Using the ForEach parameter.ps1 ├── 3.5.3.1.ForEach with Describe and Context.ps1 ├── 3.5.3.2.ForEach with Describe and Context.ps1 ├── 3.6.2.1.Using Set-ItResult.ps1 ├── 3.6.2.2.Using Set-ItResult.ps1 ├── 3.6.3.1.Using Skip.ps1 ├── 3.7.1.1.Pester phases.ps1 ├── 3.7.1.2.Pester phases.ps1 ├── 3.9.1.1.Mocking commands.ps1 ├── 3.9.1.2.Mocking commands.ps1 ├── 3.9.1.3.Mocking commands.ps1 ├── 3.9.1.4.Mocking commands.ps1 ├── 3.9.1.5.Mocking commands.ps1 ├── 3.9.1.6.Mocking commands.ps1 ├── 3.9.2.1.Parameter variables.ps1 ├── 3.9.2.2.Parameter variables.ps1 ├── 3.9.2.3.Parameter variables.ps1 ├── 3.9.3.1.Parameter filtering.ps1 ├── 3.9.3.2.Parameter filtering.ps1 ├── 3.9.3.3.Parameter filtering.ps1 ├── 3.9.3.4.Parameter filtering.ps1 ├── 3.9.3.5.Parameter filtering.ps1 ├── 3.9.4.1.Overriding mocks.ps1 ├── 3.9.4.2.Overriding mocks.ps1 ├── 3.9.4.3.Overriding mocks.ps1 ├── 3.9.4.4.Overriding mocks.ps1 ├── 3.9.4.5.Overriding mocks.ps1 ├── 3.9.5.1.Mocking non-local commands.ps1 ├── 3.9.5.2.Mocking non-local commands.ps1 ├── 3.9.5.3.Mocking non-local commands.ps1 ├── 3.9.5.4.Mocking non-local commands.ps1 └── 3.9.5.5.Mocking non-local commands.ps1 ├── Chapter22 ├── 1.1.1.1.Terminating errors.ps1 ├── 1.1.1.2.Terminating errors.ps1 ├── 1.1.1.3.Terminating errors.ps1 ├── 1.1.1.4.Terminating errors.ps1 ├── 1.2.1.1.Non-terminating errors.ps1 ├── 1.2.1.2.Non-terminating errors.ps1 ├── 2.0.0.1.Error actions.ps1 ├── 2.0.0.2.Error actions.ps1 ├── 2.0.0.3.Error actions.ps1 ├── 2.1.1.1.About Get-Error.ps1 ├── 3.1.1.1.Error records.ps1 ├── 3.1.1.2.Error records.ps1 ├── 3.1.1.3.Error records.ps1 ├── 3.1.1.4.Error records.ps1 ├── 3.2.1.1.Raising non-terminating errors.ps1 ├── 3.2.1.2.Raising non-terminating errors.ps1 ├── 3.2.1.3.Raising non-terminating errors.ps1 ├── 3.2.1.4.Raising non-terminating errors.ps1 ├── 3.2.1.5.Raising non-terminating errors.ps1 ├── 3.2.1.6.Raising non-terminating errors.ps1 ├── 3.2.1.7.Raising non-terminating errors.ps1 ├── 3.2.1.8.Raising non-terminating errors.ps1 ├── 3.3.1.1.Using the WriteError method.ps1 ├── 3.3.1.2.Using the WriteError method.ps1 ├── 3.3.1.3.Using the WriteError method.ps1 ├── 3.3.1.4.Using the WriteError method.ps1 ├── 3.3.1.5.Using the WriteError method.ps1 ├── 3.3.1.6.Using the WriteError method.ps1 ├── 3.4.1.1.Raising terminating errors.ps1 ├── 3.4.1.2.Raising terminating errors.ps1 ├── 3.4.1.3.Raising terminating errors.ps1 ├── 3.5.1.1.Using the ThrowTerminatingError method.ps1 ├── 3.5.1.2.Using the ThrowTerminatingError method.ps1 ├── 4.1.1.1.ErrorVariable.ps1 ├── 4.1.1.2.ErrorVariable.ps1 ├── 4.1.1.3.ErrorVariable.ps1 ├── 4.1.1.4.ErrorVariable.ps1 ├── 4.1.1.5.ErrorVariable.ps1 ├── 4.2.1.1.try, catch, and finally.ps1 ├── 4.2.1.10.try, catch, and finally.ps1 ├── 4.2.1.11.try, catch, and finally.ps1 ├── 4.2.1.2.try, catch, and finally.ps1 ├── 4.2.1.3.try, catch, and finally.ps1 ├── 4.2.1.4.try, catch, and finally.ps1 ├── 4.2.1.5.try, catch, and finally.ps1 ├── 4.2.1.6.try, catch, and finally.ps1 ├── 4.2.1.7.try, catch, and finally.ps1 ├── 4.2.1.8.try, catch, and finally.ps1 ├── 4.2.1.9.try, catch, and finally.ps1 ├── 4.2.2.1.Rethrowing errors.ps1 ├── 4.2.2.10.Rethrowing errors.ps1 ├── 4.2.2.2.Rethrowing errors.ps1 ├── 4.2.2.3.Rethrowing errors.ps1 ├── 4.2.2.4.Rethrowing errors.ps1 ├── 4.2.2.5.Rethrowing errors.ps1 ├── 4.2.2.6.Rethrowing errors.ps1 ├── 4.2.2.7.Rethrowing errors.ps1 ├── 4.2.2.8.Rethrowing errors.ps1 ├── 4.2.2.9.Rethrowing errors.ps1 ├── 4.3.1.1.Inconsistent error handling.ps1 ├── 4.3.1.2.Inconsistent error handling.ps1 ├── 4.3.1.3.Inconsistent error handling.ps1 ├── 4.3.1.4.Inconsistent error handling.ps1 ├── 4.3.1.5.Inconsistent error handling.ps1 ├── 4.3.1.6.Inconsistent error handling.ps1 ├── 4.3.1.7.Inconsistent error handling.ps1 ├── 4.3.2.1.throw and ErrorAction.ps1 ├── 4.3.2.10.throw and ErrorAction.ps1 ├── 4.3.2.2.throw and ErrorAction.ps1 ├── 4.3.2.3.throw and ErrorAction.ps1 ├── 4.3.2.4.throw and ErrorAction.ps1 ├── 4.3.2.5.throw and ErrorAction.ps1 ├── 4.3.2.6.throw and ErrorAction.ps1 ├── 4.3.2.7.throw and ErrorAction.ps1 ├── 4.3.2.8.throw and ErrorAction.ps1 ├── 4.3.2.9.throw and ErrorAction.ps1 ├── 4.3.3.1.Terminating errors in child scopes.ps1 ├── 4.3.3.2.Terminating errors in child scopes.ps1 ├── 4.3.3.3.Terminating errors in child scopes.ps1 ├── 4.3.3.4.Terminating errors in child scopes.ps1 ├── 4.4.1.1.Nesting try, catch, and finally.ps1 ├── 4.4.1.2.Nesting try, catch, and finally.ps1 ├── 4.4.1.3.Nesting try, catch, and finally.ps1 ├── 4.4.1.4.Nesting try, catch, and finally.ps1 ├── 5.1.1.1.Using trap.ps1 ├── 5.1.1.2.Using trap.ps1 ├── 5.1.1.3.Using trap.ps1 ├── 5.1.1.4.Using trap.ps1 ├── 5.2.1.1.trap, scope, and continue.ps1 └── 5.2.1.2.trap, scope, and continue.ps1 ├── Chapter23 ├── 1.1.1.1.Dash characters.ps1 ├── 1.1.1.2.Dash characters.ps1 ├── 1.2.2.1.Assignment instead of equality.ps1 ├── 1.2.2.2.Assignment instead of equality.ps1 ├── 1.2.2.3.Assignment instead of equality.ps1 ├── 1.2.3.1.-or instead of -and.ps1 ├── 1.2.3.2.-or instead of -and.ps1 ├── 1.2.3.3.-or instead of -and.ps1 ├── 1.2.4.1.Negated array comparisons.ps1 ├── 1.2.4.2.Negated array comparisons.ps1 ├── 1.3.2.1.Code outside of a named block.ps1 ├── 1.3.2.2.Code outside of a named block.ps1 ├── 1.3.2.3.Code outside of a named block.ps1 ├── 1.3.3.1.Pipeline without process.ps1 ├── 1.3.3.2.Pipeline without process.ps1 ├── 1.3.3.3.Pipeline without process.ps1 ├── 1.3.3.4.Pipeline without process.ps1 ├── 1.4.2.1.About strict mode.ps1 ├── 1.4.2.2.About strict mode.ps1 ├── 1.4.2.3.About strict mode.ps1 ├── 1.4.2.4.About strict mode.ps1 ├── 1.4.2.5.About strict mode.ps1 ├── 1.4.2.6.About strict mode.ps1 ├── 1.4.2.7.About strict mode.ps1 ├── 1.4.3.1.Variables and types.ps1 ├── 1.4.3.2.Variables and types.ps1 ├── 1.4.3.3.Variables and types.ps1 ├── 1.4.4.1.Types and reserved variables.ps1 ├── 1.4.4.2.Types and reserved variables.ps1 ├── 1.4.4.3.Types and reserved variables.ps1 ├── 1.4.4.4.Types and reserved variables.ps1 ├── 2.0.0.1.Debugging in the console.ps1 ├── 2.1.1.1.Setting a command breakpoint.ps1 ├── 2.1.1.2.Setting a command breakpoint.ps1 ├── 2.1.1.3.Setting a command breakpoint.ps1 ├── 2.1.1.4.Setting a command breakpoint.ps1 ├── 2.1.1.5.Setting a command breakpoint.ps1 ├── 2.2.1.1.Using variable breakpoints.ps1 ├── 2.2.1.2.Using variable breakpoints.ps1 ├── 2.2.1.3.Using variable breakpoints.ps1 ├── 2.2.1.4.Using variable breakpoints.ps1 ├── 2.3.1.1.Setting a line breakpoint.ps1 ├── 2.3.1.2.Setting a line breakpoint.ps1 ├── 2.3.1.3.Setting a line breakpoint.ps1 ├── 2.3.1.4.Setting a line breakpoint.ps1 ├── 2.3.1.5.Setting a line breakpoint.ps1 ├── 3.1.1.1.Using the debugger.ps1 ├── 3.2.1.1.Viewing the CALL STACK.ps1 ├── 3.2.1.2.Viewing the CALL STACK.ps1 ├── 3.3.1.1.Using launch configurations.ps1 ├── 3.5.1.1.Using WATCH.ps1 ├── 4.0.0.1.Debugging other PowerShell processes.ps1 ├── 4.0.0.2.Debugging other PowerShell processes.ps1 └── 4.0.0.3.Debugging other PowerShell processes.ps1 ├── LICENSE └── README.md /Chapter01/10.0.0.1.Parser modes.ps1: -------------------------------------------------------------------------------- 1 | Get-Process -Name pwsh 2 | -------------------------------------------------------------------------------- /Chapter01/10.0.0.5.Parser modes.ps1: -------------------------------------------------------------------------------- 1 | Get-Date ([DayOfWeek]::Monday) 2 | -------------------------------------------------------------------------------- /Chapter01/11.0.0.2.Experimental features.ps1: -------------------------------------------------------------------------------- 1 | Get-ExperimentalFeature | Format-Table Name, Description -Wrap 2 | -------------------------------------------------------------------------------- /Chapter01/11.0.0.3.Experimental features.ps1: -------------------------------------------------------------------------------- 1 | Enable-ExperimentalFeature -Name PSCommandNotFoundSuggestion 2 | -------------------------------------------------------------------------------- /Chapter01/11.0.0.5.Experimental features.ps1: -------------------------------------------------------------------------------- 1 | Disable-ExperimentalFeature -Name PSCommandNotFoundSuggestion 2 | -------------------------------------------------------------------------------- /Chapter01/2.0.0.1.The command line.ps1: -------------------------------------------------------------------------------- 1 | Set-PSReadLineOption -PredictionSource HistoryAndPlugin 2 | -------------------------------------------------------------------------------- /Chapter01/2.0.0.2.The command line.ps1: -------------------------------------------------------------------------------- 1 | function prompt { 2 | "$env:USERNAME $pwd PS>" 3 | } 4 | -------------------------------------------------------------------------------- /Chapter01/2.0.0.3.The command line.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_profiles 2 | -------------------------------------------------------------------------------- /Chapter01/4.1.1.2.Updatable help.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_Updatable_Help 2 | -------------------------------------------------------------------------------- /Chapter01/4.2.1.2.The Get-Help command.ps1: -------------------------------------------------------------------------------- 1 | Get-Help default | more 2 | -------------------------------------------------------------------------------- /Chapter01/4.2.1.3.The Get-Help command.ps1: -------------------------------------------------------------------------------- 1 | Get-Help default -ShowWindow 2 | -------------------------------------------------------------------------------- /Chapter01/4.2.1.4.The Get-Help command.ps1: -------------------------------------------------------------------------------- 1 | Get-Help * 2 | Get-Help -Category All 3 | -------------------------------------------------------------------------------- /Chapter01/4.2.1.5.The Get-Help command.ps1: -------------------------------------------------------------------------------- 1 | Get-Help Get-Variable 2 | -------------------------------------------------------------------------------- /Chapter01/4.2.1.6.The Get-Help command.ps1: -------------------------------------------------------------------------------- 1 | Get-Help Get-Command -Online 2 | -------------------------------------------------------------------------------- /Chapter01/4.2.1.7.The Get-Help command.ps1: -------------------------------------------------------------------------------- 1 | Get-Command Get-Command | Select-Object HelpUri 2 | -------------------------------------------------------------------------------- /Chapter01/4.2.2.1.Syntax.ps1: -------------------------------------------------------------------------------- 1 | Get-Process 2 | Get-Process pwsh 3 | Get-Process -Name pwsh 4 | -------------------------------------------------------------------------------- /Chapter01/4.2.3.1.Examples.ps1: -------------------------------------------------------------------------------- 1 | Get-Help Get-Process -Examples 2 | -------------------------------------------------------------------------------- /Chapter01/4.3.1.3.Save-Help.ps1: -------------------------------------------------------------------------------- 1 | Save-Help -Module Microsoft.PowerShell.Management -DestinationPath C:\PSHelp -UICulture en-US 2 | -------------------------------------------------------------------------------- /Chapter01/4.3.1.5.Save-Help.ps1: -------------------------------------------------------------------------------- 1 | Save-Help -Module Microsoft.PowerShell.Management -DestinationPath C:\PSHelp -UICulture pl-PL -Force 2 | -------------------------------------------------------------------------------- /Chapter01/4.3.1.6.Save-Help.ps1: -------------------------------------------------------------------------------- 1 | Save-Help -DestinationPath C:\PSHelp -UICulture en-US 2 | -------------------------------------------------------------------------------- /Chapter01/4.4.1.1.Update-Help.ps1: -------------------------------------------------------------------------------- 1 | Update-Help 2 | -------------------------------------------------------------------------------- /Chapter01/4.4.1.2.Update-Help.ps1: -------------------------------------------------------------------------------- 1 | Update-Help -Scope CurrentUser 2 | -------------------------------------------------------------------------------- /Chapter01/4.4.1.3.Update-Help.ps1: -------------------------------------------------------------------------------- 1 | Update-Help -UICulture en-US 2 | -------------------------------------------------------------------------------- /Chapter01/4.4.1.4.Update-Help.ps1: -------------------------------------------------------------------------------- 1 | Update-Help -Name Microsoft.PowerShell.Management -Force -UICulture en-US 2 | -------------------------------------------------------------------------------- /Chapter01/4.4.1.5.Update-Help.ps1: -------------------------------------------------------------------------------- 1 | Update-Help -SourcePath C:\PSHelp 2 | -------------------------------------------------------------------------------- /Chapter01/4.4.1.6.Update-Help.ps1: -------------------------------------------------------------------------------- 1 | Update-Help -Module Microsoft.PowerShell.Management -SourcePath C:\PSHelp -UICulture en-US 2 | -------------------------------------------------------------------------------- /Chapter01/4.5.1.1.About_ help files.ps1: -------------------------------------------------------------------------------- 1 | Get-Help -Category HelpFile 2 | -------------------------------------------------------------------------------- /Chapter01/5.1.1.1.Verbs.ps1: -------------------------------------------------------------------------------- 1 | Get-Verb 2 | -------------------------------------------------------------------------------- /Chapter01/5.3.1.2.Finding commands.ps1: -------------------------------------------------------------------------------- 1 | Get-Command -Verb Get, Set -Noun *Firewall* 2 | -------------------------------------------------------------------------------- /Chapter01/5.3.1.3.Finding commands.ps1: -------------------------------------------------------------------------------- 1 | Get-Help Get-*Firewall* 2 | -------------------------------------------------------------------------------- /Chapter01/5.4.1.2.Aliases.ps1: -------------------------------------------------------------------------------- 1 | Get-Alias dir 2 | -------------------------------------------------------------------------------- /Chapter01/5.4.1.4.Aliases.ps1: -------------------------------------------------------------------------------- 1 | cd $env:TEMP 2 | Set-Location $env:TEMP 3 | -------------------------------------------------------------------------------- /Chapter01/5.4.1.5.Aliases.ps1: -------------------------------------------------------------------------------- 1 | New-Alias grep -Value Select-String 2 | -------------------------------------------------------------------------------- /Chapter01/5.4.1.6.Aliases.ps1: -------------------------------------------------------------------------------- 1 | Remove-Alias grep 2 | -------------------------------------------------------------------------------- /Chapter01/5.4.1.7.Aliases.ps1: -------------------------------------------------------------------------------- 1 | Remove-Item alias:\grep 2 | -------------------------------------------------------------------------------- /Chapter01/5.4.1.8.Aliases.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_Aliases 2 | -------------------------------------------------------------------------------- /Chapter01/6.0.0.3.About profile scripts.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_profiles 2 | -------------------------------------------------------------------------------- /Chapter01/7.1.2.1.Optional parameters.ps1: -------------------------------------------------------------------------------- 1 | Get-Help -Category HelpFile 2 | -------------------------------------------------------------------------------- /Chapter01/7.1.3.1.Optional positional parameters.ps1: -------------------------------------------------------------------------------- 1 | Get-Process -Name pwsh 2 | Get-Process pwsh 3 | -------------------------------------------------------------------------------- /Chapter01/7.1.4.1.Mandatory parameters.ps1: -------------------------------------------------------------------------------- 1 | Get-ADUser -Filter 'sAMAccountName -eq "SomeName"' 2 | -------------------------------------------------------------------------------- /Chapter01/7.1.5.1.Mandatory positional parameters.ps1: -------------------------------------------------------------------------------- 1 | Get-ADUser -Identity useridentity 2 | Get-ADUser useridentity 3 | -------------------------------------------------------------------------------- /Chapter01/7.1.6.1.Switch parameters.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem c:\windows -Recurse 2 | -------------------------------------------------------------------------------- /Chapter01/7.2.1.1.Parameter values.ps1: -------------------------------------------------------------------------------- 1 | Get-CimInstance -ClassName Win32_Service 2 | -------------------------------------------------------------------------------- /Chapter01/7.2.1.4.Parameter values.ps1: -------------------------------------------------------------------------------- 1 | Get-Service -Name WinDefend 2 | -------------------------------------------------------------------------------- /Chapter01/7.2.1.5.Parameter values.ps1: -------------------------------------------------------------------------------- 1 | Get-Service WinDefend 2 | Get-Service WinDefend, WlanSvc 3 | -------------------------------------------------------------------------------- /Chapter01/7.3.1.1.Parameter sets.ps1: -------------------------------------------------------------------------------- 1 | Stop-Process $PID 2 | -------------------------------------------------------------------------------- /Chapter01/7.4.1.1.Common parameters.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_CommonParameters 2 | -------------------------------------------------------------------------------- /Chapter01/7.5.1.1.Confirm and WhatIf.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_Preference_Variables 2 | -------------------------------------------------------------------------------- /Chapter01/7.5.2.4.Confirm and ConfirmPreference.ps1: -------------------------------------------------------------------------------- 1 | Clear-RecycleBin -Confirm:$false 2 | -------------------------------------------------------------------------------- /Chapter01/7.5.2.5.Confirm and ConfirmPreference.ps1: -------------------------------------------------------------------------------- 1 | $ConfirmPreference 2 | 3 | # Expects output: 4 | # 5 | # High 6 | -------------------------------------------------------------------------------- /Chapter01/7.5.2.6.Confirm and ConfirmPreference.ps1: -------------------------------------------------------------------------------- 1 | $ConfirmPreference = 'Low' 2 | -------------------------------------------------------------------------------- /Chapter01/7.5.3.2.WhatIf and WhatIfPreference.ps1: -------------------------------------------------------------------------------- 1 | 'Some message' | Out-File $env:TEMP\test.txt -WhatIf:$false 2 | -------------------------------------------------------------------------------- /Chapter01/7.5.3.3.WhatIf and WhatIfPreference.ps1: -------------------------------------------------------------------------------- 1 | $WhatIfPreference = $true 2 | -------------------------------------------------------------------------------- /Chapter01/7.6.1.1.Force parameter.ps1: -------------------------------------------------------------------------------- 1 | Get-Help Remove-Item -Parameter Force 2 | -------------------------------------------------------------------------------- /Chapter01/7.6.1.4.Force parameter.ps1: -------------------------------------------------------------------------------- 1 | Remove-Item FileName.txt -Force 2 | -------------------------------------------------------------------------------- /Chapter01/7.7.1.2.PassThru parameter.ps1: -------------------------------------------------------------------------------- 1 | Get-Service Audiosrv | 2 | Set-Service -StartupType Automatic -PassThru | 3 | Start-Service 4 | -------------------------------------------------------------------------------- /Chapter01/8.0.0.1.Introduction to providers.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_Providers 2 | -------------------------------------------------------------------------------- /Chapter01/8.0.0.10.Introduction to providers.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem FileSystem::C:\Windows 2 | -------------------------------------------------------------------------------- /Chapter01/8.0.0.3.Introduction to providers.ps1: -------------------------------------------------------------------------------- 1 | Get-Help -Name about_Certificate_Provider 2 | -------------------------------------------------------------------------------- /Chapter01/8.0.0.4.Introduction to providers.ps1: -------------------------------------------------------------------------------- 1 | Get-Help -Name About_*_Provider 2 | -------------------------------------------------------------------------------- /Chapter01/8.0.0.5.Introduction to providers.ps1: -------------------------------------------------------------------------------- 1 | Get-Help -Name Certificate -Category Provider 2 | -------------------------------------------------------------------------------- /Chapter01/8.0.0.6.Introduction to providers.ps1: -------------------------------------------------------------------------------- 1 | Get-Help -Category Provider 2 | -------------------------------------------------------------------------------- /Chapter01/8.0.0.7.Introduction to providers.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem variable:: 2 | -------------------------------------------------------------------------------- /Chapter01/8.0.0.8.Introduction to providers.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem registry:: 2 | -------------------------------------------------------------------------------- /Chapter01/8.0.0.9.Introduction to providers.ps1: -------------------------------------------------------------------------------- 1 | Get-Item variable::true 2 | -------------------------------------------------------------------------------- /Chapter01/8.1.1.3.Drives and providers.ps1: -------------------------------------------------------------------------------- 1 | New-PSDrive HKCC -PSProvider Registry -Root HKEY_CURRENT_CONFIG 2 | -------------------------------------------------------------------------------- /Chapter01/8.1.1.5.Drives and providers.ps1: -------------------------------------------------------------------------------- 1 | Set-Location HKCU: 2 | -------------------------------------------------------------------------------- /Chapter01/9.0.0.1.Introduction to splatting.ps1: -------------------------------------------------------------------------------- 1 | $getProcess = @{ 2 | Name = 'explorer' 3 | } 4 | Get-Process @getProcess 5 | -------------------------------------------------------------------------------- /Chapter01/9.0.0.2.Introduction to splatting.ps1: -------------------------------------------------------------------------------- 1 | $getProcess = @{ 2 | Name = 'explorer' 3 | } 4 | & 'Get-Process' @getProcess 5 | -------------------------------------------------------------------------------- /Chapter01/9.4.1.1.Splatting and positional parameters.ps1: -------------------------------------------------------------------------------- 1 | Rename-Item oldname.txt newname.txt 2 | -------------------------------------------------------------------------------- /Chapter01/9.4.1.2.Splatting and positional parameters.ps1: -------------------------------------------------------------------------------- 1 | $renameItem = 'oldname.txt', 'newname.txt' 2 | Rename-Item @renameItem 3 | -------------------------------------------------------------------------------- /Chapter01/9.4.1.3.Splatting and positional parameters.ps1: -------------------------------------------------------------------------------- 1 | $argumentList = '/t', 2 2 | timeout.exe $argumentList 3 | timeout.exe @argumentList 4 | -------------------------------------------------------------------------------- /Chapter02/1.1.1.2.The Get-Module command.ps1: -------------------------------------------------------------------------------- 1 | Get-Module -ListAvailable 2 | -------------------------------------------------------------------------------- /Chapter02/1.2.1.2.The Import-Module command.ps1: -------------------------------------------------------------------------------- 1 | $PSModuleAutoLoadingPreference = 'None' 2 | -------------------------------------------------------------------------------- /Chapter02/1.2.1.3.The Import-Module command.ps1: -------------------------------------------------------------------------------- 1 | Import-Module -Name ThreadJob 2 | Import-Module -Name $PSHome\Modules\ThreadJob\ThreadJob.psd1 3 | -------------------------------------------------------------------------------- /Chapter02/1.2.1.4.The Import-Module command.ps1: -------------------------------------------------------------------------------- 1 | Get-Command -Module ThreadJob 2 | -------------------------------------------------------------------------------- /Chapter02/1.2.1.5.The Import-Module command.ps1: -------------------------------------------------------------------------------- 1 | Import-Module PSScriptAnalyzer -MaxmimumVersion 1.7.0 2 | -------------------------------------------------------------------------------- /Chapter02/1.6.1.4.Using Windows PowerShell modules in PowerShell 7.ps1: -------------------------------------------------------------------------------- 1 | Get-PSSession -Name WinPSCompatSession 2 | -------------------------------------------------------------------------------- /Chapter02/1.6.1.5.Using Windows PowerShell modules in PowerShell 7.ps1: -------------------------------------------------------------------------------- 1 | Import-Module Appx -SkipEditionCheck 2 | -------------------------------------------------------------------------------- /Chapter02/1.6.1.8.Using Windows PowerShell modules in PowerShell 7.ps1: -------------------------------------------------------------------------------- 1 | Get-WmiObject Win32_Process -Filter "ProcessID=$PID" 2 | -------------------------------------------------------------------------------- /Chapter02/2.2.1.1.The Find-Module command.ps1: -------------------------------------------------------------------------------- 1 | Find-Module Carbon 2 | Find-Module -Name Carbon 3 | Find-Module -Name Azure* 4 | -------------------------------------------------------------------------------- /Chapter02/2.2.1.2.The Find-Module command.ps1: -------------------------------------------------------------------------------- 1 | Find-Module -Filter IIS 2 | -------------------------------------------------------------------------------- /Chapter02/2.3.1.1.The Install-Module command.ps1: -------------------------------------------------------------------------------- 1 | Install-Module carbon -Scope AllUsers 2 | -------------------------------------------------------------------------------- /Chapter02/2.3.1.2.The Install-Module command.ps1: -------------------------------------------------------------------------------- 1 | Find-Module -Name posh-git | Install-Module 2 | Install-Module posh-git 3 | -------------------------------------------------------------------------------- /Chapter02/2.3.1.3.The Install-Module command.ps1: -------------------------------------------------------------------------------- 1 | Install-Module posh-git -Force 2 | -------------------------------------------------------------------------------- /Chapter02/2.5.1.1.The Save-Module command.ps1: -------------------------------------------------------------------------------- 1 | Save-Module -Name Carbon -Path C:\Modules -Force 2 | -------------------------------------------------------------------------------- /Chapter02/3.0.0.1.Microsoft.PowerShell.PSResourceGet.ps1: -------------------------------------------------------------------------------- 1 | Install-Module Microsoft.PowerShell.PSResourceGet 2 | -------------------------------------------------------------------------------- /Chapter02/3.0.0.2.Microsoft.PowerShell.PSResourceGet.ps1: -------------------------------------------------------------------------------- 1 | Register-PSResourceRepository -PSGallery 2 | -------------------------------------------------------------------------------- /Chapter02/3.0.0.3.Microsoft.PowerShell.PSResourceGet.ps1: -------------------------------------------------------------------------------- 1 | Find-PSResource -Name Indented.Net.IP -Type Module 2 | -------------------------------------------------------------------------------- /Chapter02/3.1.1.1.Repositories.ps1: -------------------------------------------------------------------------------- 1 | $env:LOCALAPPDATA\Microsoft\Windows\PowerShell\PowerShellGet\PSRepositories.xml 2 | -------------------------------------------------------------------------------- /Chapter02/3.1.1.2.Repositories.ps1: -------------------------------------------------------------------------------- 1 | $env:LOCALAPPDATA\PowerShellGet\PSResourceRepository.xml 2 | -------------------------------------------------------------------------------- /Chapter02/3.2.1.1.Version ranges.ps1: -------------------------------------------------------------------------------- 1 | Find-PSResource -Name PowerShellGet -Version * 2 | -------------------------------------------------------------------------------- /Chapter02/3.2.1.2.Version ranges.ps1: -------------------------------------------------------------------------------- 1 | Find-PSResource -Name PowerShellGet -Version '[1.0,2.0)' 2 | -------------------------------------------------------------------------------- /Chapter02/3.2.1.3.Version ranges.ps1: -------------------------------------------------------------------------------- 1 | Find-PSResource -Name PowerShellGet -Version '[1.0,2.0]' 2 | -------------------------------------------------------------------------------- /Chapter02/5.0.0.1.About snap-ins.ps1: -------------------------------------------------------------------------------- 1 | Get-PSSnapIn -Registered 2 | -------------------------------------------------------------------------------- /Chapter02/5.0.0.2.About snap-ins.ps1: -------------------------------------------------------------------------------- 1 | Add-PSSnapIn WDeploySnapin3.0 2 | -------------------------------------------------------------------------------- /Chapter02/5.0.0.3.About snap-ins.ps1: -------------------------------------------------------------------------------- 1 | Get-Command -Module WDeploySnapin3.0 2 | -------------------------------------------------------------------------------- /Chapter03/1.0.0.1.Naming and creating variables.ps1: -------------------------------------------------------------------------------- 1 | $MyVariable 2 | -------------------------------------------------------------------------------- /Chapter03/1.0.0.2.Naming and creating variables.ps1: -------------------------------------------------------------------------------- 1 | $MyVariable = 'Hello World' 2 | -------------------------------------------------------------------------------- /Chapter03/1.0.0.3.Naming and creating variables.ps1: -------------------------------------------------------------------------------- 1 | $first = $second = 0 2 | -------------------------------------------------------------------------------- /Chapter03/1.0.0.4.Naming and creating variables.ps1: -------------------------------------------------------------------------------- 1 | ${My Variable} 2 | ${My-Variable} 3 | -------------------------------------------------------------------------------- /Chapter03/1.1.1.1.Provider variables.ps1: -------------------------------------------------------------------------------- 1 | ${env:ProgramFiles(x86)} 2 | -------------------------------------------------------------------------------- /Chapter03/1.1.1.2.Provider variables.ps1: -------------------------------------------------------------------------------- 1 | ${function:mkdir} 2 | -------------------------------------------------------------------------------- /Chapter03/1.1.1.3.Provider variables.ps1: -------------------------------------------------------------------------------- 1 | ${function:Write-HelloWorld} = { Write-Host 'Hello world' } 2 | -------------------------------------------------------------------------------- /Chapter03/1.1.1.4.Provider variables.ps1: -------------------------------------------------------------------------------- 1 | ${C:\Windows\Temp\variable.txt} = "New value" 2 | -------------------------------------------------------------------------------- /Chapter03/2.0.0.1.Variables in strings.ps1: -------------------------------------------------------------------------------- 1 | $count = 5 2 | $string = "There are $count items" 3 | -------------------------------------------------------------------------------- /Chapter03/2.0.0.2.Variables in strings.ps1: -------------------------------------------------------------------------------- 1 | "Computer Name: $env:COMPUTERNAME" 2 | -------------------------------------------------------------------------------- /Chapter03/2.0.0.4.Variables in strings.ps1: -------------------------------------------------------------------------------- 1 | $computerName = $env:COMPUTERNAME 2 | "${ComputerName}: Running PS $PSEdition" 3 | -------------------------------------------------------------------------------- /Chapter03/2.0.0.5.Variables in strings.ps1: -------------------------------------------------------------------------------- 1 | $computerName = $env:COMPUTERNAME 2 | "$($ComputerName): Running PS $PSEdition” 3 | -------------------------------------------------------------------------------- /Chapter03/2.0.0.6.Variables in strings.ps1: -------------------------------------------------------------------------------- 1 | "${ComputerName}: $($ComputerName.Length) characters long" 2 | -------------------------------------------------------------------------------- /Chapter03/3.0.0.1.Variable types.ps1: -------------------------------------------------------------------------------- 1 | $variable = "Hello world" 2 | -------------------------------------------------------------------------------- /Chapter03/3.0.0.4.Variable types.ps1: -------------------------------------------------------------------------------- 1 | $variable.GetType().FullName 2 | 3 | # Expects output: 4 | # 5 | # System.String 6 | -------------------------------------------------------------------------------- /Chapter03/3.0.0.5.Variable types.ps1: -------------------------------------------------------------------------------- 1 | $variable = 1 2 | -------------------------------------------------------------------------------- /Chapter03/3.1.1.1.Assignment with types on the right.ps1: -------------------------------------------------------------------------------- 1 | $variable = [string]1 2 | -------------------------------------------------------------------------------- /Chapter03/3.2.1.1.Assignment with types on the left.ps1: -------------------------------------------------------------------------------- 1 | [string]$typedVariable = 1 2 | -------------------------------------------------------------------------------- /Chapter03/3.2.1.3.Assignment with types on the left.ps1: -------------------------------------------------------------------------------- 1 | [string]$typedVariable = 1 2 | [int]$typedVariable = 1 3 | -------------------------------------------------------------------------------- /Chapter03/3.3.1.1.Value and reference types.ps1: -------------------------------------------------------------------------------- 1 | $first = @{ Key = 'value' } 2 | -------------------------------------------------------------------------------- /Chapter03/3.3.1.2.Value and reference types.ps1: -------------------------------------------------------------------------------- 1 | $second = $first 2 | -------------------------------------------------------------------------------- /Chapter03/3.3.1.3.Value and reference types.ps1: -------------------------------------------------------------------------------- 1 | $first = $second = @{ Key = 'value' } 2 | -------------------------------------------------------------------------------- /Chapter03/3.3.1.4.Value and reference types.ps1: -------------------------------------------------------------------------------- 1 | $second.Key = 'newValue' 2 | $first.Key 3 | 4 | # Expects output: 5 | # 6 | # newValue 7 | -------------------------------------------------------------------------------- /Chapter03/3.3.1.5.Value and reference types.ps1: -------------------------------------------------------------------------------- 1 | $first = $second = 2 2 | -------------------------------------------------------------------------------- /Chapter03/3.3.1.6.Value and reference types.ps1: -------------------------------------------------------------------------------- 1 | $first = $second = 'value' 2 | -------------------------------------------------------------------------------- /Chapter03/3.3.1.7.Value and reference types.ps1: -------------------------------------------------------------------------------- 1 | $second = 'newValue' 2 | $first 3 | 4 | # Expects output: 5 | # 6 | # value 7 | -------------------------------------------------------------------------------- /Chapter03/3.4.1.2.Type conversion.ps1: -------------------------------------------------------------------------------- 1 | [DateTime]::Parse('1/1/1970') 2 | -------------------------------------------------------------------------------- /Chapter03/4.1.1.1.Get-Variable.ps1: -------------------------------------------------------------------------------- 1 | Get-Variable | Select-Object Name, Description 2 | -------------------------------------------------------------------------------- /Chapter03/4.2.1.1.New-Variable.ps1: -------------------------------------------------------------------------------- 1 | New-Variable -Name today -Value (Get-Date) 2 | -------------------------------------------------------------------------------- /Chapter03/4.2.1.2.New-Variable.ps1: -------------------------------------------------------------------------------- 1 | $today = Get-Date 2 | -------------------------------------------------------------------------------- /Chapter03/4.2.1.3.New-Variable.ps1: -------------------------------------------------------------------------------- 1 | $today 2 | 3 | # Expects output: 4 | # 5 | # 24 March 2024 12:37:46 6 | -------------------------------------------------------------------------------- /Chapter03/4.3.1.1.Set-Variable.ps1: -------------------------------------------------------------------------------- 1 | $objectCount = 23 2 | Set-Variable objectCount -Value 42 3 | -------------------------------------------------------------------------------- /Chapter03/4.3.1.2.Set-Variable.ps1: -------------------------------------------------------------------------------- 1 | Set-Variable objectCount -Description 'The number of objects in the queue' 2 | -------------------------------------------------------------------------------- /Chapter03/4.3.1.3.Set-Variable.ps1: -------------------------------------------------------------------------------- 1 | Set-Variable objectCount -Option Private 2 | -------------------------------------------------------------------------------- /Chapter03/4.4.1.1.Remove-Variable.ps1: -------------------------------------------------------------------------------- 1 | $psProcesses = Get-Process pwsh 2 | Remove-Variable psProcesses 3 | -------------------------------------------------------------------------------- /Chapter03/4.5.1.2.Clear-Variable.ps1: -------------------------------------------------------------------------------- 1 | Clear-Variable temporaryValue 2 | Write-Host $temporaryValue -ForegroundColor Green 3 | -------------------------------------------------------------------------------- /Chapter03/4.5.1.4.Clear-Variable.ps1: -------------------------------------------------------------------------------- 1 | $temporaryValue = $null 2 | -------------------------------------------------------------------------------- /Chapter03/5.0.0.2.Variable provider.ps1: -------------------------------------------------------------------------------- 1 | Test-Path variable:\VerbosePreference 2 | -------------------------------------------------------------------------------- /Chapter03/5.0.0.3.Variable provider.ps1: -------------------------------------------------------------------------------- 1 | Set-Item variable:\new -Value variable 2 | -------------------------------------------------------------------------------- /Chapter03/5.0.0.4.Variable provider.ps1: -------------------------------------------------------------------------------- 1 | Get-Content variable:\PSHome 2 | 3 | # Expects output: 4 | # 5 | # C:\Program Files\PowerShell\7 6 | -------------------------------------------------------------------------------- /Chapter03/5.0.0.5.Variable provider.ps1: -------------------------------------------------------------------------------- 1 | Get-Content variable:PSHome 2 | 3 | # Expects output: 4 | # 5 | # C:\Program Files\PowerShell\7 6 | -------------------------------------------------------------------------------- /Chapter03/5.0.0.6.Variable provider.ps1: -------------------------------------------------------------------------------- 1 | Get-Content variable:global:PSHome 2 | 3 | # Expects output: 4 | # 5 | # C:\Program Files\PowerShell\7 6 | -------------------------------------------------------------------------------- /Chapter03/6.2.1.1.Scope modifiers.ps1: -------------------------------------------------------------------------------- 1 | $Global:variableName = 123 2 | -------------------------------------------------------------------------------- /Chapter03/6.4.1.1.Private variables.ps1: -------------------------------------------------------------------------------- 1 | New-Variable -Name thisValue -Option Private 2 | $private:thisValue = "Some value" 3 | -------------------------------------------------------------------------------- /Chapter03/6.4.1.3.Private variables.ps1: -------------------------------------------------------------------------------- 1 | first 2 | 3 | # Expects output: 4 | # 5 | # In the function third the value of name is first 6 | -------------------------------------------------------------------------------- /Chapter03/7.0.0.1.About arrays.ps1: -------------------------------------------------------------------------------- 1 | $processes = Get-Process 2 | -------------------------------------------------------------------------------- /Chapter03/7.1.1.1.Array type.ps1: -------------------------------------------------------------------------------- 1 | $processes = Get-Process 2 | -------------------------------------------------------------------------------- /Chapter03/7.1.1.4.Array type.ps1: -------------------------------------------------------------------------------- 1 | $processes = @(Get-Process -Id $PID) 2 | -------------------------------------------------------------------------------- /Chapter03/7.10.1.1.Filling variables from arrays.ps1: -------------------------------------------------------------------------------- 1 | $i, $j = 1, 2 2 | -------------------------------------------------------------------------------- /Chapter03/7.10.1.2.Filling variables from arrays.ps1: -------------------------------------------------------------------------------- 1 | $i 2 | 3 | # Expects output: 4 | # 5 | # 1 6 | -------------------------------------------------------------------------------- /Chapter03/7.10.1.5.Filling variables from arrays.ps1: -------------------------------------------------------------------------------- 1 | $i, $j, $k = 1, 2 2 | -------------------------------------------------------------------------------- /Chapter03/7.10.1.6.Filling variables from arrays.ps1: -------------------------------------------------------------------------------- 1 | $firstName, $null, $lastName = -split “First A. Last” 2 | -------------------------------------------------------------------------------- /Chapter03/7.11.1.2.Multi-dimensional and jagged arrays.ps1: -------------------------------------------------------------------------------- 1 | $arrayOfArrays[0][1] 2 | 3 | # Expects output: 4 | # 5 | # 2 6 | -------------------------------------------------------------------------------- /Chapter03/7.11.1.3.Multi-dimensional and jagged arrays.ps1: -------------------------------------------------------------------------------- 1 | $arrayOfArrays[1][2] 2 | 3 | # Expects output: 4 | # 5 | # 6 6 | -------------------------------------------------------------------------------- /Chapter03/7.11.1.5.Multi-dimensional and jagged arrays.ps1: -------------------------------------------------------------------------------- 1 | $arrayOfArrays[1][5] 2 | 3 | # Expects output: 4 | # 5 | # 9 6 | -------------------------------------------------------------------------------- /Chapter03/7.3.1.1.Creating an array.ps1: -------------------------------------------------------------------------------- 1 | $myArray = @() 2 | -------------------------------------------------------------------------------- /Chapter03/7.3.1.3.Creating an array.ps1: -------------------------------------------------------------------------------- 1 | $myGreetings = "Hello world", "Hello sun", "Hello moon" 2 | -------------------------------------------------------------------------------- /Chapter03/7.3.1.4.Creating an array.ps1: -------------------------------------------------------------------------------- 1 | $myGreetings = @("Hello world", "Hello sun", "Hello moon") 2 | -------------------------------------------------------------------------------- /Chapter03/7.3.1.5.Creating an array.ps1: -------------------------------------------------------------------------------- 1 | $myGreetings = @( 2 | "Hello world" 3 | "Hello sun" 4 | "Hello moon" 5 | ) 6 | -------------------------------------------------------------------------------- /Chapter03/7.3.1.6.Creating an array.ps1: -------------------------------------------------------------------------------- 1 | $myThings = "Hello world", 2, 34.23, (Get-Date) 2 | -------------------------------------------------------------------------------- /Chapter03/7.3.1.7.Creating an array.ps1: -------------------------------------------------------------------------------- 1 | $myThings = @( 2 | "Hello world" 3 | 2 4 | 34.23 5 | Get-Date 6 | ) 7 | -------------------------------------------------------------------------------- /Chapter03/7.4.1.2.Arrays with a type.ps1: -------------------------------------------------------------------------------- 1 | [int[]]$myNumbers = 1, 2, $null, 3.45 2 | -------------------------------------------------------------------------------- /Chapter03/7.5.1.1.Adding elements to an array.ps1: -------------------------------------------------------------------------------- 1 | $myArray = @() 2 | $myArray += 'New value' 3 | -------------------------------------------------------------------------------- /Chapter03/7.6.1.1.List and ArrayList.ps1: -------------------------------------------------------------------------------- 1 | $list = [System.Collections.Generic.List[object]]::new() 2 | -------------------------------------------------------------------------------- /Chapter03/7.6.1.11.List and ArrayList.ps1: -------------------------------------------------------------------------------- 1 | Get-Member -InputObject $list 2 | Get-Member -InputObject $arrayList 3 | -------------------------------------------------------------------------------- /Chapter03/7.6.1.2.List and ArrayList.ps1: -------------------------------------------------------------------------------- 1 | $list.Add('New value') 2 | -------------------------------------------------------------------------------- /Chapter03/7.6.1.5.List and ArrayList.ps1: -------------------------------------------------------------------------------- 1 | $arrayList = [System.Collections.ArrayList]::new() 2 | -------------------------------------------------------------------------------- /Chapter03/7.6.1.6.List and ArrayList.ps1: -------------------------------------------------------------------------------- 1 | $arrayList.Add('New value') 2 | -------------------------------------------------------------------------------- /Chapter03/7.6.1.7.List and ArrayList.ps1: -------------------------------------------------------------------------------- 1 | $arrayList.Add('New value') | Out-Null 2 | -------------------------------------------------------------------------------- /Chapter03/7.6.1.8.List and ArrayList.ps1: -------------------------------------------------------------------------------- 1 | $null = $arrayList.Add('New value') 2 | [void]$arrayList.Add('New value') 3 | -------------------------------------------------------------------------------- /Chapter03/7.6.1.9.List and ArrayList.ps1: -------------------------------------------------------------------------------- 1 | [System.Collections.Generic.List[object]]$processes = Get-Process 2 | -------------------------------------------------------------------------------- /Chapter03/7.7.1.10.Selecting elements from an array.ps1: -------------------------------------------------------------------------------- 1 | $myArray -lt 3 2 | 3 | # Expects output: 4 | # 5 | # 1 6 | # 2 7 | -------------------------------------------------------------------------------- /Chapter03/7.7.1.11.Selecting elements from an array.ps1: -------------------------------------------------------------------------------- 1 | $myArray -gt 3 -lt 7 2 | 3 | # Expects output: 4 | # 5 | # 4 6 | # 5 7 | # 6 8 | -------------------------------------------------------------------------------- /Chapter03/7.7.1.13.Selecting elements from an array.ps1: -------------------------------------------------------------------------------- 1 | $myArray.Where{ $_ -lt 3 -or $_ -gt 7 } 2 | -------------------------------------------------------------------------------- /Chapter03/7.7.1.2.Selecting elements from an array.ps1: -------------------------------------------------------------------------------- 1 | $myArray[-1] 2 | $myArray[-2] 3 | 4 | # Expects output: 5 | # 6 | # 10 7 | # 9 8 | -------------------------------------------------------------------------------- /Chapter03/7.7.1.5.Selecting elements from an array.ps1: -------------------------------------------------------------------------------- 1 | $myArray[0 + 6..8 + -1] 2 | 3 | # Expects output: 4 | # 5 | # 0..2 + 6..8 + -1 6 | -------------------------------------------------------------------------------- /Chapter03/7.7.1.8.Selecting elements from an array.ps1: -------------------------------------------------------------------------------- 1 | $myArray.IndexOf(11) 2 | 3 | # Expects output: 4 | # 5 | # -1 6 | -------------------------------------------------------------------------------- /Chapter03/7.8.1.1.Changing element values in an array.ps1: -------------------------------------------------------------------------------- 1 | $myArray = 1, 2, 9, 4, 5 2 | $myArray[2] = 3 3 | -------------------------------------------------------------------------------- /Chapter03/7.9.1.1.Removing elements.ps1: -------------------------------------------------------------------------------- 1 | $list = [System.Collections.Generic.List[string]]@('a', 'b', 'c') 2 | $list.Remove('a') 3 | -------------------------------------------------------------------------------- /Chapter03/7.9.1.2.Removing elements.ps1: -------------------------------------------------------------------------------- 1 | $list.RemoveAt(0) 2 | -------------------------------------------------------------------------------- /Chapter03/7.9.2.1.Removing elements by index.ps1: -------------------------------------------------------------------------------- 1 | $oldArray = 1..100 2 | -------------------------------------------------------------------------------- /Chapter03/7.9.2.2.Removing elements by index.ps1: -------------------------------------------------------------------------------- 1 | $newArray = $oldArray[0..48] + $oldArray[50..99] 2 | -------------------------------------------------------------------------------- /Chapter03/8.1.1.1.Creating a Hashtable.ps1: -------------------------------------------------------------------------------- 1 | $hashtable = @{} 2 | -------------------------------------------------------------------------------- /Chapter03/8.1.1.2.Creating a Hashtable.ps1: -------------------------------------------------------------------------------- 1 | $hashtable = @{ Key1 = "Value1"; Key2 = "Value2" } 2 | -------------------------------------------------------------------------------- /Chapter03/8.1.1.3.Creating a Hashtable.ps1: -------------------------------------------------------------------------------- 1 | $hashtable = @{ 2 | Key1 = 'Value1' 3 | Key2 = 'Value2' 4 | } 5 | -------------------------------------------------------------------------------- /Chapter03/8.2.1.2.Adding, changing and removing keys.ps1: -------------------------------------------------------------------------------- 1 | $hashtable = @{} 2 | $hashtable.Key1 = "Value1" 3 | -------------------------------------------------------------------------------- /Chapter03/8.2.1.5.Adding, changing and removing keys.ps1: -------------------------------------------------------------------------------- 1 | if (-not $hashtable.ContainsKey('Key3')) { 2 | $hashtable.Key3 = 'Value3' 3 | } 4 | -------------------------------------------------------------------------------- /Chapter03/8.2.1.6.Adding, changing and removing keys.ps1: -------------------------------------------------------------------------------- 1 | $hashtable.Remove('Key3') 2 | -------------------------------------------------------------------------------- /Chapter03/8.3.1.2.Using a hashtable to filter.ps1: -------------------------------------------------------------------------------- 1 | $left | Where-Object UserID -in $right.UserID 2 | -------------------------------------------------------------------------------- /Chapter03/8.3.1.3.Using a hashtable to filter.ps1: -------------------------------------------------------------------------------- 1 | Measure-Command { $left | Where-Object UserID -in $right.UserID } 2 | -------------------------------------------------------------------------------- /Chapter03/8.3.1.4.Using a hashtable to filter.ps1: -------------------------------------------------------------------------------- 1 | $rightLookup = @{} 2 | $right | ForEach-Object { 3 | $rightLookup[$_.UserID] = $_ 4 | } 5 | -------------------------------------------------------------------------------- /Chapter03/8.3.1.5.Using a hashtable to filter.ps1: -------------------------------------------------------------------------------- 1 | $left | Where-Object { $rightLookup.Contains($_.UserID) } 2 | -------------------------------------------------------------------------------- /Chapter03/8.4.1.1.Enumerating a Hashtable.ps1: -------------------------------------------------------------------------------- 1 | $hashtable = @{ 2 | Key1 = 'Value1' 3 | Key2 = 'Value2' 4 | } 5 | -------------------------------------------------------------------------------- /Chapter03/8.4.1.3.Enumerating a Hashtable.ps1: -------------------------------------------------------------------------------- 1 | $hashtable.Keys 2 | 3 | # Expects output: 4 | # 5 | # Key2 6 | # Key1 7 | -------------------------------------------------------------------------------- /Chapter03/8.4.1.4.Enumerating a Hashtable.ps1: -------------------------------------------------------------------------------- 1 | $hashtable.Values 2 | 3 | # Expects output: 4 | # 5 | # Value2 6 | # Value1 7 | -------------------------------------------------------------------------------- /Chapter03/8.4.1.5.Enumerating a Hashtable.ps1: -------------------------------------------------------------------------------- 1 | $user = @{ 2 | UserID = 'User1' 3 | Keys = 'Office', 'Workshop' 4 | } 5 | -------------------------------------------------------------------------------- /Chapter03/8.4.1.6.Enumerating a Hashtable.ps1: -------------------------------------------------------------------------------- 1 | $user.Keys 2 | 3 | # Expects output: 4 | # 5 | # Office 6 | # Workshop 7 | -------------------------------------------------------------------------------- /Chapter03/8.4.1.7.Enumerating a Hashtable.ps1: -------------------------------------------------------------------------------- 1 | $user.get_Keys() 2 | 3 | # Expects output: 4 | # 5 | # Keys 6 | # UserID 7 | -------------------------------------------------------------------------------- /Chapter03/9.0.0.1.About Ordered.ps1: -------------------------------------------------------------------------------- 1 | $ordered = [Ordered]@{ 2 | One = 1 3 | Two = 2 4 | Three = 3 5 | } 6 | -------------------------------------------------------------------------------- /Chapter03/9.0.0.4.About Ordered.ps1: -------------------------------------------------------------------------------- 1 | [Ordered]@{ One = 1 } 2 | -------------------------------------------------------------------------------- /Chapter04/1.1.1.1.Standard output.ps1: -------------------------------------------------------------------------------- 1 | $computerSystem = Get-CimInstance -ClassName Win32_ComputerSystem 2 | -------------------------------------------------------------------------------- /Chapter04/1.3.1.1.The object pipeline.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | Where-Object WorkingSet64 -gt 50MB 2 | -------------------------------------------------------------------------------- /Chapter04/1.3.1.2.The object pipeline.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | 2 | Where-Object WorkingSet64 -gt 50MB | 3 | Select-Object -Property Name, ID 4 | -------------------------------------------------------------------------------- /Chapter04/1.3.1.3.The object pipeline.ps1: -------------------------------------------------------------------------------- 1 | Get-Process 2 | | Where-Object WorkingSet64 -gt 50MB 3 | | Select-Object Name, ID 4 | -------------------------------------------------------------------------------- /Chapter04/2.1.1.3.The Get-Member command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process -Id $PID | Get-Member PS* -Force 2 | -------------------------------------------------------------------------------- /Chapter04/2.2.1.1.Accessing object properties.ps1: -------------------------------------------------------------------------------- 1 | $process = Get-Process -Id $PID 2 | $process.Name 3 | -------------------------------------------------------------------------------- /Chapter04/2.2.1.2.Accessing object properties.ps1: -------------------------------------------------------------------------------- 1 | (Get-Process -Id $PID).Name 2 | -------------------------------------------------------------------------------- /Chapter04/2.2.1.4.Accessing object properties.ps1: -------------------------------------------------------------------------------- 1 | (Get-Process -Id $PID).StartTime | Get-Member -MemberType Property 2 | -------------------------------------------------------------------------------- /Chapter04/2.2.1.5.Accessing object properties.ps1: -------------------------------------------------------------------------------- 1 | $process = Get-Process -Id $PID 2 | $process.StartTime.DayOfWeek 3 | -------------------------------------------------------------------------------- /Chapter04/2.2.1.6.Accessing object properties.ps1: -------------------------------------------------------------------------------- 1 | (Get-Process -Id $PID).StartTime.DayOfWeek 2 | -------------------------------------------------------------------------------- /Chapter04/2.2.1.7.Accessing object properties.ps1: -------------------------------------------------------------------------------- 1 | Sunday 2 | -------------------------------------------------------------------------------- /Chapter04/2.3.1.3.Access modifiers.ps1: -------------------------------------------------------------------------------- 1 | $File = New-Item NewFile.txt -Force 2 | $File.CreationTime = Get-Date -Day 1 -Month 2 -Year 1692 3 | -------------------------------------------------------------------------------- /Chapter04/2.3.1.4.Access modifiers.ps1: -------------------------------------------------------------------------------- 1 | Get-Item NewFile.txt | Select-Object -ExpandProperty CreationTime 2 | -------------------------------------------------------------------------------- /Chapter04/2.3.1.5.Access modifiers.ps1: -------------------------------------------------------------------------------- 1 | 01 February 1692 09:14:27 2 | -------------------------------------------------------------------------------- /Chapter04/2.4.1.1.Using methods.ps1: -------------------------------------------------------------------------------- 1 | 'any string' | Get-Member -MemberType Method 2 | -------------------------------------------------------------------------------- /Chapter04/2.4.1.11.Using methods.ps1: -------------------------------------------------------------------------------- 1 | $date = Get-Date 2 | $date.Date 3 | -------------------------------------------------------------------------------- /Chapter04/2.4.1.13.Using methods.ps1: -------------------------------------------------------------------------------- 1 | $date.Date.AddDays(1) 2 | $date.Date.AddDays(-1) 3 | -------------------------------------------------------------------------------- /Chapter04/2.4.1.2.Using methods.ps1: -------------------------------------------------------------------------------- 1 | 'CaT'.ToLower() 2 | -------------------------------------------------------------------------------- /Chapter04/2.4.1.3.Using methods.ps1: -------------------------------------------------------------------------------- 1 | 'My pet is a cat'.Replace('cat', 'dog') 2 | -------------------------------------------------------------------------------- /Chapter04/2.4.1.4.Using methods.ps1: -------------------------------------------------------------------------------- 1 | My pet is a dog 2 | -------------------------------------------------------------------------------- /Chapter04/2.4.1.5.Using methods.ps1: -------------------------------------------------------------------------------- 1 | 'My pet is a cat' -replace 'cat', 'dog' 2 | -------------------------------------------------------------------------------- /Chapter04/2.4.1.7.Using methods.ps1: -------------------------------------------------------------------------------- 1 | 'My cat'.Substring(3) 2 | -------------------------------------------------------------------------------- /Chapter04/2.4.1.8.Using methods.ps1: -------------------------------------------------------------------------------- 1 | 'My cat is gray'.Substring(3, 3) 2 | -------------------------------------------------------------------------------- /Chapter04/2.4.1.9.Using methods.ps1: -------------------------------------------------------------------------------- 1 | $date = Get-Date 2 | -------------------------------------------------------------------------------- /Chapter04/2.4.2.3.Return types and argument types.ps1: -------------------------------------------------------------------------------- 1 | $date = Get-Date 2 | $date.Date.AddSeconds(-1).AddDays(1.5) 3 | -------------------------------------------------------------------------------- /Chapter04/2.5.2.1.Using PSCustomObject.ps1: -------------------------------------------------------------------------------- 1 | [PSCustomObject]@{ 2 | Email = 'name@domain.com' 3 | } 4 | -------------------------------------------------------------------------------- /Chapter04/3.1.1.1.The ForEach-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | ForEach-Object { 2 | Write-Host $_.Name -ForegroundColor Green 3 | } 4 | -------------------------------------------------------------------------------- /Chapter04/3.1.3.1.The Parallel parameter.ps1: -------------------------------------------------------------------------------- 1 | 2 | 1..10 | ForEach-Object -Parallel { 3 | Start-Sleep -Seconds 2 4 | $_ 5 | } 6 | -------------------------------------------------------------------------------- /Chapter04/3.1.3.4.The Parallel parameter.ps1: -------------------------------------------------------------------------------- 1 | 1 | ForEach-Object -Parallel { 2 | $using:newString = $_ 3 | } 4 | -------------------------------------------------------------------------------- /Chapter04/3.1.3.7.The Parallel parameter.ps1: -------------------------------------------------------------------------------- 1 | $output = 1..5 | ForEach-Object -Parallel { $_ } 2 | -------------------------------------------------------------------------------- /Chapter04/3.1.4.1.The MemberName parameter.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | ForEach-Object -MemberName Path 2 | -------------------------------------------------------------------------------- /Chapter04/3.1.4.3.The MemberName parameter.ps1: -------------------------------------------------------------------------------- 1 | 20190101 2 | 20200101 3 | -------------------------------------------------------------------------------- /Chapter04/3.2.1.1.The Where-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | Where-Object StartTime -gt (Get-Date 9:00:00) 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.1.1.The Select-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process -Id $PID | Select-Object * 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.1.10.The Select-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem C:\ | Select-Object -Index 3, 4, 5 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.1.11.The Select-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem C:\ | Select-Object -SkipIndex 3, 4, 5 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.1.3.The Select-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | Select-Object -Property Name, *Memory* 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.1.6.The Select-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem C:\ -Recurse | Select-Object -First 2 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.1.7.The Select-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem C:\ | Select-Object -Last 3 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.1.8.The Select-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem C:\ | Select-Object -Skip 4 -First 1 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.1.9.The Select-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem C:\ | Select-Object -Skip 2 -Last 1 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.2.5.Calculated properties.ps1: -------------------------------------------------------------------------------- 1 | (Get-Process | Select-Object -First 1).GetType() 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.2.6.Calculated properties.ps1: -------------------------------------------------------------------------------- 1 | (Get-Process | Select-Object -Property Path, Company -First 1).GetType() 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.3.1.The ExpandProperty parameter.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | Select-Object -First 5 -ExpandProperty Name 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.4.1.The Unique parameter.ps1: -------------------------------------------------------------------------------- 1 | 1, 1, 1, 3, 5, 2, 2, 4 | Select-Object -Unique 2 | -------------------------------------------------------------------------------- /Chapter04/4.1.4.4.The Unique parameter.ps1: -------------------------------------------------------------------------------- 1 | 'dog', 'dog', 'cat', 'cat', 'mouse', 'Mouse' | 2 | Select-Object -Unique 3 | -------------------------------------------------------------------------------- /Chapter04/4.2.1.2.The Sort-Object command.ps1: -------------------------------------------------------------------------------- 1 | 'ccc', 'BBB', 'aaa' | Sort-Object 2 | 3 | # Expects output: 4 | # 5 | # aaa 6 | # BBB 7 | # ccc 8 | -------------------------------------------------------------------------------- /Chapter04/4.2.1.3.The Sort-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | Sort-Object -Property Id 2 | -------------------------------------------------------------------------------- /Chapter04/4.2.1.4.The Sort-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem C:\Windows\System32 | 2 | Sort-Object LastWriteTime, Name 3 | -------------------------------------------------------------------------------- /Chapter04/5.1.1.3.The Group-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem C:\Windows\Assembly -Filter *.dll -Recurse | 2 | Group-Object Name 3 | -------------------------------------------------------------------------------- /Chapter04/6.0.0.1.Comparing.ps1: -------------------------------------------------------------------------------- 1 | Compare-Object -ReferenceObject 1, 2 -DifferenceObject 1, 2 2 | -------------------------------------------------------------------------------- /Chapter04/6.0.0.5.Comparing.ps1: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | -------------------------------------------------------------------------------- /Chapter04/7.1.1.1.The Export-Csv command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | Export-Csv processes.csv 2 | -------------------------------------------------------------------------------- /Chapter04/7.1.1.11.The Export-Csv command.ps1: -------------------------------------------------------------------------------- 1 | "Name","Value" 2 | "Numbers","1, 2, 3, 4, 5" 3 | -------------------------------------------------------------------------------- /Chapter04/7.1.1.2.The Export-Csv command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process -ID $PID | 2 | Select-Object Name, Id | 3 | Export-Csv .\Processes.csv 4 | -------------------------------------------------------------------------------- /Chapter04/7.1.1.5.The Export-Csv command.ps1: -------------------------------------------------------------------------------- 1 | #TYPE Selected.System.Diagnostics.Process 2 | -------------------------------------------------------------------------------- /Chapter04/7.1.1.6.The Export-Csv command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | Export-Csv processes.csv -NoTypeInformation 2 | -------------------------------------------------------------------------------- /Chapter04/7.2.1.1.The Import-Csv command.ps1: -------------------------------------------------------------------------------- 1 | Import-Csv TabDelimitedFile.tsv -Delimiter `t 2 | -------------------------------------------------------------------------------- /Chapter04/7.2.1.2.The Import-Csv command.ps1: -------------------------------------------------------------------------------- 1 | Name,Position 2 | Jim,35 3 | Matt,3 4 | Dave,5 5 | -------------------------------------------------------------------------------- /Chapter04/7.2.1.6.The Import-Csv command.ps1: -------------------------------------------------------------------------------- 1 | “Name,Id 2 | Powershell,404” | ConvertFrom-Csv 3 | -------------------------------------------------------------------------------- /Chapter04/7.3.1.3.Export-Clixml and Import-Clixml.ps1: -------------------------------------------------------------------------------- 1 | $object = Import-Clixml .\object.xml 2 | -------------------------------------------------------------------------------- /Chapter04/7.3.1.5.Export-Clixml and Import-Clixml.ps1: -------------------------------------------------------------------------------- 1 | Get-Credential | Export-CliXml -Path secret.xml 2 | -------------------------------------------------------------------------------- /Chapter04/7.3.1.6.Export-Clixml and Import-Clixml.ps1: -------------------------------------------------------------------------------- 1 | $credential = Import-CliXml -Path secret.xml 2 | -------------------------------------------------------------------------------- /Chapter04/7.3.1.7.Export-Clixml and Import-Clixml.ps1: -------------------------------------------------------------------------------- 1 | $credential.GetNetworkCredential().Password 2 | -------------------------------------------------------------------------------- /Chapter04/7.4.1.1.The Tee-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | Tee-Object -Variable processes 2 | -------------------------------------------------------------------------------- /Chapter04/7.4.1.3.The Tee-Object command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | Tee-Object -FilePath .\processes.txt 2 | -------------------------------------------------------------------------------- /Chapter04/8.2.1.3.The Format-Table command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | Format-Table * 2 | -------------------------------------------------------------------------------- /Chapter04/8.3.1.2.The Format-List command.ps1: -------------------------------------------------------------------------------- 1 | Get-Process -Id $PID | Format-List * 2 | -------------------------------------------------------------------------------- /Chapter04/8.5.1.2.Format-only properties.ps1: -------------------------------------------------------------------------------- 1 | Get-Process -Id $PID | Select-Object ProcessName, 'NPM(K)' 2 | -------------------------------------------------------------------------------- /Chapter04/8.5.1.3.Format-only properties.ps1: -------------------------------------------------------------------------------- 1 | $process = Get-Process -Id $PID 2 | $format = Get-FormatData -TypeName $process.PSTypeNames 3 | -------------------------------------------------------------------------------- /Chapter04/8.5.1.5.Format-only properties.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | Format-Table -View Priority 2 | -------------------------------------------------------------------------------- /Chapter05/1.1.1.1.Operator precedence.ps1: -------------------------------------------------------------------------------- 1 | 3 + 2 * 2 2 | 2 * 2 + 3 3 | -------------------------------------------------------------------------------- /Chapter05/1.1.1.2.Operator precedence.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_Operator_Precedence 2 | -------------------------------------------------------------------------------- /Chapter05/1.2.1.1.Grouping.ps1: -------------------------------------------------------------------------------- 1 | 3 + 2 * 2 2 | -------------------------------------------------------------------------------- /Chapter05/1.2.1.2.Grouping.ps1: -------------------------------------------------------------------------------- 1 | (3 + 2) * 2 2 | -------------------------------------------------------------------------------- /Chapter05/1.3.1.1.Sub-expression operator.ps1: -------------------------------------------------------------------------------- 1 | $word = 'one' 2 | "Length: $($word.Length)" 3 | -------------------------------------------------------------------------------- /Chapter05/1.4.1.1.Array sub-expression operator.ps1: -------------------------------------------------------------------------------- 1 | $processes = @(Get-Process -ID $PID) 2 | -------------------------------------------------------------------------------- /Chapter05/10.5.1.1.Redirection to null.ps1: -------------------------------------------------------------------------------- 1 | Get-Process > $null 2 | -------------------------------------------------------------------------------- /Chapter05/10.5.1.2.Redirection to null.ps1: -------------------------------------------------------------------------------- 1 | .\somecommand.exe 2> $null 3> $null 2 | .\somecommand.exe *> $null 3 | -------------------------------------------------------------------------------- /Chapter05/11.1.1.1.Comma.ps1: -------------------------------------------------------------------------------- 1 | $array = 1, 2, 3, 4 2 | -------------------------------------------------------------------------------- /Chapter05/11.1.1.2.Comma.ps1: -------------------------------------------------------------------------------- 1 | $array = ,1 2 | -------------------------------------------------------------------------------- /Chapter05/11.10.1.1.Background.ps1: -------------------------------------------------------------------------------- 1 | $job = Get-Process & 2 | -------------------------------------------------------------------------------- /Chapter05/11.10.1.3.Background.ps1: -------------------------------------------------------------------------------- 1 | $job = Get-Process & 2 | $job | Receive-Job 3 | -------------------------------------------------------------------------------- /Chapter05/11.2.1.1.Index.ps1: -------------------------------------------------------------------------------- 1 | $array = 1, 2, 3, 4, 5 2 | $array[0] 3 | -------------------------------------------------------------------------------- /Chapter05/11.2.1.2.Index.ps1: -------------------------------------------------------------------------------- 1 | $array = 1, 2, 3, 4, 5 2 | $array[0, 1] 3 | -------------------------------------------------------------------------------- /Chapter05/11.2.1.3.Index.ps1: -------------------------------------------------------------------------------- 1 | $array = 1, 2, 3, 4, 5 2 | $array[-1, -2] 3 | -------------------------------------------------------------------------------- /Chapter05/11.2.1.4.Index.ps1: -------------------------------------------------------------------------------- 1 | $name = 'Andrew' 2 | $firstLetter = $name[0] 3 | -------------------------------------------------------------------------------- /Chapter05/11.3.1.1.Range.ps1: -------------------------------------------------------------------------------- 1 | 1..10 2 | -------------------------------------------------------------------------------- /Chapter05/11.3.1.2.Range.ps1: -------------------------------------------------------------------------------- 1 | 90..75 2 | -------------------------------------------------------------------------------- /Chapter05/11.3.1.3.Range.ps1: -------------------------------------------------------------------------------- 1 | 'a'..'f' 2 | -------------------------------------------------------------------------------- /Chapter05/11.3.1.4.Range.ps1: -------------------------------------------------------------------------------- 1 | $array = 1, 2, 3, 4, 5 2 | $array[2..4] 3 | -------------------------------------------------------------------------------- /Chapter05/11.3.1.5.Range.ps1: -------------------------------------------------------------------------------- 1 | 1..10 | ForEach-Object { Start-Sleep -Seconds 1 } 2 | -------------------------------------------------------------------------------- /Chapter05/11.4.1.1.Call.ps1: -------------------------------------------------------------------------------- 1 | & 'C:\Program Files\PowerShell\7\pwsh.exe' 2 | -------------------------------------------------------------------------------- /Chapter05/11.4.1.2.Call.ps1: -------------------------------------------------------------------------------- 1 | $pwsh = 'C:\Program Files\PowerShell\7\pwsh.exe' 2 | & $pwsh 3 | -------------------------------------------------------------------------------- /Chapter05/11.4.1.3.Call.ps1: -------------------------------------------------------------------------------- 1 | $pwsh = 'C:\Program Files\PowerShell\7\pwsh.exe' 2 | & $pwsh -NoProfile -NoLogo -Command "Write-Host 'Hello world'" 3 | -------------------------------------------------------------------------------- /Chapter05/11.4.1.5.Call.ps1: -------------------------------------------------------------------------------- 1 | $scriptBlock = { Write-Host 'Hello world' } 2 | & $scriptBlock 3 | -------------------------------------------------------------------------------- /Chapter05/11.5.1.10.Format.ps1: -------------------------------------------------------------------------------- 1 | '{0}, {1}' -f 'one', 'two', 'three', 'four' 2 | -------------------------------------------------------------------------------- /Chapter05/11.5.1.12.Format.ps1: -------------------------------------------------------------------------------- 1 | $shortFormat -f $errorDetails 2 | $longFormat -f $errorDetails 3 | -------------------------------------------------------------------------------- /Chapter05/11.5.1.2.Format.ps1: -------------------------------------------------------------------------------- 1 | $word = 'one' 2 | "Length: $($word.Length)" 3 | -------------------------------------------------------------------------------- /Chapter05/11.5.1.3.Format.ps1: -------------------------------------------------------------------------------- 1 | $word = 'one' 2 | 'Length: {0}' -f $word.Length 3 | -------------------------------------------------------------------------------- /Chapter05/11.5.1.4.Format.ps1: -------------------------------------------------------------------------------- 1 | 'The pass mark is {0:P}' -f 0.8 2 | -------------------------------------------------------------------------------- /Chapter05/11.5.1.5.Format.ps1: -------------------------------------------------------------------------------- 1 | '244 in Hexadecimal is {0:X2}' -f 244 2 | -------------------------------------------------------------------------------- /Chapter05/11.5.1.6.Format.ps1: -------------------------------------------------------------------------------- 1 | 'The price is {0:C2}' -f 199 2 | -------------------------------------------------------------------------------- /Chapter05/11.5.1.7.Format.ps1: -------------------------------------------------------------------------------- 1 | 'Today is {0:dddd} the {0:dd} of {0:MMMM}' -f (Get-Date) 2 | -------------------------------------------------------------------------------- /Chapter05/11.5.1.8.Format.ps1: -------------------------------------------------------------------------------- 1 | 'The value in {{0}} is {0}' -f 1 2 | -------------------------------------------------------------------------------- /Chapter05/11.6.1.1.join.ps1: -------------------------------------------------------------------------------- 1 | 'a', 'b', 'c', 'd' -join "`t" 2 | 3 | # Expects output: 4 | # 5 | # a b c d 6 | -------------------------------------------------------------------------------- /Chapter05/11.6.1.2.join.ps1: -------------------------------------------------------------------------------- 1 | -join ('hello', 'world') 2 | 3 | # Expects output: 4 | # 5 | # helloworld 6 | -------------------------------------------------------------------------------- /Chapter05/11.7.1.2.Null coalescing.ps1: -------------------------------------------------------------------------------- 1 | $valueA = $null 2 | $valueB = $valueA ?? 'Default value' 3 | -------------------------------------------------------------------------------- /Chapter05/11.7.1.3.Null coalescing.ps1: -------------------------------------------------------------------------------- 1 | $valueA = 'Supplied value' 2 | $valueA ?? 'Default value' 3 | -------------------------------------------------------------------------------- /Chapter05/11.7.1.6.Null coalescing.ps1: -------------------------------------------------------------------------------- 1 | (first) ?? (second) ?? (third) ?? 'default' 2 | -------------------------------------------------------------------------------- /Chapter05/11.7.2.1.Null coalescing assignment.ps1: -------------------------------------------------------------------------------- 1 | $value = $null 2 | if ($null -eq $value) { 3 | $value = 1 4 | } 5 | -------------------------------------------------------------------------------- /Chapter05/11.7.2.2.Null coalescing assignment.ps1: -------------------------------------------------------------------------------- 1 | $value = $null 2 | $value ??= 1 3 | -------------------------------------------------------------------------------- /Chapter05/11.7.2.3.Null coalescing assignment.ps1: -------------------------------------------------------------------------------- 1 | $value = 1 2 | $value ??= 2 3 | -------------------------------------------------------------------------------- /Chapter05/11.8.1.2.Null conditional.ps1: -------------------------------------------------------------------------------- 1 | ${someObject}?.ToString() 2 | -------------------------------------------------------------------------------- /Chapter05/11.8.1.3.Null conditional.ps1: -------------------------------------------------------------------------------- 1 | $someOtherObject = [PSCustomObject]@{ 2 | Value = $null 3 | } 4 | $someOtherObject.Value?.ToString() 5 | -------------------------------------------------------------------------------- /Chapter05/11.9.1.1.Pipeline chain.ps1: -------------------------------------------------------------------------------- 1 | Get-Item . 2 | -------------------------------------------------------------------------------- /Chapter05/11.9.1.3.Pipeline chain.ps1: -------------------------------------------------------------------------------- 1 | Get-Item DoesNotExist -ErrorAction Ignore && 2 | Write-Host 'Exists' 3 | -------------------------------------------------------------------------------- /Chapter05/11.9.1.4.Pipeline chain.ps1: -------------------------------------------------------------------------------- 1 | Get-Item DoesNotExist -ErrorAction Ignore || 2 | Write-Host 'Does not exist' 3 | -------------------------------------------------------------------------------- /Chapter05/11.9.1.5.Pipeline chain.ps1: -------------------------------------------------------------------------------- 1 | Get-Item DoesNotExist -ErrorAction Ignore 2 | if (-not $?) { 3 | Write-Host 'Does not exist' 4 | } 5 | -------------------------------------------------------------------------------- /Chapter05/11.9.1.7.Pipeline chain.ps1: -------------------------------------------------------------------------------- 1 | installApplication.exe && application.exe 2 | -------------------------------------------------------------------------------- /Chapter05/2.0.0.1.Unary, Binary, and Ternary operators.ps1: -------------------------------------------------------------------------------- 1 | -not $false 2 | -------------------------------------------------------------------------------- /Chapter05/2.0.0.2.Unary, Binary, and Ternary operators.ps1: -------------------------------------------------------------------------------- 1 | +1 2 | -1 3 | -------------------------------------------------------------------------------- /Chapter05/2.0.0.3.Unary, Binary, and Ternary operators.ps1: -------------------------------------------------------------------------------- 1 | 1 + 1 2 | 1 - 1 3 | -------------------------------------------------------------------------------- /Chapter05/2.1.1.1.About the ternary operator.ps1: -------------------------------------------------------------------------------- 1 | $result = if ($value) { 2 | 1 3 | } else { 4 | 2 5 | } 6 | -------------------------------------------------------------------------------- /Chapter05/2.1.1.2.About the ternary operator.ps1: -------------------------------------------------------------------------------- 1 | $result = $value ? 1 : 2 2 | -------------------------------------------------------------------------------- /Chapter05/2.1.1.3.About the ternary operator.ps1: -------------------------------------------------------------------------------- 1 | (Get-Process notepad -ErrorAction Ignore) ? 'Running' : 'Not running' 2 | -------------------------------------------------------------------------------- /Chapter05/3.1.1.1.Addition operator.ps1: -------------------------------------------------------------------------------- 1 | 2.71828 + 3.14159 2 | -------------------------------------------------------------------------------- /Chapter05/3.1.1.10.Addition operator.ps1: -------------------------------------------------------------------------------- 1 | @(1, 2) + 3 2 | -------------------------------------------------------------------------------- /Chapter05/3.1.1.11.Addition operator.ps1: -------------------------------------------------------------------------------- 1 | @(1, 2) + @(3, 4) 2 | (1, 2) + (3, 4) 3 | 1, 2 + 3, 4 4 | -------------------------------------------------------------------------------- /Chapter05/3.1.1.13.Addition operator.ps1: -------------------------------------------------------------------------------- 1 | @{key1 = 1} + @{key2 = 2} 2 | -------------------------------------------------------------------------------- /Chapter05/3.1.1.2.Addition operator.ps1: -------------------------------------------------------------------------------- 1 | 'good' + 'bye' 2 | -------------------------------------------------------------------------------- /Chapter05/3.1.1.3.Addition operator.ps1: -------------------------------------------------------------------------------- 1 | $word = 'one' 2 | "Length: “ + $word.Length 3 | -------------------------------------------------------------------------------- /Chapter05/3.1.1.4.Addition operator.ps1: -------------------------------------------------------------------------------- 1 | 'hello number ' + 1 2 | -------------------------------------------------------------------------------- /Chapter05/3.1.1.5.Addition operator.ps1: -------------------------------------------------------------------------------- 1 | +1 2 | -------------------------------------------------------------------------------- /Chapter05/3.1.1.7.Addition operator.ps1: -------------------------------------------------------------------------------- 1 | $number | Get-Member 2 | 3 | # Expects output: 4 | # 5 | # +'string' 6 | -------------------------------------------------------------------------------- /Chapter05/3.1.1.9.Addition operator.ps1: -------------------------------------------------------------------------------- 1 | 1 + '4' 2 | -------------------------------------------------------------------------------- /Chapter05/3.2.1.1.Subtraction operator.ps1: -------------------------------------------------------------------------------- 1 | 5 - 2 2 | 2 - 20 3 | -------------------------------------------------------------------------------- /Chapter05/3.2.1.2.Subtraction operator.ps1: -------------------------------------------------------------------------------- 1 | -5 2 | -------------------------------------------------------------------------------- /Chapter05/3.3.1.1.Multiplication operator.ps1: -------------------------------------------------------------------------------- 1 | 2.5 * 2 2 | -------------------------------------------------------------------------------- /Chapter05/3.3.1.2.Multiplication operator.ps1: -------------------------------------------------------------------------------- 1 | 'hello' * 3 2 | -------------------------------------------------------------------------------- /Chapter05/3.3.1.4.Multiplication operator.ps1: -------------------------------------------------------------------------------- 1 | @('one', 'two') * 2 2 | ('one', 'two') * 2 3 | 'one', 'two' * 2 4 | -------------------------------------------------------------------------------- /Chapter05/3.4.1.1.Division operator.ps1: -------------------------------------------------------------------------------- 1 | 20 / 5 2 | 3 | # Expects output: 4 | # 5 | # 4 6 | -------------------------------------------------------------------------------- /Chapter05/3.4.1.2.Division operator.ps1: -------------------------------------------------------------------------------- 1 | 1 / 0 2 | 3 | # Expects output: 4 | # 5 | # RuntimeException: Attempted to divide by zero. 6 | -------------------------------------------------------------------------------- /Chapter05/3.5.1.1.Remainder operator.ps1: -------------------------------------------------------------------------------- 1 | 3 % 2 2 | -------------------------------------------------------------------------------- /Chapter05/3.6.1.1.Increment and decrement operators.ps1: -------------------------------------------------------------------------------- 1 | $i = 0 2 | $i++ # Post-increment 3 | $i-- # Post-decrement 4 | -------------------------------------------------------------------------------- /Chapter05/3.6.1.2.Increment and decrement operators.ps1: -------------------------------------------------------------------------------- 1 | $i = 0 2 | ++$i # Pre-increment 3 | --$i # Pre-decrement 4 | -------------------------------------------------------------------------------- /Chapter05/3.6.1.4.Increment and decrement operators.ps1: -------------------------------------------------------------------------------- 1 | $i = 0 2 | ($i++) # Post-increment 3 | ($i--) # Post-decrement 4 | -------------------------------------------------------------------------------- /Chapter05/3.6.1.5.Increment and decrement operators.ps1: -------------------------------------------------------------------------------- 1 | $i = 0 2 | (++$i) # Pre-increment 3 | (--$i) # Pre-decrement 4 | -------------------------------------------------------------------------------- /Chapter05/3.6.1.6.Increment and decrement operators.ps1: -------------------------------------------------------------------------------- 1 | for ($i = 1; $i -le 15; $i++) { 2 | Write-Host $i -ForegroundColor $i 3 | } 4 | -------------------------------------------------------------------------------- /Chapter05/3.6.1.7.Increment and decrement operators.ps1: -------------------------------------------------------------------------------- 1 | for ($i = 15; $i -ge 0; $i--) { 2 | Write-Host $i -ForegroundColor $i 3 | } 4 | -------------------------------------------------------------------------------- /Chapter05/4.1.1.1.eq and ne.ps1: -------------------------------------------------------------------------------- 1 | 1 -eq 1 2 | 'string' -eq 'string' 3 | -------------------------------------------------------------------------------- /Chapter05/4.1.1.2.eq and ne.ps1: -------------------------------------------------------------------------------- 1 | 20 -ne 100 2 | 'this' -ne 'that' 3 | -------------------------------------------------------------------------------- /Chapter05/4.1.1.3.eq and ne.ps1: -------------------------------------------------------------------------------- 1 | 1 -eq '1' 2 | -------------------------------------------------------------------------------- /Chapter05/4.1.1.4.eq and ne.ps1: -------------------------------------------------------------------------------- 1 | '1' -eq 1 2 | -------------------------------------------------------------------------------- /Chapter05/4.1.1.5.eq and ne.ps1: -------------------------------------------------------------------------------- 1 | 1 -eq 'one' 2 | -------------------------------------------------------------------------------- /Chapter05/4.1.1.6.eq and ne.ps1: -------------------------------------------------------------------------------- 1 | $true -eq 'True' 2 | -------------------------------------------------------------------------------- /Chapter05/4.1.1.7.eq and ne.ps1: -------------------------------------------------------------------------------- 1 | $false -eq 'False' 2 | -------------------------------------------------------------------------------- /Chapter05/4.1.1.8.eq and ne.ps1: -------------------------------------------------------------------------------- 1 | [bool]'True' 2 | [bool]'False' 3 | -------------------------------------------------------------------------------- /Chapter05/4.2.1.1.like and notlike.ps1: -------------------------------------------------------------------------------- 1 | 'The cow jumped over the moon' -like '*moon*' 2 | '' -like '*' 3 | -------------------------------------------------------------------------------- /Chapter05/4.2.1.2.like and notlike.ps1: -------------------------------------------------------------------------------- 1 | 'Hello world' -like '?ello ?orld' 2 | 'Hello world' -like '??llo w*' 3 | 4 | '' -notlike '?*' 5 | -------------------------------------------------------------------------------- /Chapter05/4.2.1.3.like and notlike.ps1: -------------------------------------------------------------------------------- 1 | 'Hello world' -like '?*' 2 | 'Hello world' -like '*?' 3 | -------------------------------------------------------------------------------- /Chapter05/4.2.1.4.like and notlike.ps1: -------------------------------------------------------------------------------- 1 | '' -like '?*' 2 | -------------------------------------------------------------------------------- /Chapter05/4.2.1.5.like and notlike.ps1: -------------------------------------------------------------------------------- 1 | 'Hello world' -like '[f-k]*' 2 | -------------------------------------------------------------------------------- /Chapter05/4.2.1.6.like and notlike.ps1: -------------------------------------------------------------------------------- 1 | '*.txt' -like '`*.txt' 2 | '*.txt' -like '`*.*' 3 | -------------------------------------------------------------------------------- /Chapter05/4.2.1.7.like and notlike.ps1: -------------------------------------------------------------------------------- 1 | [WildcardPattern]::Escape('* [a-z] ?') 2 | -------------------------------------------------------------------------------- /Chapter05/4.2.1.8.like and notlike.ps1: -------------------------------------------------------------------------------- 1 | `* `[a-z`] `? 2 | -------------------------------------------------------------------------------- /Chapter05/4.3.1.3.Greater than and less than.ps1: -------------------------------------------------------------------------------- 1 | 'bat' -clt 'Bat' # True, b before B 2 | 'Bat' -clt 'cat' # True, B before c 3 | -------------------------------------------------------------------------------- /Chapter05/4.4.1.1.Case sensitivity.ps1: -------------------------------------------------------------------------------- 1 | 'Trees' -eq 'trees' 2 | -------------------------------------------------------------------------------- /Chapter05/4.4.1.2.Case sensitivity.ps1: -------------------------------------------------------------------------------- 1 | 'Trees' -ceq 'trees' 2 | -------------------------------------------------------------------------------- /Chapter05/4.4.1.3.Case sensitivity.ps1: -------------------------------------------------------------------------------- 1 | 'Trees' -ieq 'trees' 2 | -------------------------------------------------------------------------------- /Chapter05/4.5.1.2.Comparison operators and arrays.ps1: -------------------------------------------------------------------------------- 1 | $value = 'one' 2 | if ($value -notlike 't*') { 3 | 'two or three not found' 4 | } 5 | -------------------------------------------------------------------------------- /Chapter05/4.5.1.5.Comparison operators and arrays.ps1: -------------------------------------------------------------------------------- 1 | $value = 'one', 'two', 'three' 2 | $value -notlike 't*' # Returns the value "one" 3 | -------------------------------------------------------------------------------- /Chapter05/4.6.1.1.Comparisons to null.ps1: -------------------------------------------------------------------------------- 1 | $array = 1, 2 2 | if ($array -eq $null) { Write-Host 'Variable not set' } 3 | -------------------------------------------------------------------------------- /Chapter05/4.6.1.3.Comparisons to null.ps1: -------------------------------------------------------------------------------- 1 | [bool]@($null) # Returns false 2 | [bool]@($null, $null) # Returns true 3 | -------------------------------------------------------------------------------- /Chapter05/4.6.1.4.Comparisons to null.ps1: -------------------------------------------------------------------------------- 1 | $array = 1, 2, $null, $null 2 | if ($null -eq $array) { Write-Host 'Variable not set' } 3 | -------------------------------------------------------------------------------- /Chapter05/4.7.1.1.contains and in.ps1: -------------------------------------------------------------------------------- 1 | 1, 2 -contains 2 # Returns true 2 | 1, 2, 3 -contains 4 # Returns false 3 | -------------------------------------------------------------------------------- /Chapter05/4.7.1.2.contains and in.ps1: -------------------------------------------------------------------------------- 1 | 1 -in 1, 2, 3 # Returns true 2 | 4 -in 1, 2, 3 # Returns false 3 | -------------------------------------------------------------------------------- /Chapter05/5.1.1.2.match and notmatch.ps1: -------------------------------------------------------------------------------- 1 | '1234567689' -match '[0-4]*' 2 | -------------------------------------------------------------------------------- /Chapter05/5.1.1.5.match and notmatch.ps1: -------------------------------------------------------------------------------- 1 | $matches[1] 2 | $matches.1 3 | -------------------------------------------------------------------------------- /Chapter05/5.2.1.1.replace.ps1: -------------------------------------------------------------------------------- 1 | 'abababab' -replace 'a', 'c' 2 | 3 | # Expects output: 4 | # 5 | # cbcbcbcb 6 | -------------------------------------------------------------------------------- /Chapter05/5.2.1.2.replace.ps1: -------------------------------------------------------------------------------- 1 | 'abababab' -replace 'a' 2 | 3 | # Expects output: 4 | # 5 | # bbbb 6 | -------------------------------------------------------------------------------- /Chapter05/5.2.1.3.replace.ps1: -------------------------------------------------------------------------------- 1 | 'value1,value2,value3' -replace '(.*),(.*),(.*)', '$3,$2,$1' 2 | -------------------------------------------------------------------------------- /Chapter05/5.2.1.4.replace.ps1: -------------------------------------------------------------------------------- 1 | '1' -replace '.', 'No groups, $1 is not substituted' 2 | -------------------------------------------------------------------------------- /Chapter05/5.2.1.5.replace.ps1: -------------------------------------------------------------------------------- 1 | '1' -replace '(1)', 'The value of group $$1 is $1' 2 | -------------------------------------------------------------------------------- /Chapter05/5.2.1.7.replace.ps1: -------------------------------------------------------------------------------- 1 | '0', '4', $PID -replace '.+', { (Get-Process -Id $_.Value).Name } 2 | -------------------------------------------------------------------------------- /Chapter05/5.2.1.9.replace.ps1: -------------------------------------------------------------------------------- 1 | Process: Idle 2 | Process: System 3 | Process: pwsh 4 | -------------------------------------------------------------------------------- /Chapter05/5.3.1.1.split.ps1: -------------------------------------------------------------------------------- 1 | 'a1b2c3d4' -split '[0-9]' 2 | 3 | # Expects output: 4 | # 5 | # a 6 | # b 7 | # c 8 | # d 9 | -------------------------------------------------------------------------------- /Chapter05/5.3.1.2.split.ps1: -------------------------------------------------------------------------------- 1 | -split "a`tb c" 2 | -------------------------------------------------------------------------------- /Chapter05/5.3.1.3.split.ps1: -------------------------------------------------------------------------------- 1 | $first, $second, $third = '1,2,3,4,5' -split ',' 2 | -------------------------------------------------------------------------------- /Chapter05/5.3.1.4.split.ps1: -------------------------------------------------------------------------------- 1 | $first, $second, $null = '1,2,3,4,5' -split ',' 2 | -------------------------------------------------------------------------------- /Chapter05/5.3.1.5.split.ps1: -------------------------------------------------------------------------------- 1 | $split = '1,2,3,4,5' -split ',', 2 2 | 3 | # Expects output: 4 | # 5 | # 1 6 | # 2,3,4,5 7 | -------------------------------------------------------------------------------- /Chapter05/5.3.1.6.split.ps1: -------------------------------------------------------------------------------- 1 | $split = '1,2,3,4,5' -split ',', -2 2 | 3 | # Expects output: 4 | # 5 | # 1,2,3,4 6 | # 5 7 | -------------------------------------------------------------------------------- /Chapter05/5.3.1.7.split.ps1: -------------------------------------------------------------------------------- 1 | $split = '1,2,3,4,5' -split ',', -3 2 | 3 | # Expects output: 4 | # 5 | # 1,2,3 6 | # 4 7 | # 5 8 | -------------------------------------------------------------------------------- /Chapter05/5.3.1.8.split.ps1: -------------------------------------------------------------------------------- 1 | 'a?b?c?d?' -split 'b?', 0, 'SimpleMatch' 2 | -------------------------------------------------------------------------------- /Chapter05/5.3.1.9.split.ps1: -------------------------------------------------------------------------------- 1 | 'axbxcxd' -csplit ' X ', 0, 'IgnoreCase, IgnorePatternWhiteSpace' 2 | -------------------------------------------------------------------------------- /Chapter05/6.3.1.1.not.ps1: -------------------------------------------------------------------------------- 1 | -not $false 2 | -not (Test-Path X:\) 3 | -not ($true -and $false) 4 | !($true -and $false) 5 | -------------------------------------------------------------------------------- /Chapter05/6.3.1.2.not.ps1: -------------------------------------------------------------------------------- 1 | -not 'string' 2 | !'string' 3 | -------------------------------------------------------------------------------- /Chapter05/6.3.1.3.not.ps1: -------------------------------------------------------------------------------- 1 | $string = 'string' 2 | -not -not $string 3 | -------------------------------------------------------------------------------- /Chapter05/6.3.1.4.not.ps1: -------------------------------------------------------------------------------- 1 | $string 2 | !!$string 3 | -------------------------------------------------------------------------------- /Chapter05/6.4.1.1.xor (eXclusive OR).ps1: -------------------------------------------------------------------------------- 1 | $true -xor $false 2 | 1 -le 2 -xor 1 -eq 2 3 | (Test-Path C:\Windows) -xor (Test-Path D:\Windows) 4 | -------------------------------------------------------------------------------- /Chapter05/7.0.0.1.Bitwise operators.ps1: -------------------------------------------------------------------------------- 1 | # Both sides are int, result is System.Int32 2 | 1 -band 1 | Get-Member 3 | -------------------------------------------------------------------------------- /Chapter05/7.0.0.2.Bitwise operators.ps1: -------------------------------------------------------------------------------- 1 | # Both sides are byte, result is Int32 2 | [byte]1 -band [byte]1 | Get-Member 3 | -------------------------------------------------------------------------------- /Chapter05/7.0.0.3.Bitwise operators.ps1: -------------------------------------------------------------------------------- 1 | [Int64]1 -band 1 | Get-Member 2 | 1 -band [Int64]1 | Get-Member 3 | -------------------------------------------------------------------------------- /Chapter05/7.1.1.1.band (Bitwise AND).ps1: -------------------------------------------------------------------------------- 1 | 11 -band 6 2 | -------------------------------------------------------------------------------- /Chapter05/7.2.1.1.bor (Bitwise OR).ps1: -------------------------------------------------------------------------------- 1 | 11 -bor 12 2 | -------------------------------------------------------------------------------- /Chapter05/7.3.1.1.bxor (Bitwise eXclusive OR).ps1: -------------------------------------------------------------------------------- 1 | 6 -bxor 13 2 | -------------------------------------------------------------------------------- /Chapter05/7.4.1.1.bnot (Bitwise NOT).ps1: -------------------------------------------------------------------------------- 1 | -bnot 122 2 | -------------------------------------------------------------------------------- /Chapter05/7.5.1.1.shl and shr (Shift left and right operators).ps1: -------------------------------------------------------------------------------- 1 | 2 * 4 -shl 2 + 2 2 | -------------------------------------------------------------------------------- /Chapter05/7.5.1.2.shl and shr (Shift left and right operators).ps1: -------------------------------------------------------------------------------- 1 | 78 -shl 1 2 | -------------------------------------------------------------------------------- /Chapter05/7.5.1.3.shl and shr (Shift left and right operators).ps1: -------------------------------------------------------------------------------- 1 | 156 -shr 1 2 | 3 | # Expects output: 4 | # 5 | # 78 6 | -------------------------------------------------------------------------------- /Chapter05/7.5.1.4.shl and shr (Shift left and right operators).ps1: -------------------------------------------------------------------------------- 1 | 3 -shr 1 2 | 3 | # Expects output: 4 | # 5 | # 1 6 | -------------------------------------------------------------------------------- /Chapter05/7.5.1.5.shl and shr (Shift left and right operators).ps1: -------------------------------------------------------------------------------- 1 | [byte]255 -shl 1 2 | 3 | # Expects output: 4 | # 5 | # 254 6 | -------------------------------------------------------------------------------- /Chapter05/7.5.1.6.shl and shr (Shift left and right operators).ps1: -------------------------------------------------------------------------------- 1 | [Int16]255 -shl 1 2 | 3 | # Expects output: 4 | # 5 | # 510 6 | -------------------------------------------------------------------------------- /Chapter05/7.5.1.7.shl and shr (Shift left and right operators).ps1: -------------------------------------------------------------------------------- 1 | ([SByte]64) -shl 1 2 | 3 | # Expects output: 4 | # 5 | # -128 6 | -------------------------------------------------------------------------------- /Chapter05/7.5.1.8.shl and shr (Shift left and right operators).ps1: -------------------------------------------------------------------------------- 1 | (192 -shl 24) + (168 -shl 16) + (4 -shl 8) + 32 2 | -------------------------------------------------------------------------------- /Chapter05/8.1.1.1.Assign, add and assign, and subtract and assign.ps1: -------------------------------------------------------------------------------- 1 | $variable = 'some value' 2 | -------------------------------------------------------------------------------- /Chapter05/8.1.1.10.Assign, add and assign, and subtract and assign.ps1: -------------------------------------------------------------------------------- 1 | $i = 20 2 | $i -= 2 3 | -------------------------------------------------------------------------------- /Chapter05/8.1.1.2.Assign, add and assign, and subtract and assign.ps1: -------------------------------------------------------------------------------- 1 | $host.UI.RawUI.WindowTitle = 'PowerShell window' 2 | -------------------------------------------------------------------------------- /Chapter05/8.1.1.3.Assign, add and assign, and subtract and assign.ps1: -------------------------------------------------------------------------------- 1 | $i = 1 2 | $i += 20 3 | -------------------------------------------------------------------------------- /Chapter05/8.1.1.4.Assign, add and assign, and subtract and assign.ps1: -------------------------------------------------------------------------------- 1 | $i = 1 2 | $i = $i + 20 3 | -------------------------------------------------------------------------------- /Chapter05/8.1.1.5.Assign, add and assign, and subtract and assign.ps1: -------------------------------------------------------------------------------- 1 | $string = 'one' 2 | $string += 'one' 3 | -------------------------------------------------------------------------------- /Chapter05/8.1.1.7.Assign, add and assign, and subtract and assign.ps1: -------------------------------------------------------------------------------- 1 | $array = 1, 2 2 | $array += 3 3 | -------------------------------------------------------------------------------- /Chapter05/8.1.1.8.Assign, add and assign, and subtract and assign.ps1: -------------------------------------------------------------------------------- 1 | $array = 1, 2 2 | $array += 3, 4 3 | -------------------------------------------------------------------------------- /Chapter05/8.1.1.9.Assign, add and assign, and subtract and assign.ps1: -------------------------------------------------------------------------------- 1 | $hashtable = @{key1 = 1} 2 | $hashtable += @{key2 = 2} 3 | -------------------------------------------------------------------------------- /Chapter05/8.2.1.1.Multiply and assign, divide and assign, and modulus and assign.ps1: -------------------------------------------------------------------------------- 1 | $i = 2 2 | $i *= 2 3 | -------------------------------------------------------------------------------- /Chapter05/8.2.1.2.Multiply and assign, divide and assign, and modulus and assign.ps1: -------------------------------------------------------------------------------- 1 | $string = 'one' 2 | $string *= 2 3 | -------------------------------------------------------------------------------- /Chapter05/8.2.1.3.Multiply and assign, divide and assign, and modulus and assign.ps1: -------------------------------------------------------------------------------- 1 | $string = 'one' 2 | $string *= '2' 3 | -------------------------------------------------------------------------------- /Chapter05/8.2.1.5.Multiply and assign, divide and assign, and modulus and assign.ps1: -------------------------------------------------------------------------------- 1 | $variable = 1, 2 2 | $variable *= 2 3 | -------------------------------------------------------------------------------- /Chapter05/8.2.1.6.Multiply and assign, divide and assign, and modulus and assign.ps1: -------------------------------------------------------------------------------- 1 | $variable = 2 2 | $variable /= 2 3 | -------------------------------------------------------------------------------- /Chapter05/8.2.1.7.Multiply and assign, divide and assign, and modulus and assign.ps1: -------------------------------------------------------------------------------- 1 | $variable = 10 2 | $variable %= 3 3 | -------------------------------------------------------------------------------- /Chapter05/9.1.1.1.as.ps1: -------------------------------------------------------------------------------- 1 | "1" -as [Int32] 2 | 'String' -as [Type] 3 | -------------------------------------------------------------------------------- /Chapter05/9.1.1.2.as.ps1: -------------------------------------------------------------------------------- 1 | $true -as [DateTime] 2 | -------------------------------------------------------------------------------- /Chapter05/9.2.1.1.is and isnot.ps1: -------------------------------------------------------------------------------- 1 | 'string' -is [String] 2 | 1 -is [Int32] 3 | [String] -is [Type] 4 | 123 -isnot [String] 5 | -------------------------------------------------------------------------------- /Chapter06/1.1.1.1.Assignment within If statements.ps1: -------------------------------------------------------------------------------- 1 | if ($i = 1) { 2 | Write-Host "The variable i is $i" 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/2.0.0.1.Implicit Boolean.ps1: -------------------------------------------------------------------------------- 1 | if (Get-ChildItem c:\users\a*) { 2 | # If statement body 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/2.0.0.2.Implicit Boolean.ps1: -------------------------------------------------------------------------------- 1 | if ($null -ne (Get-ChildItem c:\users\c*)) { 2 | # If statement body 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/3.1.1.2.Switch and arrays.ps1: -------------------------------------------------------------------------------- 1 | switch (@()) { 2 | default { 'this default case will not run' } 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/3.1.1.3.Switch and arrays.ps1: -------------------------------------------------------------------------------- 1 | switch ($null) { 2 | default { 'this default case will run' } 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/3.5.1.2.Switch and Enum.ps1: -------------------------------------------------------------------------------- 1 | switch ('[DayOfWeek]::Monday') { 2 | [DayOfWeek]::Monday { 'This case matched' } 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/3.5.1.3.Switch and Enum.ps1: -------------------------------------------------------------------------------- 1 | switch ((Get-Date).DayOfWeek) { 2 | 'Monday' { 'Monday' } 3 | 'Tuesday' { 'Tuesday' } 4 | } 5 | -------------------------------------------------------------------------------- /Chapter06/3.5.1.5.Switch and Enum.ps1: -------------------------------------------------------------------------------- 1 | switch ((Get-Date).Date) { 2 | ([DateTime]::Today) { 'It is still today' } 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/5.1.1.1.foreach loop.ps1: -------------------------------------------------------------------------------- 1 | foreach ($process in Get-Process) { 2 | Write-Host $process.Name 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/5.1.2.1.ForEach keyword and ForEach alias.ps1: -------------------------------------------------------------------------------- 1 | $array = 1..3 2 | foreach ($value in $array) { 3 | 'Will repeat three times!' 4 | } 5 | -------------------------------------------------------------------------------- /Chapter06/5.1.2.2.ForEach keyword and ForEach alias.ps1: -------------------------------------------------------------------------------- 1 | $array = 1..3 2 | $array | foreach { 3 | 'Will repeat three times!' 4 | } 5 | -------------------------------------------------------------------------------- /Chapter06/5.2.1.2.For loop.ps1: -------------------------------------------------------------------------------- 1 | for ($i = 0; $i -lt $processes.Count; $i += 3) { 2 | Write-Host $processes[$i].Name 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/5.2.1.3.For loop.ps1: -------------------------------------------------------------------------------- 1 | for ($i = $processes.Count - 1; $i -ge 0; $i--) { 2 | Write-Host $processes[$i].Name 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/5.2.1.5.For loop.ps1: -------------------------------------------------------------------------------- 1 | for (;;) { 2 | break 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/5.2.1.6.For loop.ps1: -------------------------------------------------------------------------------- 1 | for (($i = 0), ($j = 0); $i -le 10 ; $i++, ($j += 2)) { 2 | Write-Host "$i :: $j" 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/5.2.1.7.For loop.ps1: -------------------------------------------------------------------------------- 1 | $i -le 10 -and $j -le 20 2 | -------------------------------------------------------------------------------- /Chapter06/5.3.1.1.do-until and do-while loops.ps1: -------------------------------------------------------------------------------- 1 | do { 2 | 3 | } () 4 | -------------------------------------------------------------------------------- /Chapter06/5.4.1.1.while loop.ps1: -------------------------------------------------------------------------------- 1 | while (-not (Test-Path $env:TEMP\test.txt -PathType Leaf)) { 2 | Start-Sleep -Seconds 10 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/7.0.0.1.Loops and labels.ps1: -------------------------------------------------------------------------------- 1 | :ThisIsALabel foreach ($value in 1..10) { 2 | $value 3 | } 4 | -------------------------------------------------------------------------------- /Chapter06/7.0.0.2.Loops and labels.ps1: -------------------------------------------------------------------------------- 1 | :ThisIsALabel 2 | foreach ($value in 1..10) { 3 | $value 4 | } 5 | -------------------------------------------------------------------------------- /Chapter06/8.0.0.3.Loops, Queues, and Stacks.ps1: -------------------------------------------------------------------------------- 1 | $path = Get-Item Project 2 | $queue = [System.Collections.Generic.Queue[object]]$path 3 | -------------------------------------------------------------------------------- /Chapter07/1.0.0.3.Assemblies.ps1: -------------------------------------------------------------------------------- 1 | Install-Module ClassExplorer 2 | Get-Assembly 3 | -------------------------------------------------------------------------------- /Chapter07/1.0.0.4.Assemblies.ps1: -------------------------------------------------------------------------------- 1 | Add-Type -AssemblyName System.Windows.Forms 2 | -------------------------------------------------------------------------------- /Chapter07/1.0.0.5.Assemblies.ps1: -------------------------------------------------------------------------------- 1 | [System.Management.Automation.PowerShell].Assembly 2 | -------------------------------------------------------------------------------- /Chapter07/1.0.0.6.Assemblies.ps1: -------------------------------------------------------------------------------- 1 | [System.Management.Automation.PSCredential].Assembly 2 | [System.Management.Automation.PSObject].Assembly 3 | -------------------------------------------------------------------------------- /Chapter07/2.1.1.1.Type descriptions are objects in PowerShell.ps1: -------------------------------------------------------------------------------- 1 | [System.AppDomain].GetType() 2 | -------------------------------------------------------------------------------- /Chapter07/2.4.1.1.Namespaces.ps1: -------------------------------------------------------------------------------- 1 | [System.IO.File].Namespace 2 | 3 | # Expects output: 4 | # 5 | # System.IO 6 | -------------------------------------------------------------------------------- /Chapter07/2.4.1.2.Namespaces.ps1: -------------------------------------------------------------------------------- 1 | [AppDomain]::CurrentDomain.GetAssemblies() 2 | -------------------------------------------------------------------------------- /Chapter07/2.4.1.3.Namespaces.ps1: -------------------------------------------------------------------------------- 1 | [Management.Automation.PowerShell].Assembly 2 | -------------------------------------------------------------------------------- /Chapter07/3.1.1.1.Using namespaces.ps1: -------------------------------------------------------------------------------- 1 | [File] 2 | 3 | # Expects output: 4 | # 5 | # InvalidOperation: Unable to find type [File]. 6 | -------------------------------------------------------------------------------- /Chapter07/3.1.1.3.Using namespaces.ps1: -------------------------------------------------------------------------------- 1 | using namespace System.IO 2 | using namespace System.Data.SqlClient 3 | -------------------------------------------------------------------------------- /Chapter07/3.1.1.5.Using namespaces.ps1: -------------------------------------------------------------------------------- 1 | [File] 2 | 3 | # Expects output: 4 | # 5 | # InvalidOperation: Unable to find type [File]. 6 | -------------------------------------------------------------------------------- /Chapter07/3.1.1.6.Using namespaces.ps1: -------------------------------------------------------------------------------- 1 | using namespace System.IO; using namespace System.Data.SqlClient 2 | -------------------------------------------------------------------------------- /Chapter07/3.2.1.1.Using assemblies.ps1: -------------------------------------------------------------------------------- 1 | using assembly System.Windows.Forms 2 | -------------------------------------------------------------------------------- /Chapter07/3.2.1.2.Using assemblies.ps1: -------------------------------------------------------------------------------- 1 | using assembly 'C:\Program Files\PowerShell\7\System.Windows.Forms.dll' 2 | -------------------------------------------------------------------------------- /Chapter07/4.0.0.1.Type accelerators.ps1: -------------------------------------------------------------------------------- 1 | [PowerShell].Assembly 2 | -------------------------------------------------------------------------------- /Chapter07/4.0.0.3.Type accelerators.ps1: -------------------------------------------------------------------------------- 1 | [ADSI].FullName 2 | 3 | # Expects output: 4 | # 5 | # System.DirectoryServices.DirectoryEntry 6 | -------------------------------------------------------------------------------- /Chapter07/4.0.0.4.Type accelerators.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_Type_Accelerators 2 | -------------------------------------------------------------------------------- /Chapter07/4.1.1.1.About PSCustomObject and Ordered.ps1: -------------------------------------------------------------------------------- 1 | [int]"1" 2 | "1" -as [int] 3 | -------------------------------------------------------------------------------- /Chapter07/4.1.1.2.About PSCustomObject and Ordered.ps1: -------------------------------------------------------------------------------- 1 | [PSCustomObject]@{ Name = 'Value' } 2 | -------------------------------------------------------------------------------- /Chapter07/4.1.1.4.About PSCustomObject and Ordered.ps1: -------------------------------------------------------------------------------- 1 | @{ Name = 'Value' } -as [PSCustomObject] 2 | -------------------------------------------------------------------------------- /Chapter07/5.1.1.1.Constructors.ps1: -------------------------------------------------------------------------------- 1 | New-Object System.Text.StringBuilder 2 | -------------------------------------------------------------------------------- /Chapter07/5.1.1.2.Constructors.ps1: -------------------------------------------------------------------------------- 1 | [System.Text.StringBuilder]::new() 2 | -------------------------------------------------------------------------------- /Chapter07/5.3.1.1.Methods.ps1: -------------------------------------------------------------------------------- 1 | $stringBuilder = [System.Text.StringBuilder]::new() 2 | $stringBuilder.Append($true) 3 | -------------------------------------------------------------------------------- /Chapter07/5.3.1.2.Methods.ps1: -------------------------------------------------------------------------------- 1 | $stringBuilder.Append([Byte]1) 2 | -------------------------------------------------------------------------------- /Chapter07/5.3.1.4.Methods.ps1: -------------------------------------------------------------------------------- 1 | $stringBuilder.ToString() 2 | 3 | # Expects output: 4 | # 5 | # Hello 6 | # World 7 | -------------------------------------------------------------------------------- /Chapter07/5.3.2.3.Fluent interfaces.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | Where-Object -Property Name -Value pwsh -EQ 2 | -------------------------------------------------------------------------------- /Chapter07/5.3.3.1.Static methods.ps1: -------------------------------------------------------------------------------- 1 | [DateTime] | Get-Member -MemberType Method -Static 2 | -------------------------------------------------------------------------------- /Chapter07/5.3.3.2.Static methods.ps1: -------------------------------------------------------------------------------- 1 | [DateTime]::IsLeapYear(2020) 2 | 3 | # Expects output: 4 | # 5 | # True 6 | -------------------------------------------------------------------------------- /Chapter07/5.3.3.3.Static methods.ps1: -------------------------------------------------------------------------------- 1 | $array = 1, 2, 3 2 | [Array]::Reverse($array) 3 | -------------------------------------------------------------------------------- /Chapter07/5.3.3.4.Static methods.ps1: -------------------------------------------------------------------------------- 1 | $array 2 | 3 | # Expects output: 4 | # 5 | # 3 6 | # 2 7 | # 1 8 | -------------------------------------------------------------------------------- /Chapter07/5.3.4.1.About the new() method.ps1: -------------------------------------------------------------------------------- 1 | [System.Text.StringBuilder]::new() 2 | -------------------------------------------------------------------------------- /Chapter07/5.4.1.2.Static properties.ps1: -------------------------------------------------------------------------------- 1 | [DateTime]::Now 2 | -------------------------------------------------------------------------------- /Chapter07/6.1.1.1.The TypeAccelerators type.ps1: -------------------------------------------------------------------------------- 1 | [PowerShell].Assembly 2 | -------------------------------------------------------------------------------- /Chapter07/6.1.1.5.The TypeAccelerators type.ps1: -------------------------------------------------------------------------------- 1 | $typeAccelerators::Get 2 | -------------------------------------------------------------------------------- /Chapter07/6.1.1.6.The TypeAccelerators type.ps1: -------------------------------------------------------------------------------- 1 | $typeAccelerators::Add( 2 | 'TypeAccelerators', 3 | $typeAccelerators 4 | ) 5 | -------------------------------------------------------------------------------- /Chapter07/6.1.1.7.The TypeAccelerators type.ps1: -------------------------------------------------------------------------------- 1 | [TypeAccelerators]::Get 2 | -------------------------------------------------------------------------------- /Chapter07/6.2.1.1.The ArgumentTypeConverterAttribute type.ps1: -------------------------------------------------------------------------------- 1 | [string]$variable = 'value' 2 | -------------------------------------------------------------------------------- /Chapter07/6.2.1.10.The ArgumentTypeConverterAttribute type.ps1: -------------------------------------------------------------------------------- 1 | Install-Module ImpliedReflection 2 | Enable-ImpliedReflection 3 | -------------------------------------------------------------------------------- /Chapter07/6.2.1.4.The ArgumentTypeConverterAttribute type.ps1: -------------------------------------------------------------------------------- 1 | $typeConverterType.GetMembers() | 2 | Select-Object Name, MemberType, IsPublic 3 | -------------------------------------------------------------------------------- /Chapter07/7.1.1.1.Generic classes.ps1: -------------------------------------------------------------------------------- 1 | [System.Collections.Generic.List[string]]::new() 2 | -------------------------------------------------------------------------------- /Chapter07/7.1.1.3.Generic classes.ps1: -------------------------------------------------------------------------------- 1 | $listOfStrings = [System.Collections.Generic.List[string]]::new() 2 | -------------------------------------------------------------------------------- /Chapter07/7.1.1.4.Generic classes.ps1: -------------------------------------------------------------------------------- 1 | using namespace System.Collections.Generic 2 | 3 | $listOfObject = [List[object]]::new() 4 | -------------------------------------------------------------------------------- /Chapter07/7.2.1.1.Generic methods.ps1: -------------------------------------------------------------------------------- 1 | Find-Type -Namespace System.Management.Automation | 2 | Find-Member -GenericParameter System.Object 3 | -------------------------------------------------------------------------------- /Chapter07/7.2.1.2.Generic methods.ps1: -------------------------------------------------------------------------------- 1 | [System.Management.Automation.LanguagePrimitives] | 2 | Get-Member ConvertTo -Static 3 | -------------------------------------------------------------------------------- /Chapter08/1.1.1.3.Indexing into strings.ps1: -------------------------------------------------------------------------------- 1 | $myString = 'abc' 2 | -join $myString[0..5] 3 | 4 | # Expects output: 5 | # 6 | # abc 7 | -------------------------------------------------------------------------------- /Chapter08/1.1.1.4.Indexing into strings.ps1: -------------------------------------------------------------------------------- 1 | $myString = 'abcdefghi' 2 | -join $myString[0,-1] 3 | 4 | # Expects output: 5 | # 6 | # ai 7 | -------------------------------------------------------------------------------- /Chapter08/1.10.1.1.Contains, StartsWith, and EndsWith.ps1: -------------------------------------------------------------------------------- 1 | $string = 'I am the subject' 2 | $string.Contains('the') # Returns $true 3 | -------------------------------------------------------------------------------- /Chapter08/1.10.1.2.Contains, StartsWith, and EndsWith.ps1: -------------------------------------------------------------------------------- 1 | $string = 'abc' 2 | $string.StartsWith('ab') 3 | $string.EndsWith('bc') 4 | -------------------------------------------------------------------------------- /Chapter08/1.2.1.5.Substring.ps1: -------------------------------------------------------------------------------- 1 | $myString = 'abcdefghi' 2 | if ($myString.Length -gt 6) { 3 | $myString.Substring(0, 6) 4 | } 5 | -------------------------------------------------------------------------------- /Chapter08/1.2.1.6.Substring.ps1: -------------------------------------------------------------------------------- 1 | $myString = 'abcdefghi' 2 | $myString.Substring(0, [Math]::Min(6, $myString.Length)) 3 | -------------------------------------------------------------------------------- /Chapter08/1.3.1.1.Split.ps1: -------------------------------------------------------------------------------- 1 | $myString = 'Surname,GivenName' 2 | $myString.Split(',') 3 | -------------------------------------------------------------------------------- /Chapter08/1.3.1.5.Split.ps1: -------------------------------------------------------------------------------- 1 | $surname, $givenName = $string.Split( 2 | ',', 3 | [StringSplitOptions]::RemoveEmptyEntries 4 | ) 5 | -------------------------------------------------------------------------------- /Chapter08/1.3.1.7.Split.ps1: -------------------------------------------------------------------------------- 1 | $string = 'one||two||three' 2 | $string.Split('||') 3 | -------------------------------------------------------------------------------- /Chapter08/1.3.1.9.Split.ps1: -------------------------------------------------------------------------------- 1 | $string = 'one||two||three' 2 | $string.Split([string[]]'||', [StringSplitOptions]::None) 3 | -------------------------------------------------------------------------------- /Chapter08/1.4.1.1.Replace.ps1: -------------------------------------------------------------------------------- 1 | $string = 'This is the first example' 2 | $string.Replace('first', 'second') 3 | -------------------------------------------------------------------------------- /Chapter08/1.4.1.3.Replace.ps1: -------------------------------------------------------------------------------- 1 | 'begin'.Replace('B', '') 2 | 3 | # Expects output: 4 | # 5 | # begin 6 | -------------------------------------------------------------------------------- /Chapter08/1.4.1.4.Replace.ps1: -------------------------------------------------------------------------------- 1 | 'begin'.Replace('B', '', $true, (Get-Culture)) 2 | 3 | # Expects output: 4 | # 5 | # egin 6 | -------------------------------------------------------------------------------- /Chapter08/1.4.1.5.Replace.ps1: -------------------------------------------------------------------------------- 1 | 'begin'.Replace( 2 | 'B', 3 | '', 4 | [StringComparison]::OrdinalIgnoreCase 5 | ) 6 | -------------------------------------------------------------------------------- /Chapter08/1.5.1.2.Trim, TrimStart, and TrimEnd.ps1: -------------------------------------------------------------------------------- 1 | $string = '*__This string is surrounded by clutter.--#' 2 | $string.Trim('*_-#') 3 | -------------------------------------------------------------------------------- /Chapter08/1.6.1.2.Insert and Remove.ps1: -------------------------------------------------------------------------------- 1 | $string = 'This is is an example' 2 | $string.Remove(4, 3) 3 | -------------------------------------------------------------------------------- /Chapter08/1.6.1.3.Insert and Remove.ps1: -------------------------------------------------------------------------------- 1 | $string = " mat`n" 2 | $string.Replace('m', 'c').Trim() 3 | -------------------------------------------------------------------------------- /Chapter08/1.9.1.1.ToUpper, ToLower, and ToTitleCase.ps1: -------------------------------------------------------------------------------- 1 | 'aBc'.ToUpper() # Returns ABC 2 | 'AbC'.ToLower() # Returns abc 3 | -------------------------------------------------------------------------------- /Chapter08/1.9.1.4.ToUpper, ToLower, and ToTitleCase.ps1: -------------------------------------------------------------------------------- 1 | $host.CurrentCulture.TextInfo.ToTitleCase('another title') 2 | -------------------------------------------------------------------------------- /Chapter08/2.1.1.2.Properties and methods of array elements.ps1: -------------------------------------------------------------------------------- 1 | ((Get-Date '01/01/2017'), (Get-Date '01/02/2017')).AddDays(5) 2 | -------------------------------------------------------------------------------- /Chapter08/2.1.1.3.Properties and methods of array elements.ps1: -------------------------------------------------------------------------------- 1 | ((Get-Date '01/01/2017'), (Get-Date '01/02/2017')).DayOfWeek 2 | -------------------------------------------------------------------------------- /Chapter08/2.2.1.2.Chaining methods.ps1: -------------------------------------------------------------------------------- 1 | $string = 'one __ three four _____ six ___' 2 | $valuesToInsert = 'two', 'five', 'seven' 3 | -------------------------------------------------------------------------------- /Chapter08/3.1.5.1.UseCulture and Delimiter.ps1: -------------------------------------------------------------------------------- 1 | Import-Csv ExcelMadeThis.csv -UseCulture 2 | -------------------------------------------------------------------------------- /Chapter08/3.1.5.2.UseCulture and Delimiter.ps1: -------------------------------------------------------------------------------- 1 | (Get-Culture).TextInfo.ListSeparator 2 | -------------------------------------------------------------------------------- /Chapter08/3.1.5.3.UseCulture and Delimiter.ps1: -------------------------------------------------------------------------------- 1 | Import-CSv ExcelMadeThis.csv -Delimiter ';' 2 | -------------------------------------------------------------------------------- /Chapter08/3.1.7.2.About quoting.ps1: -------------------------------------------------------------------------------- 1 | Name,"Phone",Age 2 | David,"0123456789",28 3 | -------------------------------------------------------------------------------- /Chapter08/3.5.1.2.Working with Base64.ps1: -------------------------------------------------------------------------------- 1 | [Convert]::ToBase64String([char[]]'Hello world') 2 | -------------------------------------------------------------------------------- /Chapter08/3.5.1.4.Working with Base64.ps1: -------------------------------------------------------------------------------- 1 | pwsh -encodedcommand VwByAGkAdABlAC0ASABvAHMAdAAgACcASABlAGwAbABvACAAdwBvAHIAbABkACcA 2 | -------------------------------------------------------------------------------- /Chapter08/4.1.1.1.Hexadecimal.ps1: -------------------------------------------------------------------------------- 1 | 0x5eb4 2 | 3 | # Expects output: 4 | # 5 | # 24244 6 | -------------------------------------------------------------------------------- /Chapter08/4.2.1.1.Numeric literals.ps1: -------------------------------------------------------------------------------- 1 | 22.5GB 2 | 3 | # Expects output: 4 | # 5 | # 24159191040 6 | -------------------------------------------------------------------------------- /Chapter08/4.2.1.3.Numeric literals.ps1: -------------------------------------------------------------------------------- 1 | [byte]1 2 | -------------------------------------------------------------------------------- /Chapter08/4.2.1.4.Numeric literals.ps1: -------------------------------------------------------------------------------- 1 | 1uy 2 | -------------------------------------------------------------------------------- /Chapter08/4.2.1.5.Numeric literals.ps1: -------------------------------------------------------------------------------- 1 | 1u | Get-Member 2 | 3 | # Expects output: 4 | # 5 | # TypeName: System.UInt32 6 | -------------------------------------------------------------------------------- /Chapter08/4.3.1.1.Power of 10.ps1: -------------------------------------------------------------------------------- 1 | 2e2 # Returns 200 (2 * 10^2) 2 | 2e-1 # Returns 0.2 (2 * 10^-1) 3 | -------------------------------------------------------------------------------- /Chapter08/4.4.1.1.Using System.Math.ps1: -------------------------------------------------------------------------------- 1 | [Math] | Get-Member -Static 2 | -------------------------------------------------------------------------------- /Chapter08/4.4.1.2.Using System.Math.ps1: -------------------------------------------------------------------------------- 1 | [Math]::Round(2.123456789, 2) 2 | -------------------------------------------------------------------------------- /Chapter08/4.4.1.3.Using System.Math.ps1: -------------------------------------------------------------------------------- 1 | [Math]::Round(2.225, 2) 2 | -------------------------------------------------------------------------------- /Chapter08/4.4.1.5.Using System.Math.ps1: -------------------------------------------------------------------------------- 1 | [Math]::Ceiling(2.1234) # Returns 3 2 | [Math]::Floor(2.9876) # Returns 2 3 | -------------------------------------------------------------------------------- /Chapter08/4.4.1.6.Using System.Math.ps1: -------------------------------------------------------------------------------- 1 | [Math]::Abs(-45748) 2 | -------------------------------------------------------------------------------- /Chapter08/4.4.1.7.Using System.Math.ps1: -------------------------------------------------------------------------------- 1 | [Math]::Pow(2, 8) # Returns 256 (28) 2 | -------------------------------------------------------------------------------- /Chapter08/4.4.1.8.Using System.Math.ps1: -------------------------------------------------------------------------------- 1 | [Math]::Sqrt(9) # Returns 3 2 | -------------------------------------------------------------------------------- /Chapter08/4.4.1.9.Using System.Math.ps1: -------------------------------------------------------------------------------- 1 | [Math]::pi # π, 3.14159265358979 2 | [Math]::e # e, 2.71828182845905 3 | -------------------------------------------------------------------------------- /Chapter08/4.5.1.2.Converting strings into numeric values.ps1: -------------------------------------------------------------------------------- 1 | $string = '5eb4' 2 | +"0x$string" 3 | -------------------------------------------------------------------------------- /Chapter08/4.5.1.3.Converting strings into numeric values.ps1: -------------------------------------------------------------------------------- 1 | $size = '1,024MB' 2 | +($size -replace ',') / 1GB 3 | -------------------------------------------------------------------------------- /Chapter08/4.5.1.4.Converting strings into numeric values.ps1: -------------------------------------------------------------------------------- 1 | [Convert]::ToInt32('01000111110101', 2) # Returns 4597 2 | -------------------------------------------------------------------------------- /Chapter08/5.1.1.3.Parsing dates.ps1: -------------------------------------------------------------------------------- 1 | $string = 'The 3rd of May, 2017', 'The 5th of December, 2023' 2 | -------------------------------------------------------------------------------- /Chapter08/5.2.1.1.Changing dates.ps1: -------------------------------------------------------------------------------- 1 | (Get-Date) + (New-Timespan -Hours 6) 2 | -------------------------------------------------------------------------------- /Chapter08/5.2.1.10.Changing dates.ps1: -------------------------------------------------------------------------------- 1 | Get-Date -Format 'dd/MM/yyyy HH:mm' 2 | (Get-Date).ToString('dd/MM/yyyy HH:mm') 3 | -------------------------------------------------------------------------------- /Chapter08/5.2.1.13.Changing dates.ps1: -------------------------------------------------------------------------------- 1 | '{0:dddd} the {0:dd} day of {0:MMM}' -f (Get-Date) 2 | -------------------------------------------------------------------------------- /Chapter08/5.2.1.14.Changing dates.ps1: -------------------------------------------------------------------------------- 1 | (Get-Date).ToUniversalTime().ToString('u') 2 | -------------------------------------------------------------------------------- /Chapter08/5.2.1.15.Changing dates.ps1: -------------------------------------------------------------------------------- 1 | (Get-Date).ToUniversalTime().ToString('u').Replace(' ', 'T') 2 | -------------------------------------------------------------------------------- /Chapter08/5.2.1.2.Changing dates.ps1: -------------------------------------------------------------------------------- 1 | (Get-Date).Date 2 | -------------------------------------------------------------------------------- /Chapter08/5.2.1.3.Changing dates.ps1: -------------------------------------------------------------------------------- 1 | (Get-Date).AddDays(1) # One day from now 2 | (Get-Date).AddDays(-1) # One day before now 3 | -------------------------------------------------------------------------------- /Chapter08/5.2.1.4.Changing dates.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem -File | 2 | Where-Object LastWriteTime -gt (Get-Date).AddDays(-7) 3 | -------------------------------------------------------------------------------- /Chapter08/5.2.1.7.Changing dates.ps1: -------------------------------------------------------------------------------- 1 | (Get-Date).ToUniversalTime() 2 | -------------------------------------------------------------------------------- /Chapter08/5.2.1.9.Changing dates.ps1: -------------------------------------------------------------------------------- 1 | $UtcDate = [DateTime]::new((Get-Date).Ticks, 'Utc') 2 | -------------------------------------------------------------------------------- /Chapter08/5.3.1.3.DateTime parameters.ps1: -------------------------------------------------------------------------------- 1 | 10 November 2000 00:00:00 2 | -------------------------------------------------------------------------------- /Chapter08/5.3.1.4.DateTime parameters.ps1: -------------------------------------------------------------------------------- 1 | Test-DateTime -Date (Get-Date "11/10/2000") 2 | -------------------------------------------------------------------------------- /Chapter08/5.3.1.5.DateTime parameters.ps1: -------------------------------------------------------------------------------- 1 | Test-Path c:\temp\file.txt -NewerThan (Get-Date).AddDays(-7) 2 | -------------------------------------------------------------------------------- /Chapter08/5.4.1.1.Comparing dates.ps1: -------------------------------------------------------------------------------- 1 | $date1 = (Get-Date).AddDays(-20) 2 | $date2 = (Get-Date).AddDays(1) 3 | $date2 -gt $date1 4 | -------------------------------------------------------------------------------- /Chapter08/5.4.1.2.Comparing dates.ps1: -------------------------------------------------------------------------------- 1 | (Get-Date 13/01/2017) -gt '12/01/2017' 2 | 3 | # Expects output: 4 | # 5 | # False 6 | -------------------------------------------------------------------------------- /Chapter08/5.4.1.3.Comparing dates.ps1: -------------------------------------------------------------------------------- 1 | (Get-Date 13/01/2017) -gt '01/12/2017' 2 | 3 | # Expects output: 4 | # 5 | # True 6 | -------------------------------------------------------------------------------- /Chapter09/1.0.0.1.Regex basics.ps1: -------------------------------------------------------------------------------- 1 | 'cat' -match '.*' # Match anything, returns true 2 | 'cat' -match '\d' # Match digits, returns false 3 | -------------------------------------------------------------------------------- /Chapter09/1.1.1.1.Literal characters.ps1: -------------------------------------------------------------------------------- 1 | 'cat' -match 'cat' 2 | 3 | # Expects output: 4 | # 5 | # True 6 | -------------------------------------------------------------------------------- /Chapter09/1.1.1.2.Literal characters.ps1: -------------------------------------------------------------------------------- 1 | 'cat' -match 'dog' 2 | 3 | # Expects output: 4 | # 5 | # False 6 | -------------------------------------------------------------------------------- /Chapter09/1.1.1.3.Literal characters.ps1: -------------------------------------------------------------------------------- 1 | 'The cat chased the mouse' -match 'cat' 2 | 3 | # Expects output: 4 | # 5 | # True 6 | -------------------------------------------------------------------------------- /Chapter09/1.2.1.1.Any character (.).ps1: -------------------------------------------------------------------------------- 1 | 'abcdef' -match '......' 2 | 3 | # Expects output: 4 | # 5 | # True 6 | -------------------------------------------------------------------------------- /Chapter09/1.2.1.2.Any character (.).ps1: -------------------------------------------------------------------------------- 1 | 'abc' -match '......' 2 | 3 | # Expects output: 4 | # 5 | # False 6 | -------------------------------------------------------------------------------- /Chapter09/1.2.1.3.Any character (.).ps1: -------------------------------------------------------------------------------- 1 | 'abcdefghijkl' -match '......' 2 | 3 | # Expects output: 4 | # 5 | # True 6 | -------------------------------------------------------------------------------- /Chapter09/1.3.1.4.Repetition with and +.ps1: -------------------------------------------------------------------------------- 1 | 'bcd' -match 'a+' # Returns false 2 | -------------------------------------------------------------------------------- /Chapter09/1.4.1.1.The escape character ().ps1: -------------------------------------------------------------------------------- 1 | '1 * 3' -match '\*' 2 | 3 | # Expects output: 4 | # 5 | # True 6 | -------------------------------------------------------------------------------- /Chapter09/1.4.1.5.The escape character ().ps1: -------------------------------------------------------------------------------- 1 | 'domain\user' -match 'domain\.+' 2 | 3 | # Expects output: 4 | # 5 | # False 6 | -------------------------------------------------------------------------------- /Chapter09/1.4.1.6.The escape character ().ps1: -------------------------------------------------------------------------------- 1 | 'domain.com' -match 'domain\.+' 2 | 3 | # Expects output: 4 | # 5 | # True 6 | -------------------------------------------------------------------------------- /Chapter09/1.4.1.7.The escape character ().ps1: -------------------------------------------------------------------------------- 1 | 'domain.user' -match 'domain\.+' 2 | -------------------------------------------------------------------------------- /Chapter09/1.4.1.8.The escape character ().ps1: -------------------------------------------------------------------------------- 1 | 'Domain\User' -replace '.+\\' 2 | 3 | # Expects output: 4 | # 5 | # User 6 | -------------------------------------------------------------------------------- /Chapter09/1.4.1.9.The escape character ().ps1: -------------------------------------------------------------------------------- 1 | 'Domain\User' -replace '\\.+' 2 | 3 | # Expects output: 4 | # 5 | # Domain 6 | -------------------------------------------------------------------------------- /Chapter09/1.5.1.3.Regex is context sensitive.ps1: -------------------------------------------------------------------------------- 1 | 'string{123}' -match 'string{123}' 2 | 3 | # Expects output: 4 | # 5 | # False 6 | -------------------------------------------------------------------------------- /Chapter09/2.0.0.2.Anchors.ps1: -------------------------------------------------------------------------------- 1 | $env:PATH -split ';' -match '^C' 2 | -------------------------------------------------------------------------------- /Chapter09/4.1.1.2.Ranges.ps1: -------------------------------------------------------------------------------- 1 | '"#' -match '[!-9]+' 2 | $matches[0] 3 | 4 | # Expects output: 5 | # 6 | # True 7 | # 8 | # "# 9 | -------------------------------------------------------------------------------- /Chapter09/4.1.1.4.Ranges.ps1: -------------------------------------------------------------------------------- 1 | 'The registry value is 0xAF9B7' -cmatch '0x[0-9a-fA-F]+' 2 | 3 | # Expects output: 4 | # 5 | # True 6 | -------------------------------------------------------------------------------- /Chapter09/4.1.1.6.Ranges.ps1: -------------------------------------------------------------------------------- 1 | 'version 0.1.2.3234' -match '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' 2 | -------------------------------------------------------------------------------- /Chapter09/4.1.1.8.Ranges.ps1: -------------------------------------------------------------------------------- 1 | 'one-two,three,four' -split '[_,-]' 2 | -------------------------------------------------------------------------------- /Chapter09/4.1.1.9.Ranges.ps1: -------------------------------------------------------------------------------- 1 | 'one-two_three,four' -split '[_\-,]' 2 | -------------------------------------------------------------------------------- /Chapter09/4.3.1.2.Character class subtraction.ps1: -------------------------------------------------------------------------------- 1 | 'bcdfghjklmnpqrstvwxyz' -match '[aeiou]' 2 | 3 | # Expects output: 4 | # 5 | # False 6 | -------------------------------------------------------------------------------- /Chapter09/4.5.1.2.Unicode category class.ps1: -------------------------------------------------------------------------------- 1 | 'Get–Process' -replace '\p{Pd}', '-' 2 | 3 | # Expects output: 4 | # 5 | # Get-Process 6 | -------------------------------------------------------------------------------- /Chapter09/5.0.0.1.Alternation.ps1: -------------------------------------------------------------------------------- 1 | 'one', 'two', 'three' -match 'one|three' 2 | 3 | # Expects output: 4 | # 5 | # one 6 | # three 7 | -------------------------------------------------------------------------------- /Chapter09/5.0.0.3.Alternation.ps1: -------------------------------------------------------------------------------- 1 | 'one', 'one hundred', 'three', 'eighty three' -match '^one$|^three$' 2 | -------------------------------------------------------------------------------- /Chapter09/5.0.0.4.Alternation.ps1: -------------------------------------------------------------------------------- 1 | 'one', 'one hundred', 'three', 'eighty three' -match '^(one|three)$' 2 | -------------------------------------------------------------------------------- /Chapter09/6.1.1.1.Repeating groups.ps1: -------------------------------------------------------------------------------- 1 | $pattern = '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' 2 | -------------------------------------------------------------------------------- /Chapter09/6.1.1.2.Repeating groups.ps1: -------------------------------------------------------------------------------- 1 | $pattern = '([0-9]+\.){3}[0-9]+' 2 | -------------------------------------------------------------------------------- /Chapter09/8.0.0.1.The .NET Regex type.ps1: -------------------------------------------------------------------------------- 1 | $string = @' 2 | Name: Ruth 3 | Job title: Programmer 4 | Language: C# 5 | Level: Senior 6 | '@ 7 | -------------------------------------------------------------------------------- /Chapter09/8.1.1.4.Regex options.ps1: -------------------------------------------------------------------------------- 1 | 'Name (first or full): Bob' -cmatch '^(?i)[a-z]+.*(?-i)([A-Z].+)$' 2 | -------------------------------------------------------------------------------- /Chapter09/8.1.1.5.Regex options.ps1: -------------------------------------------------------------------------------- 1 | "First line`nSecond line" -match '(?sm)^\S+\sl.+$' 2 | -------------------------------------------------------------------------------- /Chapter09/8.1.1.6.Regex options.ps1: -------------------------------------------------------------------------------- 1 | "First line`nSecond line" -match '(?sm)^\S+\sl.+?$' 2 | -------------------------------------------------------------------------------- /Chapter09/8.1.1.8.Regex options.ps1: -------------------------------------------------------------------------------- 1 | $regex = '(?x)# This is a comment 2 | abc' 3 | 'abc' -match $regex 4 | -------------------------------------------------------------------------------- /Chapter09/9.1.1.1.MAC addresses.ps1: -------------------------------------------------------------------------------- 1 | $regex = '[0-9a-f]' 2 | -------------------------------------------------------------------------------- /Chapter09/9.1.1.2.MAC addresses.ps1: -------------------------------------------------------------------------------- 1 | $regex = '[0-9a-f]{2}' 2 | -------------------------------------------------------------------------------- /Chapter09/9.1.1.3.MAC addresses.ps1: -------------------------------------------------------------------------------- 1 | $regex = '[0-9a-f]{2}[-:]' 2 | -------------------------------------------------------------------------------- /Chapter09/9.1.1.4.MAC addresses.ps1: -------------------------------------------------------------------------------- 1 | $regex = '([0-9a-f]{2}[-:]){5}' 2 | -------------------------------------------------------------------------------- /Chapter09/9.1.1.5.MAC addresses.ps1: -------------------------------------------------------------------------------- 1 | $regex = '([0-9a-f]{2}[-:]){5}[0-9a-f]{2}' 2 | -------------------------------------------------------------------------------- /Chapter09/9.1.1.6.MAC addresses.ps1: -------------------------------------------------------------------------------- 1 | $regex = '([0-9a-f]{2}[-:]){5}[0-9a-f]{2}$' 2 | -------------------------------------------------------------------------------- /Chapter09/9.1.1.7.MAC addresses.ps1: -------------------------------------------------------------------------------- 1 | $regex = '\s([0-9a-f]{2}[-:]){5}[0-9a-f]{2}$' 2 | -------------------------------------------------------------------------------- /Chapter09/9.1.1.8.MAC addresses.ps1: -------------------------------------------------------------------------------- 1 | $regex = '(?<=\s)([0-9a-f]{2}[-:]){5}[0-9a-f]{2}$' 2 | -------------------------------------------------------------------------------- /Chapter09/9.2.1.1.IP addresses.ps1: -------------------------------------------------------------------------------- 1 | $regex = '([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])' 2 | -------------------------------------------------------------------------------- /Chapter09/9.3.1.2.The netstat command.ps1: -------------------------------------------------------------------------------- 1 | $regex = '^\s*\S+\s+\S+' 2 | -------------------------------------------------------------------------------- /Chapter09/9.3.1.5.The netstat command.ps1: -------------------------------------------------------------------------------- 1 | $regex = '(State>\S+)?' 2 | -------------------------------------------------------------------------------- /Chapter10/1.0.0.4.Working with providers.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_*_provider 2 | -------------------------------------------------------------------------------- /Chapter10/1.1.1.3.Navigating.ps1: -------------------------------------------------------------------------------- 1 | Push-Location c:\windows 2 | -------------------------------------------------------------------------------- /Chapter10/1.1.1.4.Navigating.ps1: -------------------------------------------------------------------------------- 1 | Pop-Location 2 | -------------------------------------------------------------------------------- /Chapter10/1.1.1.5.Navigating.ps1: -------------------------------------------------------------------------------- 1 | Set-Location c:\windows 2 | # Return to the previous location 3 | Set-Location -Path - 4 | -------------------------------------------------------------------------------- /Chapter10/1.1.1.6.Navigating.ps1: -------------------------------------------------------------------------------- 1 | Set-Location -Path + 2 | -------------------------------------------------------------------------------- /Chapter10/1.2.1.4.Getting items.ps1: -------------------------------------------------------------------------------- 1 | Get-ChildItem Registry::HKEY_USERS 2 | -------------------------------------------------------------------------------- /Chapter10/1.3.1.1.Drives.ps1: -------------------------------------------------------------------------------- 1 | New-PSDrive -Name X -PSProvider FileSystem -Root \\Server\Share 2 | -------------------------------------------------------------------------------- /Chapter10/2.1.1.1.Paths and .NET.ps1: -------------------------------------------------------------------------------- 1 | Set-Content file.txt -Value 'Some content' 2 | -------------------------------------------------------------------------------- /Chapter10/2.1.1.2.Paths and .NET.ps1: -------------------------------------------------------------------------------- 1 | [System.IO.File]::Exists('file.txt') 2 | -------------------------------------------------------------------------------- /Chapter10/2.1.1.3.Paths and .NET.ps1: -------------------------------------------------------------------------------- 1 | [Environment]::CurrentDirectory 2 | -------------------------------------------------------------------------------- /Chapter10/2.1.1.4.Paths and .NET.ps1: -------------------------------------------------------------------------------- 1 | [System.IO.File]::Exists("$pwd\file.txt") 2 | -------------------------------------------------------------------------------- /Chapter10/2.1.1.5.Paths and .NET.ps1: -------------------------------------------------------------------------------- 1 | $path = 'file.txt' 2 | $path = Convert-Path $path 3 | -------------------------------------------------------------------------------- /Chapter10/2.1.1.6.Paths and .NET.ps1: -------------------------------------------------------------------------------- 1 | $path = 'file.txt' 2 | $path = Resolve-Path $path 3 | -------------------------------------------------------------------------------- /Chapter10/2.1.1.8.Paths and .NET.ps1: -------------------------------------------------------------------------------- 1 | $path = 'file.txt' 2 | $path = $PSCmdlet.GetUnresolvedProviderPathFromPSPath($path) 3 | -------------------------------------------------------------------------------- /Chapter10/2.2.1.1.Testing for existing items.ps1: -------------------------------------------------------------------------------- 1 | Test-Path C:\Temp 2 | -------------------------------------------------------------------------------- /Chapter10/2.2.1.2.Testing for existing items.ps1: -------------------------------------------------------------------------------- 1 | Test-Path HKLM:\Software\Microsoft 2 | -------------------------------------------------------------------------------- /Chapter10/2.2.2.1.Testing FileSystem paths.ps1: -------------------------------------------------------------------------------- 1 | [System.IO.Path]::Exists('C:\Temp') 2 | -------------------------------------------------------------------------------- /Chapter10/2.2.2.2.Testing FileSystem paths.ps1: -------------------------------------------------------------------------------- 1 | Test-Path C:/Temp 2 | -------------------------------------------------------------------------------- /Chapter10/2.2.2.3.Testing FileSystem paths.ps1: -------------------------------------------------------------------------------- 1 | [System.IO.Path]::Exists('C:/Temp') 2 | -------------------------------------------------------------------------------- /Chapter10/2.2.2.4.Testing FileSystem paths.ps1: -------------------------------------------------------------------------------- 1 | Test-Path \tmp 2 | -------------------------------------------------------------------------------- /Chapter10/2.2.2.5.Testing FileSystem paths.ps1: -------------------------------------------------------------------------------- 1 | [System.IO.Path]::Exists('\tmp') 2 | -------------------------------------------------------------------------------- /Chapter10/2.2.2.6.Testing FileSystem paths.ps1: -------------------------------------------------------------------------------- 1 | [System.IO.Path]::DirectorySeparatorChar 2 | -------------------------------------------------------------------------------- /Chapter10/2.2.3.1.Testing Registry paths.ps1: -------------------------------------------------------------------------------- 1 | Test-Path HKLM:\Software\Microsoft 2 | -------------------------------------------------------------------------------- /Chapter10/2.2.3.5.Testing Registry paths.ps1: -------------------------------------------------------------------------------- 1 | (Get-Item HKLM:\Software).GetSubKeyNames() -contains 'Microsoft' 2 | -------------------------------------------------------------------------------- /Chapter10/2.2.4.2.Testing path type.ps1: -------------------------------------------------------------------------------- 1 | Test-Path C:\Windows\System32\cmd.exe -PathType Container 2 | -------------------------------------------------------------------------------- /Chapter10/2.3.1.4.Creating items.ps1: -------------------------------------------------------------------------------- 1 | New-Item $env:Temp\folder\newfile.txt -ItemType File -Force 2 | -------------------------------------------------------------------------------- /Chapter10/2.4.1.1.Reading and writing content.ps1: -------------------------------------------------------------------------------- 1 | Get-Content C:\windows\win.ini 2 | -------------------------------------------------------------------------------- /Chapter10/2.4.1.2.Reading and writing content.ps1: -------------------------------------------------------------------------------- 1 | Get-Content function:prompt 2 | -------------------------------------------------------------------------------- /Chapter10/2.4.2.1.Reading and writing in a pipeline.ps1: -------------------------------------------------------------------------------- 1 | Set-Content file.txt -Value first, second 2 | -------------------------------------------------------------------------------- /Chapter10/2.4.3.2.Reading all content.ps1: -------------------------------------------------------------------------------- 1 | [System.IO.File]::ReadAllLines("$pwd\file.txt") 2 | -------------------------------------------------------------------------------- /Chapter10/2.4.4.1.Writing content.ps1: -------------------------------------------------------------------------------- 1 | Set-Content function:Write-HelloWorld -Value { 2 | Write-Host "Hello World" 3 | } 4 | -------------------------------------------------------------------------------- /Chapter10/2.4.4.2.Writing content.ps1: -------------------------------------------------------------------------------- 1 | Set-Content env:HelloWorld -Value 'Hello world' 2 | -------------------------------------------------------------------------------- /Chapter10/2.4.4.3.Writing content.ps1: -------------------------------------------------------------------------------- 1 | [System.IO.File]::WriteAllLines('file.txt', ('first', 'second')) 2 | -------------------------------------------------------------------------------- /Chapter10/2.4.5.1.About text file encoding.ps1: -------------------------------------------------------------------------------- 1 | Set-Content file.txt 'Hello World ☺' 2 | -------------------------------------------------------------------------------- /Chapter10/2.4.5.2.About text file encoding.ps1: -------------------------------------------------------------------------------- 1 | Set-Content file.txt 'Hello World ☺' 2 | Get-Content file.txt 3 | -------------------------------------------------------------------------------- /Chapter10/2.4.5.4.About text file encoding.ps1: -------------------------------------------------------------------------------- 1 | Get-Content file.txt 2 | 3 | # Expects output: 4 | # 5 | # Hello World ☺ 6 | -------------------------------------------------------------------------------- /Chapter10/2.4.5.5.About text file encoding.ps1: -------------------------------------------------------------------------------- 1 | Get-Content file.txt -Encoding UTF8 2 | 3 | # Expects output: 4 | # 5 | # Hello World ☺ 6 | -------------------------------------------------------------------------------- /Chapter10/2.4.5.6.About text file encoding.ps1: -------------------------------------------------------------------------------- 1 | (Get-Content file.txt) | Set-Content file.txt -Encoding utf8BOM 2 | -------------------------------------------------------------------------------- /Chapter10/2.5.1.1.Temporary files.ps1: -------------------------------------------------------------------------------- 1 | $tempFile = New-TemporaryFile 2 | -------------------------------------------------------------------------------- /Chapter10/2.5.1.2.Temporary files.ps1: -------------------------------------------------------------------------------- 1 | $tempFile = [System.IO.Path]::GetTempFileName() 2 | -------------------------------------------------------------------------------- /Chapter10/2.6.1.1.Removing items.ps1: -------------------------------------------------------------------------------- 1 | $file = New-TemporaryFile 2 | Set-Content -Path $file -Value 'Temporary: 10' 3 | Remove-Item $file 4 | -------------------------------------------------------------------------------- /Chapter10/2.8.2.1.Properties and the File System.ps1: -------------------------------------------------------------------------------- 1 | Set-ItemProperty .\somefile.txt -Name IsReadOnly -Value $true 2 | -------------------------------------------------------------------------------- /Chapter10/2.8.2.2.Properties and the File System.ps1: -------------------------------------------------------------------------------- 1 | (Get-Item 'somefile.txt').IsReadOnly = $true 2 | -------------------------------------------------------------------------------- /Chapter10/2.8.3.1.Adding and removing file attributes.ps1: -------------------------------------------------------------------------------- 1 | [System.IO.FileAttributes].GetEnumValues() 2 | -------------------------------------------------------------------------------- /Chapter10/2.8.3.4.Adding and removing file attributes.ps1: -------------------------------------------------------------------------------- 1 | [System.IO.FileAttributes]'ReadOnly, Hidden' -eq 'Hidden, ReadOnly' 2 | -------------------------------------------------------------------------------- /Chapter10/2.8.3.5.Adding and removing file attributes.ps1: -------------------------------------------------------------------------------- 1 | (Get-Item 'somefile.txt').Attributes = 'ReadOnly, Hidden' 2 | -------------------------------------------------------------------------------- /Chapter10/2.8.3.9.Adding and removing file attributes.ps1: -------------------------------------------------------------------------------- 1 | $file.Attributes = 'ReadOnly' 2 | -------------------------------------------------------------------------------- /Chapter10/2.8.4.2.Registry values.ps1: -------------------------------------------------------------------------------- 1 | Set-ItemProperty -Path HKCU:\Environment -Name NewValue -Value 'New' 2 | -------------------------------------------------------------------------------- /Chapter10/2.8.4.3.Registry values.ps1: -------------------------------------------------------------------------------- 1 | Remove-ItemProperty -Path HKCU:\Environment -Name NewValue 2 | -------------------------------------------------------------------------------- /Chapter10/2.8.4.5.Registry values.ps1: -------------------------------------------------------------------------------- 1 | [Environment]::Is64BitProcess 2 | -------------------------------------------------------------------------------- /Chapter10/2.8.5.4.Registry values and Environment variables.ps1: -------------------------------------------------------------------------------- 1 | Remove-ItemProperty -Path $params['Path'] -Name $params['Name'] 2 | -------------------------------------------------------------------------------- /Chapter10/3.1.1.1.Access and audit.ps1: -------------------------------------------------------------------------------- 1 | Get-Acl C:\Temp\ACL\1 -Audit | Format-List 2 | -------------------------------------------------------------------------------- /Chapter10/3.2.1.6.Rule protection.ps1: -------------------------------------------------------------------------------- 1 | whoami /priv 2 | -------------------------------------------------------------------------------- /Chapter10/3.5.1.2.Copying lists and entries.ps1: -------------------------------------------------------------------------------- 1 | $acl = Get-Acl C:\Temp\ACL\4 2 | Set-Acl C:\Temp\ACL\5 -AclObject $acl 3 | -------------------------------------------------------------------------------- /Chapter10/3.6.2.1.FileSystem rights.ps1: -------------------------------------------------------------------------------- 1 | [System.Security.AccessControl.FileSystemRights].GetEnumValues() 2 | -------------------------------------------------------------------------------- /Chapter10/4.0.0.3.Transactions.ps1: -------------------------------------------------------------------------------- 1 | Undo-Transaction 2 | -------------------------------------------------------------------------------- /Chapter10/4.0.0.4.Transactions.ps1: -------------------------------------------------------------------------------- 1 | Complete-Transaction 2 | -------------------------------------------------------------------------------- /Chapter10/4.0.0.5.Transactions.ps1: -------------------------------------------------------------------------------- 1 | Get-Command -ParameterName UseTransaction 2 | -------------------------------------------------------------------------------- /Chapter10/5.3.1.7.Test-FileCatalog.ps1: -------------------------------------------------------------------------------- 1 | $result.PathItems.Keys | Where-Object { 2 | -not $result.CatalogItems.ContainsKey($_) 3 | } 4 | -------------------------------------------------------------------------------- /Chapter10/5.3.1.9.Test-FileCatalog.ps1: -------------------------------------------------------------------------------- 1 | $result.CatalogItems.Keys | Where-Object { 2 | -not $result.PathItems.ContainsKey($_) 3 | } 4 | -------------------------------------------------------------------------------- /Chapter11/1.3.2.3.Getting instances.ps1: -------------------------------------------------------------------------------- 1 | Get-CimInstance Win32_UserAccount -Property Name, SID 2 | -------------------------------------------------------------------------------- /Chapter11/1.3.5.2.Creating instances.ps1: -------------------------------------------------------------------------------- 1 | $class = Get-CimClass Win32_ProcessStartup 2 | $startupInfo = New-Object CimInstance $class 3 | -------------------------------------------------------------------------------- /Chapter11/1.3.5.3.Creating instances.ps1: -------------------------------------------------------------------------------- 1 | $class = Get-CimClass Win32_ProcessStartup 2 | $startupInfo = [CimInstance]::new($class) 3 | -------------------------------------------------------------------------------- /Chapter11/1.3.6.2.Removing instances.ps1: -------------------------------------------------------------------------------- 1 | $process | Remove-CimInstance 2 | -------------------------------------------------------------------------------- /Chapter11/2.2.1.2.Escape sequences and wildcards.ps1: -------------------------------------------------------------------------------- 1 | Get-CimInstance Win32_Service -Filter 'PathName LIKE "_:\\%.exe"' 2 | -------------------------------------------------------------------------------- /Chapter11/2.3.1.1.Comparison operators.ps1: -------------------------------------------------------------------------------- 1 | Get-CimInstance Win32_Process -Filter "Name='pwsh.exe'" 2 | -------------------------------------------------------------------------------- /Chapter11/2.3.2.1.WQL filters and Dates.ps1: -------------------------------------------------------------------------------- 1 | $date = (Get-Date).AddDays(-90).ToString('yyyyMMddHHmmss.fK') 2 | -------------------------------------------------------------------------------- /Chapter11/2.5.1.1.Quoting values.ps1: -------------------------------------------------------------------------------- 1 | Get-CimInstance Win32_Process -Filter 'Name="pwsh.exe"' 2 | -------------------------------------------------------------------------------- /Chapter11/2.5.1.2.Quoting values.ps1: -------------------------------------------------------------------------------- 1 | Get-CimInstance Win32_Process -Filter "Name='pwsh.exe'" 2 | -------------------------------------------------------------------------------- /Chapter11/2.6.2.1.WMI object paths.ps1: -------------------------------------------------------------------------------- 1 | (Get-CimClass Win32_Process).CimClassProperties | 2 | Where-Object { $_.Flags -band 'Key' } 3 | -------------------------------------------------------------------------------- /Chapter11/2.6.3.1.Using ASSOCIATORS OF.ps1: -------------------------------------------------------------------------------- 1 | Get-CimInstance -Query "ASSOCIATORS OF {Win32_Process.Handle=$PID}" 2 | -------------------------------------------------------------------------------- /Chapter11/3.1.1.1.Getting instances.ps1: -------------------------------------------------------------------------------- 1 | ([wmisearcher]"SELECT * FROM Win32_Process").Get() 2 | -------------------------------------------------------------------------------- /Chapter11/3.5.1.1.Creating instances.ps1: -------------------------------------------------------------------------------- 1 | ([WmiClass]'Win32_Trustee').CreateInstance() 2 | -------------------------------------------------------------------------------- /Chapter11/4.1.3.6.Getting a security descriptor.ps1: -------------------------------------------------------------------------------- 1 | [System.Security.AccessControl.AceFlags]0 2 | 3 | # Expects output: 4 | # 5 | # None 6 | -------------------------------------------------------------------------------- /Chapter11/4.1.4.3.Adding an access control entry.ps1: -------------------------------------------------------------------------------- 1 | $aclObject.DACL += $ace 2 | -------------------------------------------------------------------------------- /Chapter11/4.3.1.2.WMI and SDDL.ps1: -------------------------------------------------------------------------------- 1 | $acl = Get-Acl C:\ 2 | $acl.SetSecurityDescriptorSddlForm($sddlString) 3 | -------------------------------------------------------------------------------- /Chapter12/1.0.0.1.ConvertTo-Html.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | ConvertTo-Html -Property Name, Id, WorkingSet 2 | -------------------------------------------------------------------------------- /Chapter12/1.5.1.1.Modifying HTML content.ps1: -------------------------------------------------------------------------------- 1 | [PSCustomObject]@{ 2 | Name = 'Name' 3 | Values = 'First', 'Second' 4 | } 5 | -------------------------------------------------------------------------------- /Chapter12/1.5.1.3.Modifying HTML content.ps1: -------------------------------------------------------------------------------- 1 | @{ 2 | Name = 'Values'; Expression = { $_.Values -join "`n" } 3 | } 4 | -------------------------------------------------------------------------------- /Chapter12/2.6.1.1.ConvertTo-Xml.ps1: -------------------------------------------------------------------------------- 1 | Get-Process -Id $pid | ConvertTo-Xml 2 | -------------------------------------------------------------------------------- /Chapter12/3.11.1.2.Infer a schema.ps1: -------------------------------------------------------------------------------- 1 | $reader = [System.Xml.XmlNodeReader]$xml 2 | -------------------------------------------------------------------------------- /Chapter12/3.3.1.2.SelectNodes and XPathNodeList.ps1: -------------------------------------------------------------------------------- 1 | if ($nodes.Count -ge 1) { 2 | Write-Host "A blue car record exists" 3 | } 4 | -------------------------------------------------------------------------------- /Chapter12/3.4.1.2.Working with namespaces.ps1: -------------------------------------------------------------------------------- 1 | $xml.SelectNodes('//engine') 2 | -------------------------------------------------------------------------------- /Chapter12/3.4.1.3.Working with namespaces.ps1: -------------------------------------------------------------------------------- 1 | Select-Xml -Xml $xml -XPath '//engine' 2 | -------------------------------------------------------------------------------- /Chapter12/3.4.1.4.Working with namespaces.ps1: -------------------------------------------------------------------------------- 1 | $namespaceManager = [System.Xml.XmlNamespaceManager]::new( 2 | $xml.NameTable 3 | ) 4 | -------------------------------------------------------------------------------- /Chapter12/3.4.1.5.Working with namespaces.ps1: -------------------------------------------------------------------------------- 1 | $namespaceManager.AddNamespace('any', 'http://example/cars') 2 | -------------------------------------------------------------------------------- /Chapter12/3.4.1.6.Working with namespaces.ps1: -------------------------------------------------------------------------------- 1 | $namespaceManager 2 | 3 | # Expects output: 4 | # 5 | # xmlns 6 | # xml 7 | # any 8 | -------------------------------------------------------------------------------- /Chapter12/3.6.1.3.Modifying element and attribute values.ps1: -------------------------------------------------------------------------------- 1 | $xml.list.SelectSingleNode('./name[.="one"]').'#text' = 'three' 2 | -------------------------------------------------------------------------------- /Chapter12/3.8.1.2.Removing elements and attributes.ps1: -------------------------------------------------------------------------------- 1 | $xml.list.RemoveAttribute('type') 2 | -------------------------------------------------------------------------------- /Chapter12/4.0.0.1.System.Xml.Linq.ps1: -------------------------------------------------------------------------------- 1 | Add-Type -AssemblyName System.Xml.Linq 2 | -------------------------------------------------------------------------------- /Chapter12/4.3.1.3.Creating documents.ps1: -------------------------------------------------------------------------------- 1 | $xDocument.Save("$pwd\test.xml") 2 | -------------------------------------------------------------------------------- /Chapter12/4.4.1.2.Working with namespaces.ps1: -------------------------------------------------------------------------------- 1 | [XNamespace]'http://example/cars' + 'engine' 2 | -------------------------------------------------------------------------------- /Chapter12/5.0.0.1.JSON.ps1: -------------------------------------------------------------------------------- 1 | { 2 | "key1": "value1", 3 | "key2": "value2" 4 | } 5 | -------------------------------------------------------------------------------- /Chapter12/5.1.3.1.AsArray.ps1: -------------------------------------------------------------------------------- 1 | @(Get-Process -ID $PID | Select-Object Name, ID) | ConvertTo-Json 2 | -------------------------------------------------------------------------------- /Chapter12/5.1.3.2.AsArray.ps1: -------------------------------------------------------------------------------- 1 | ConvertTo-Json -InputObject @( 2 | Get-Process -ID $PID | Select-Object Name, ID 3 | ) 4 | -------------------------------------------------------------------------------- /Chapter12/5.1.3.3.AsArray.ps1: -------------------------------------------------------------------------------- 1 | Get-Process -ID $PID | 2 | Select-Object Name, ID | 3 | ConvertTo-Json -AsArray 4 | -------------------------------------------------------------------------------- /Chapter12/5.2.1.7.ConvertFrom-Json.ps1: -------------------------------------------------------------------------------- 1 | Get-TypeData System.DateTime | Remove-TypeData 2 | -------------------------------------------------------------------------------- /Chapter12/5.2.3.1.NoEnumerate.ps1: -------------------------------------------------------------------------------- 1 | $content = @" 2 | [ 3 | { "Element": 1 } 4 | ] 5 | "@ | ConvertFrom-Json 6 | -------------------------------------------------------------------------------- /Chapter12/5.2.3.3.NoEnumerate.ps1: -------------------------------------------------------------------------------- 1 | $content = @" 2 | [ 3 | { "Element": { "Value": 1 } } 4 | ] 5 | "@ | ConvertFrom-Json -NoEnumerate 6 | -------------------------------------------------------------------------------- /Chapter12/5.3.1.2.Test-Json.ps1: -------------------------------------------------------------------------------- 1 | Test-Json -Json '{ "name": "first" }' -SchemaFile item.json 2 | 3 | # Expects output: 4 | # 5 | # True 6 | -------------------------------------------------------------------------------- /Chapter12/5.3.1.4.Test-Json.ps1: -------------------------------------------------------------------------------- 1 | Test-Json -Json $json -SchemaFile item.json -ErrorAction Ignore 2 | -------------------------------------------------------------------------------- /Chapter13/2.3.1.1.About parsing web pages.ps1: -------------------------------------------------------------------------------- 1 | Invoke-WebRequest https://devblogs.microsoft.com/powershell-community/ -UseBasicParsing 2 | -------------------------------------------------------------------------------- /Chapter13/2.6.4.1.Windows PowerShell and certificate validation.ps1: -------------------------------------------------------------------------------- 1 | $default = [System.Net.ServicePointManager]::CertificatePolicy 2 | -------------------------------------------------------------------------------- /Chapter13/2.6.4.4.Windows PowerShell and certificate validation.ps1: -------------------------------------------------------------------------------- 1 | [System.Net.ServicePointManager]::CertificatePolicy = $default 2 | -------------------------------------------------------------------------------- /Chapter13/2.6.5.3.Capturing SSL errors.ps1: -------------------------------------------------------------------------------- 1 | $certValidation.Chain.ChainElements | ForEach-Object Certificate 2 | -------------------------------------------------------------------------------- /Chapter13/2.6.5.4.Capturing SSL errors.ps1: -------------------------------------------------------------------------------- 1 | $certValidation.Chain.ChainStatus 2 | -------------------------------------------------------------------------------- /Chapter13/3.0.0.1.Working with REST.ps1: -------------------------------------------------------------------------------- 1 | Invoke-RestMethod -Uri wttr.in 2 | -------------------------------------------------------------------------------- /Chapter13/3.1.1.1.Simple requests.ps1: -------------------------------------------------------------------------------- 1 | Invoke-RestMethod -Uri https://api.github.com/users/powershell/repos 2 | -------------------------------------------------------------------------------- /Chapter13/3.3.1.1.Requests with arguments.ps1: -------------------------------------------------------------------------------- 1 | Get-Content language:powershell repo:powershell/powershell 2 | -------------------------------------------------------------------------------- /Chapter13/3.5.2.1.Creating an application.ps1: -------------------------------------------------------------------------------- 1 | $clientId = 'FromGitHub' 2 | $clientSecret = 'FromGitHub' 3 | -------------------------------------------------------------------------------- /Chapter13/3.5.6.1.Using a token.ps1: -------------------------------------------------------------------------------- 1 | $headers = @{ 2 | Authorization = 'token {0}' -f $token 3 | } 4 | -------------------------------------------------------------------------------- /Chapter13/4.2.4.4.Methods and enumerations.ps1: -------------------------------------------------------------------------------- 1 | $service.GetElementsByGroup([SOAP.Group]::Nonmetal) | Format-Table 2 | -------------------------------------------------------------------------------- /Chapter13/4.2.5.2.Methods and SOAP objects.ps1: -------------------------------------------------------------------------------- 1 | $searchCondition = [SOAP.SearchCondition]::new() 2 | -------------------------------------------------------------------------------- /Chapter13/4.2.6.4.Overlapping services.ps1: -------------------------------------------------------------------------------- 1 | ('{0}.SearchCondition' -f $service.GetType().Namespace -as [Type])::new() 2 | -------------------------------------------------------------------------------- /Chapter13/SimpleSOAP/SimpleSOAP/Service.asmx: -------------------------------------------------------------------------------- 1 | <%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" Class="Service" %> 2 | -------------------------------------------------------------------------------- /Chapter14/2.0.0.1.Executing remote commands.ps1: -------------------------------------------------------------------------------- 1 | Enable-PSRemoting 2 | -------------------------------------------------------------------------------- /Chapter14/2.1.1.1.Enter-PSSession.ps1: -------------------------------------------------------------------------------- 1 | Enter-PSSession PSTest 2 | -------------------------------------------------------------------------------- /Chapter14/2.1.1.2.Enter-PSSession.ps1: -------------------------------------------------------------------------------- 1 | Enter-PSSession localhost 2 | -------------------------------------------------------------------------------- /Chapter14/2.1.1.4.Enter-PSSession.ps1: -------------------------------------------------------------------------------- 1 | Enter-PSSession localhost -ConfigurationName PowerShell.7 2 | -------------------------------------------------------------------------------- /Chapter14/2.1.1.5.Enter-PSSession.ps1: -------------------------------------------------------------------------------- 1 | $PSSessionConfigurationName = 'PowerShell.7' 2 | Enter-PSSession localhost -EnableNetworkAccess 3 | -------------------------------------------------------------------------------- /Chapter14/2.2.1.1.Invoke-Command.ps1: -------------------------------------------------------------------------------- 1 | Invoke-Command -ComputerName localhost -ScriptBlock { 2 | Get-Process 3 | } 4 | -------------------------------------------------------------------------------- /Chapter14/2.2.2.4.Parallel execution.ps1: -------------------------------------------------------------------------------- 1 | Invoke-Command { Get-Process -ID $PID } 2 | -------------------------------------------------------------------------------- /Chapter14/2.2.4.2.Local functions and remote sessions.ps1: -------------------------------------------------------------------------------- 1 | Invoke-Command ${function:Get-NetInformation} -ComputerName localhost 2 | -------------------------------------------------------------------------------- /Chapter14/2.2.5.2.Using ArgumentList.ps1: -------------------------------------------------------------------------------- 1 | $params['ArgumentList'] = @('C', 'D'), 'GB' 2 | -------------------------------------------------------------------------------- /Chapter14/2.2.6.1.The using scope modifier.ps1: -------------------------------------------------------------------------------- 1 | $hello = 'Hello world' 2 | Invoke-Command { $using:hello } -ComputerName localhost 3 | -------------------------------------------------------------------------------- /Chapter14/3.1.1.3.New-PSSession and Get-PSSession.ps1: -------------------------------------------------------------------------------- 1 | $session = New-PSSession -ComputerName PSTest -Name Example 2 | -------------------------------------------------------------------------------- /Chapter14/3.2.1.2.Disconnected sessions.ps1: -------------------------------------------------------------------------------- 1 | Get-PSSession -ComputerName PSTest | 2 | Connect-PSSession | 3 | Receive-PSSession 4 | -------------------------------------------------------------------------------- /Chapter14/3.2.1.3.Disconnected sessions.ps1: -------------------------------------------------------------------------------- 1 | $session = Get-PSSession -ComputerName PSTest -Name 'Example' 2 | Connect-PSSession $session 3 | -------------------------------------------------------------------------------- /Chapter14/3.4.1.2.Export-PSSession.ps1: -------------------------------------------------------------------------------- 1 | Import-Module "NetAdapter-$computerName" 2 | -------------------------------------------------------------------------------- /Chapter14/4.2.1.1.The WSMan drive.ps1: -------------------------------------------------------------------------------- 1 | Set-Item WSMan:\localhost\MaxEnvelopeSizekb 8KB 2 | -------------------------------------------------------------------------------- /Chapter14/4.2.1.2.The WSMan drive.ps1: -------------------------------------------------------------------------------- 1 | Restart-Service winrm 2 | -------------------------------------------------------------------------------- /Chapter14/4.3.1.7.Remoting and SSL.ps1: -------------------------------------------------------------------------------- 1 | Test-WSMan -UseSSL 2 | -------------------------------------------------------------------------------- /Chapter14/5.0.0.1.Remoting on Linux.ps1: -------------------------------------------------------------------------------- 1 | Get-Content /etc/shells # Use cat or less in Bash 2 | -------------------------------------------------------------------------------- /Chapter14/5.0.0.2.Remoting on Linux.ps1: -------------------------------------------------------------------------------- 1 | chsh -s /usr/bin/pwsh 2 | -------------------------------------------------------------------------------- /Chapter14/5.0.0.3.Remoting on Linux.ps1: -------------------------------------------------------------------------------- 1 | yum install omi.x86_64 omi-psrp-server.x86_64 2 | -------------------------------------------------------------------------------- /Chapter14/5.0.0.4.Remoting on Linux.ps1: -------------------------------------------------------------------------------- 1 | firewall-cmd --zone=home --change-interface=eth0 2 | firewall-cmd --zone=home --add-port=5986/tcp 3 | -------------------------------------------------------------------------------- /Chapter14/5.2.1.1.Connecting from Windows to Linux.ps1: -------------------------------------------------------------------------------- 1 | Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 2 | -------------------------------------------------------------------------------- /Chapter14/5.2.1.2.Connecting from Windows to Linux.ps1: -------------------------------------------------------------------------------- 1 | choco install openssh 2 | -------------------------------------------------------------------------------- /Chapter14/5.2.1.3.Connecting from Windows to Linux.ps1: -------------------------------------------------------------------------------- 1 | service sshd restart 2 | -------------------------------------------------------------------------------- /Chapter14/5.2.1.4.Connecting from Windows to Linux.ps1: -------------------------------------------------------------------------------- 1 | Get-Content ~\.ssh\id_rsa.pub | Set-Clipboard 2 | -------------------------------------------------------------------------------- /Chapter14/5.3.1.2.Connecting from Linux to Windows.ps1: -------------------------------------------------------------------------------- 1 | Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 2 | -------------------------------------------------------------------------------- /Chapter14/5.3.1.3.Connecting from Linux to Windows.ps1: -------------------------------------------------------------------------------- 1 | & "C:\Program Files\OpenSSH-Win64\install-sshd.ps1" 2 | -------------------------------------------------------------------------------- /Chapter14/5.3.1.5.Connecting from Linux to Windows.ps1: -------------------------------------------------------------------------------- 1 | ssh user@WindowsSystemNameOrIPAddress 2 | -------------------------------------------------------------------------------- /Chapter14/5.3.1.7.Connecting from Linux to Windows.ps1: -------------------------------------------------------------------------------- 1 | Restart-Service sshd 2 | -------------------------------------------------------------------------------- /Chapter14/5.3.1.9.Connecting from Linux to Windows.ps1: -------------------------------------------------------------------------------- 1 | Get-Content ~/.ssh/id_rsa.pub 2 | -------------------------------------------------------------------------------- /Chapter14/6.1.1.2.CredSSP.ps1: -------------------------------------------------------------------------------- 1 | Enable-WSManCredSSP -Role Client -DelegateComputer PSTest 2 | -------------------------------------------------------------------------------- /Chapter14/6.1.1.3.CredSSP.ps1: -------------------------------------------------------------------------------- 1 | Enable-WSManCredSSP -Role Server 2 | -------------------------------------------------------------------------------- /Chapter14/6.1.1.4.CredSSP.ps1: -------------------------------------------------------------------------------- 1 | Disable-WSManCredSSP -Role Client 2 | -------------------------------------------------------------------------------- /Chapter14/6.1.1.5.CredSSP.ps1: -------------------------------------------------------------------------------- 1 | Disable-WSManCredSSP -Role Server 2 | -------------------------------------------------------------------------------- /Chapter14/7.0.0.1.CIM sessions.ps1: -------------------------------------------------------------------------------- 1 | Get-Command -ParameterName CimSession 2 | -------------------------------------------------------------------------------- /Chapter14/7.0.0.2.CIM sessions.ps1: -------------------------------------------------------------------------------- 1 | New-CimSession 2 | -------------------------------------------------------------------------------- /Chapter14/8.1.1.3.Session configuration.ps1: -------------------------------------------------------------------------------- 1 | Enter-PSSession -ComputerName localhost -ConfigurationName JEATest 2 | -------------------------------------------------------------------------------- /Chapter14/8.1.1.4.Session configuration.ps1: -------------------------------------------------------------------------------- 1 | Unregister-PSSessionConfiguration -Name 'JEATest' 2 | -------------------------------------------------------------------------------- /Chapter15/1.1.1.3.Start-Job, Get-Job, and Remove-Job.ps1: -------------------------------------------------------------------------------- 1 | Get-Job | Remove-Job 2 | -------------------------------------------------------------------------------- /Chapter15/1.1.1.4.Start-Job, Get-Job, and Remove-Job.ps1: -------------------------------------------------------------------------------- 1 | Get-Job -State Completed | Remove-Job 2 | -------------------------------------------------------------------------------- /Chapter15/1.5.1.1.The background operator.ps1: -------------------------------------------------------------------------------- 1 | Get-Process & 2 | -------------------------------------------------------------------------------- /Chapter15/1.5.1.2.The background operator.ps1: -------------------------------------------------------------------------------- 1 | Start-Job -ScriptBlock { Get-Process } 2 | -------------------------------------------------------------------------------- /Chapter15/1.6.1.1.The ThreadJob module.ps1: -------------------------------------------------------------------------------- 1 | Start-ThreadJob { Write-Host 'Hello world' } | Receive-Job -Wait 2 | -------------------------------------------------------------------------------- /Chapter15/2.3.1.2.Get-EventSubscriber and Unregister-Event.ps1: -------------------------------------------------------------------------------- 1 | Get-EventSubscriber | Unregister-Event 2 | -------------------------------------------------------------------------------- /Chapter15/3.1.1.1.Creating a PowerShell instance.ps1: -------------------------------------------------------------------------------- 1 | $psInstance = [PowerShell]::Create() 2 | -------------------------------------------------------------------------------- /Chapter15/3.1.1.4.Creating a PowerShell instance.ps1: -------------------------------------------------------------------------------- 1 | Get-Process -Name powershell 2 | Get-Service | Select-Object -First 1 3 | -------------------------------------------------------------------------------- /Chapter15/3.2.1.6.The Invoke and BeginInvoke methods.ps1: -------------------------------------------------------------------------------- 1 | Get-Content c:\temp\output.txt -Wait 2 | -------------------------------------------------------------------------------- /Chapter15/3.3.1.2.About Streams and InvocationStateInfo.ps1: -------------------------------------------------------------------------------- 1 | $instance.Streams.Verbose 2 | 3 | # Expects output: 4 | # 5 | # Start 6 | -------------------------------------------------------------------------------- /Chapter15/3.3.1.6.About Streams and InvocationStateInfo.ps1: -------------------------------------------------------------------------------- 1 | $instance.HadErrors 2 | 3 | # Expects output: 4 | # 5 | # True 6 | -------------------------------------------------------------------------------- /Chapter15/3.3.1.8.About Streams and InvocationStateInfo.ps1: -------------------------------------------------------------------------------- 1 | $instance.InvocationStateInfo.Reason 2 | -------------------------------------------------------------------------------- /Chapter15/3.4.1.3.Running multiple instances.ps1: -------------------------------------------------------------------------------- 1 | while ($jobs.State -contains 'Running') { 2 | Start-Sleep -Milliseconds 100 3 | } 4 | -------------------------------------------------------------------------------- /Chapter15/3.5.1.1.Using the RunspacePool object.ps1: -------------------------------------------------------------------------------- 1 | [RunspaceFactory]::CreateRunspacePool(1, 5) 2 | -------------------------------------------------------------------------------- /Chapter15/3.5.1.4.Using the RunspacePool object.ps1: -------------------------------------------------------------------------------- 1 | $jobs.Instance | ForEach-Object Dispose 2 | $runspacePool.Dispose() 3 | -------------------------------------------------------------------------------- /Chapter15/3.5.1.5.Using the RunspacePool object.ps1: -------------------------------------------------------------------------------- 1 | [GC]::Collect() 2 | -------------------------------------------------------------------------------- /Chapter15/3.6.1.1.About the InitialSessionState object.ps1: -------------------------------------------------------------------------------- 1 | $initialSessionState = [InitialSessionState]::CreateDefault2() 2 | -------------------------------------------------------------------------------- /Chapter15/3.7.1.2.Using the InitialSessionState and RunspacePool objects.ps1: -------------------------------------------------------------------------------- 1 | $runspacePool.SetMaxRunspaces(5) 2 | -------------------------------------------------------------------------------- /Chapter15/4.0.0.1.Using thread-safe objects.ps1: -------------------------------------------------------------------------------- 1 | $synchronizedHashtable = [Hashtable]::Synchronized(@{ 2 | Key = 'Value' 3 | }) 4 | -------------------------------------------------------------------------------- /Chapter15/5.0.0.11.Managing concurrent access.ps1: -------------------------------------------------------------------------------- 1 | # In both consoles 2 | $mutex = [System.Threading.Mutex]::new($true, 'PSMutex') 3 | -------------------------------------------------------------------------------- /Chapter15/5.0.0.12.Managing concurrent access.ps1: -------------------------------------------------------------------------------- 1 | # Inn the first console 2 | $mutex.WaitOne() 3 | -------------------------------------------------------------------------------- /Chapter15/5.0.0.13.Managing concurrent access.ps1: -------------------------------------------------------------------------------- 1 | # In the first console 2 | $mutex.ReleaseMutex() 3 | -------------------------------------------------------------------------------- /Chapter15/5.0.0.14.Managing concurrent access.ps1: -------------------------------------------------------------------------------- 1 | # In the second console 2 | $mutex.ReleaseMutex() 3 | -------------------------------------------------------------------------------- /Chapter15/5.0.0.15.Managing concurrent access.ps1: -------------------------------------------------------------------------------- 1 | # In both consoles 2 | $mutex.Dispose() 3 | -------------------------------------------------------------------------------- /Chapter15/5.0.0.2.Managing concurrent access.ps1: -------------------------------------------------------------------------------- 1 | Remove-Item runspace.log 2 | -------------------------------------------------------------------------------- /Chapter15/5.0.0.6.Managing concurrent access.ps1: -------------------------------------------------------------------------------- 1 | $mutex = [System.Threading.Mutex]::new() 2 | -------------------------------------------------------------------------------- /Chapter15/5.0.0.8.Managing concurrent access.ps1: -------------------------------------------------------------------------------- 1 | $mutex.Dispose() 2 | -------------------------------------------------------------------------------- /Chapter16/1.0.0.1.About Windows Presentation Foundation (WPF).ps1: -------------------------------------------------------------------------------- 1 | Add-Type -AssemblyName PresentationFramework 2 | -------------------------------------------------------------------------------- /Chapter16/4.0.0.1.Displaying the UI.ps1: -------------------------------------------------------------------------------- 1 | $Window.ShowDialog() 2 | -------------------------------------------------------------------------------- /Chapter16/6.0.0.2.Naming and locating controls.ps1: -------------------------------------------------------------------------------- 1 | $button3 = $window.Content.Children[2].Content 2 | -------------------------------------------------------------------------------- /Chapter16/7.0.0.4.Handling events.ps1: -------------------------------------------------------------------------------- 1 | $ui.MainWindow.ShowDialog() 2 | -------------------------------------------------------------------------------- /Chapter16/7.4.1.1.Sorting a ListView.ps1: -------------------------------------------------------------------------------- 1 | [char]0x25bc 2 | [char]0x25b2 3 | 4 | # Expects output: 5 | # 6 | # ▼ 7 | # ▲ 8 | -------------------------------------------------------------------------------- /Chapter16/8.2.1.1.Errors in the background.ps1: -------------------------------------------------------------------------------- 1 | $ui.PSHost.Streams.Error 2 | -------------------------------------------------------------------------------- /Chapter16/8.2.1.2.Errors in the background.ps1: -------------------------------------------------------------------------------- 1 | $ui.PSHost.InvocationStateInfo.Reason 2 | -------------------------------------------------------------------------------- /Chapter16/8.3.1.4.Using the Dispatcher.ps1: -------------------------------------------------------------------------------- 1 | $ui.Controls['Button'].Enabled = $false 2 | -------------------------------------------------------------------------------- /Chapter16/8.3.1.5.Using the Dispatcher.ps1: -------------------------------------------------------------------------------- 1 | $ui.Dispatcher.Invoke({ 2 | $ui.Controls['Button'].Enabled = $false 3 | }) 4 | -------------------------------------------------------------------------------- /Chapter16/8.4.1.1.ScriptBlock runspace affinity.ps1: -------------------------------------------------------------------------------- 1 | $scriptBlock = { 'Hello world' } 2 | $scriptBlock.Ast.GetScriptBlock() 3 | -------------------------------------------------------------------------------- /Chapter17/2.1.1.1.Scripts and using statements.ps1: -------------------------------------------------------------------------------- 1 | using namespace System.Xml.Linq 2 | -------------------------------------------------------------------------------- /Chapter17/2.2.1.2.Scripts and Requires statement.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_Requires 2 | -------------------------------------------------------------------------------- /Chapter17/3.0.0.1.Parameters and the param block.ps1: -------------------------------------------------------------------------------- 1 | param ( 2 | $Parameter1, 3 | $Parameter2 4 | ) 5 | -------------------------------------------------------------------------------- /Chapter17/3.0.0.3.Parameters and the param block.ps1: -------------------------------------------------------------------------------- 1 | function New-Function($Parameter1, $Parameter2) { 2 | # Function body 3 | } 4 | -------------------------------------------------------------------------------- /Chapter17/3.1.1.1.Parameter types.ps1: -------------------------------------------------------------------------------- 1 | param ( 2 | [string] 3 | $Parameter1 4 | ) 5 | -------------------------------------------------------------------------------- /Chapter17/4.0.0.1.The CmdletBinding attribute.ps1: -------------------------------------------------------------------------------- 1 | function Test-EmptyParam { 2 | [CmdletBinding()] 3 | param ( ) 4 | } 5 | -------------------------------------------------------------------------------- /Chapter17/4.1.1.1.Common parameters.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_CommonParameters 2 | -------------------------------------------------------------------------------- /Chapter17/4.1.1.2.Common parameters.ps1: -------------------------------------------------------------------------------- 1 | [System.Management.Automation.PSCmdlet]::CommonParameters 2 | -------------------------------------------------------------------------------- /Chapter17/4.1.1.4.Common parameters.ps1: -------------------------------------------------------------------------------- 1 | Show-Verbose -Verbose 2 | 3 | # Expects output: 4 | # 5 | # VERBOSE: Verbose message 6 | -------------------------------------------------------------------------------- /Chapter17/5.0.0.2.The Alias attribute.ps1: -------------------------------------------------------------------------------- 1 | gsm 2 | 3 | # Expects output: 4 | # 5 | # Running Get-Something 6 | -------------------------------------------------------------------------------- /Chapter17/6.1.1.1.begin.ps1: -------------------------------------------------------------------------------- 1 | function Show-Pipeline { 2 | begin { 3 | Write-Host 'Pipeline start' 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /Chapter17/6.5.1.3.Named blocks and return.ps1: -------------------------------------------------------------------------------- 1 | function Test-Return { return 1 } 2 | function Test-Return { 1; return } 3 | -------------------------------------------------------------------------------- /Chapter17/7.4.1.2.Casting to Void.ps1: -------------------------------------------------------------------------------- 1 | [void](Get-Command Get-Command) 2 | -------------------------------------------------------------------------------- /Chapter17/7.4.1.3.Casting to Void.ps1: -------------------------------------------------------------------------------- 1 | [GC]::Collect() 2 | -------------------------------------------------------------------------------- /Chapter17/8.1.1.1.Line break after a pipe.ps1: -------------------------------------------------------------------------------- 1 | Get-Process | 2 | Where-Object Name -match 'po?w(er)?sh(ell)?' 3 | -------------------------------------------------------------------------------- /Chapter17/8.1.1.2.Line break after a pipe.ps1: -------------------------------------------------------------------------------- 1 | Get-Process 2 | | Where-Object Name -match 'po?w(er)?sh(ell)?' 3 | -------------------------------------------------------------------------------- /Chapter17/9.0.0.1.Comment-based help.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_Comment_Based_Help 2 | -------------------------------------------------------------------------------- /Chapter17/9.2.1.7.Parameter help.ps1: -------------------------------------------------------------------------------- 1 | $Path = (Get-Process -ID $PID).Path 2 | -------------------------------------------------------------------------------- /Chapter18/1.0.0.2.The Parameter attribute.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | param ( 3 | [Parameter()] 4 | $Parameter 5 | ) 6 | -------------------------------------------------------------------------------- /Chapter18/1.1.1.2.Position and positional binding.ps1: -------------------------------------------------------------------------------- 1 | Test-Position 1 2 2 | 3 | # Expects output: 4 | # 5 | # 1-2 6 | -------------------------------------------------------------------------------- /Chapter18/2.2.1.1.Validation attributes.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_Functions_Advanced_Parameters 2 | -------------------------------------------------------------------------------- /Chapter18/2.2.12.2.The ValidateUserDrive attribute.ps1: -------------------------------------------------------------------------------- 1 | [ValidateDrive('User')] 2 | [string] 3 | $Parameter 4 | -------------------------------------------------------------------------------- /Chapter18/2.2.7.5.The ValidatePattern attribute.ps1: -------------------------------------------------------------------------------- 1 | [ValidatePattern('^Hello', Options = 'IgnoreCase, Multiline')] 2 | -------------------------------------------------------------------------------- /Chapter18/2.2.7.6.The ValidatePattern attribute.ps1: -------------------------------------------------------------------------------- 1 | [ValidatePattern('^Hello', Options = 'None')] 2 | -------------------------------------------------------------------------------- /Chapter18/2.3.4.2.The AllowEmptyCollection attribute.ps1: -------------------------------------------------------------------------------- 1 | Test-AllowEmptyCollection -Parameter @() 2 | -------------------------------------------------------------------------------- /Chapter18/3.2.1.4.Accepting null input.ps1: -------------------------------------------------------------------------------- 1 | Get-EmptyOutput | Where-Object { $_ } | Get-InputObject 2 | -------------------------------------------------------------------------------- /Chapter18/3.5.1.3.About ValueFromPipelineByPropertyName.ps1: -------------------------------------------------------------------------------- 1 | [PSCustomObject]@{ Name = 'Name'; Status = 'Running' } | 2 | Get-Status 3 | -------------------------------------------------------------------------------- /Chapter18/4.0.0.3.Defining parameter sets.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding(DefaultParameterSetName = 'FirstSetName')] 2 | -------------------------------------------------------------------------------- /Chapter18/4.0.0.4.Defining parameter sets.ps1: -------------------------------------------------------------------------------- 1 | [Parameter(Position = 1, ParameterSetName = 'FirstSetName')] 2 | $Parameter1 3 | -------------------------------------------------------------------------------- /Chapter18/5.4.1.2.Non-literal values.ps1: -------------------------------------------------------------------------------- 1 | Test-ArgumentCompleter -Path C:\Program Files 2 | -------------------------------------------------------------------------------- /Chapter19/1.0.0.1.Defining an enumeration.ps1: -------------------------------------------------------------------------------- 1 | enum MyEnum { 2 | First = 1 3 | Second = 2 4 | Third = 3 5 | } 6 | -------------------------------------------------------------------------------- /Chapter19/1.1.1.1.Enum and underlying types.ps1: -------------------------------------------------------------------------------- 1 | enum MyEnum { 2 | First = 1 3 | } 4 | -------------------------------------------------------------------------------- /Chapter19/1.1.1.3.Enum and underlying types.ps1: -------------------------------------------------------------------------------- 1 | enum MyEnum : ulong { 2 | First = 0 3 | Last = 18446744073709551615 4 | } 5 | -------------------------------------------------------------------------------- /Chapter19/1.1.1.4.Enum and underlying types.ps1: -------------------------------------------------------------------------------- 1 | [int][MyEnum]::First 2 | -------------------------------------------------------------------------------- /Chapter19/1.1.1.5.Enum and underlying types.ps1: -------------------------------------------------------------------------------- 1 | [MyEnum]::First -as [MyEnum].GetEnumUnderlyingType() 2 | -------------------------------------------------------------------------------- /Chapter19/1.1.1.6.Enum and underlying types.ps1: -------------------------------------------------------------------------------- 1 | [MyEnum]::First.value__ 2 | 3 | # Expects output: 4 | # 5 | # 0 6 | -------------------------------------------------------------------------------- /Chapter19/1.2.1.1.Automatic value assignment.ps1: -------------------------------------------------------------------------------- 1 | enum MyEnum { 2 | Zero 3 | One 4 | } 5 | -------------------------------------------------------------------------------- /Chapter19/1.2.1.2.Automatic value assignment.ps1: -------------------------------------------------------------------------------- 1 | enum MyEnum { 2 | Five = 5 3 | Six 4 | } 5 | -------------------------------------------------------------------------------- /Chapter19/1.2.1.4.Automatic value assignment.ps1: -------------------------------------------------------------------------------- 1 | [MyEnum]::Second.value__ 2 | 3 | # Expects output: 4 | # 5 | # 2 6 | -------------------------------------------------------------------------------- /Chapter19/1.3.1.3.Enum or ValidateSet.ps1: -------------------------------------------------------------------------------- 1 | $VerbosePreference = 'Continue' 2 | $VerbosePreference = 2 3 | -------------------------------------------------------------------------------- /Chapter19/1.3.1.4.Enum or ValidateSet.ps1: -------------------------------------------------------------------------------- 1 | [System.Management.Automation.ActionPreference]::Continue.value__ 2 | -------------------------------------------------------------------------------- /Chapter19/1.4.1.2.The Flags attribute.ps1: -------------------------------------------------------------------------------- 1 | [System.Security.AccessControl.FileSystemRights]'ReadData, Delete' 2 | -------------------------------------------------------------------------------- /Chapter19/1.4.1.4.The Flags attribute.ps1: -------------------------------------------------------------------------------- 1 | [Flags()] 2 | enum MyEnum { 3 | First = 1 4 | Second = 2 5 | Third = 4 6 | } 7 | -------------------------------------------------------------------------------- /Chapter19/1.4.1.7.The Flags attribute.ps1: -------------------------------------------------------------------------------- 1 | [MyEnum]6 2 | 3 | # Expects output: 4 | # 5 | # Second, Third 6 | -------------------------------------------------------------------------------- /Chapter19/2.0.0.1.Creating a class.ps1: -------------------------------------------------------------------------------- 1 | class MyClass { 2 | [string] $Value = 'My value' 3 | } 4 | -------------------------------------------------------------------------------- /Chapter19/2.0.0.4.Creating a class.ps1: -------------------------------------------------------------------------------- 1 | $customObject = [PSCustomObject]@{ Value = 'New value' } 2 | [MyClass]$customObject 3 | -------------------------------------------------------------------------------- /Chapter19/2.1.1.1.Properties.ps1: -------------------------------------------------------------------------------- 1 | class MyClass { 2 | [string] $Value = 'My value' 3 | } 4 | -------------------------------------------------------------------------------- /Chapter19/2.1.1.3.Properties.ps1: -------------------------------------------------------------------------------- 1 | $instance = [MyClass]::new() 2 | $instance.Value 3 | 4 | # Expects output: 5 | # 6 | # My value 7 | -------------------------------------------------------------------------------- /Chapter19/2.10.1.2.Supporting casting.ps1: -------------------------------------------------------------------------------- 1 | [MyClass]1 2 | 3 | # Expects output: 4 | # 5 | # Number 6 | # ------ 7 | # 1 8 | -------------------------------------------------------------------------------- /Chapter19/2.10.1.5.Supporting casting.ps1: -------------------------------------------------------------------------------- 1 | [MyClass][long]2312 2 | 3 | # Expects output: 4 | # 5 | # Number 6 | # ------ 7 | # 2312 8 | -------------------------------------------------------------------------------- /Chapter19/2.3.1.3.Methods.ps1: -------------------------------------------------------------------------------- 1 | [MyClass]::new().ToString() 2 | 3 | # Expects output: 4 | # 5 | # Hello world 6 | -------------------------------------------------------------------------------- /Chapter19/2.5.1.2.The Static modifier.ps1: -------------------------------------------------------------------------------- 1 | [MyClass]::Property 2 | [MyClass]::Method() 3 | -------------------------------------------------------------------------------- /Chapter19/2.9.1.1.Working with interfaces.ps1: -------------------------------------------------------------------------------- 1 | class MyClass { 2 | [int] $Number 3 | } 4 | -------------------------------------------------------------------------------- /Chapter19/2.9.2.5.Implementing IComparable.ps1: -------------------------------------------------------------------------------- 1 | $first -eq $second 2 | 3 | # Expects output: 4 | # 5 | # False 6 | -------------------------------------------------------------------------------- /Chapter19/4.2.2.3.ValidateArgumentsAttribute.ps1: -------------------------------------------------------------------------------- 1 | Test-Validate -Value 'a', 'c', 'f' 2 | -------------------------------------------------------------------------------- /Chapter19/5.3.1.2.Implementing Test.ps1: -------------------------------------------------------------------------------- 1 | $resource = [ComputerDescription]@{ 2 | Description = 'New description' 3 | } 4 | -------------------------------------------------------------------------------- /Chapter19/5.3.1.3.Implementing Test.ps1: -------------------------------------------------------------------------------- 1 | $resource.Test() 2 | 3 | # Expects output: 4 | # 5 | # False 6 | -------------------------------------------------------------------------------- /Chapter20/2.1.1.2.The root module.ps1: -------------------------------------------------------------------------------- 1 | Import-Module .\LocalMachine.psm1 2 | -------------------------------------------------------------------------------- /Chapter20/3.0.0.2.Publishing a module.ps1: -------------------------------------------------------------------------------- 1 | Unregister-PSRepository -Name PSLocal 2 | -------------------------------------------------------------------------------- /Chapter20/3.0.0.3.Publishing a module.ps1: -------------------------------------------------------------------------------- 1 | Unregister-PSResourceRepository -Name PSLocal 2 | -------------------------------------------------------------------------------- /Chapter20/3.0.0.4.Publishing a module.ps1: -------------------------------------------------------------------------------- 1 | Publish-Module -Path . -Repository PSLocal 2 | -------------------------------------------------------------------------------- /Chapter20/3.0.0.5.Publishing a module.ps1: -------------------------------------------------------------------------------- 1 | Publish-PSResource -Path . -Repository PSLocal 2 | -------------------------------------------------------------------------------- /Chapter20/4.2.1.2.Merging module content.ps1: -------------------------------------------------------------------------------- 1 | Install-Module ModuleBuilder -Scope CurrentUser 2 | Build-Module -SourcePath .\LocalMachine 3 | -------------------------------------------------------------------------------- /Chapter20/4.2.1.3.Merging module content.ps1: -------------------------------------------------------------------------------- 1 | Set-Location .\LocalMachine 2 | Build-Module 3 | -------------------------------------------------------------------------------- /Chapter20/5.1.1.5.Accessing module scope.ps1: -------------------------------------------------------------------------------- 1 | & (Get-Module SomeService) { GetServiceConnection } 2 | -------------------------------------------------------------------------------- /Chapter20/5.2.1.6.Modules, classes, and enumerations.ps1: -------------------------------------------------------------------------------- 1 | using module .\ModuleWithClass.psm1 2 | -------------------------------------------------------------------------------- /Chapter20/6.2.1.1.The OnRemove event.ps1: -------------------------------------------------------------------------------- 1 | $ExecutionContext.SessionState.Module.OnRemove 2 | -------------------------------------------------------------------------------- /Chapter20/6.2.1.5.The OnRemove event.ps1: -------------------------------------------------------------------------------- 1 | Remove-Module OnRemove 2 | -------------------------------------------------------------------------------- /Chapter20/LocalMachine/MultiFile/LocalMachine/test.ps1: -------------------------------------------------------------------------------- 1 | Import-Module .\LocalMachine.psd1 2 | 3 | Get-ComputerDescription 4 | -------------------------------------------------------------------------------- /Chapter20/LocalMachine/MultiFileWithModuleBuilder/LocalMachine/enum/Ensure.ps1: -------------------------------------------------------------------------------- 1 | enum Ensure { 2 | Absent 3 | Present 4 | } 5 | -------------------------------------------------------------------------------- /Chapter21/2.0.0.1.Static analysis.ps1: -------------------------------------------------------------------------------- 1 | $scriptBlock = { 2 | param ( $String ) 3 | Write-Host $String 4 | } 5 | -------------------------------------------------------------------------------- /Chapter21/2.1.1.1.PSScriptAnalyzer.ps1: -------------------------------------------------------------------------------- 1 | Install-Module PSScriptAnalyzer 2 | -------------------------------------------------------------------------------- /Chapter21/2.1.2.4.Configurable rules.ps1: -------------------------------------------------------------------------------- 1 | Invoke-ScriptAnalyzer .\Show-Password.ps1 -Settings CodeFormatting 2 | -------------------------------------------------------------------------------- /Chapter21/2.2.1.2.Using AST.ps1: -------------------------------------------------------------------------------- 1 | function Write-Content { Write-Host 'content' } 2 | 3 | (Get-Command Write-Content).ScriptBlock 4 | -------------------------------------------------------------------------------- /Chapter21/2.2.1.3.Using AST.ps1: -------------------------------------------------------------------------------- 1 | function Write-Content { Write-Host 'content' } 2 | 3 | (Get-Item function:\Write-Content).ScriptBlock 4 | -------------------------------------------------------------------------------- /Chapter21/2.2.2.1.Visualizing the AST.ps1: -------------------------------------------------------------------------------- 1 | Install-Module ShowPSAst -Scope CurrentUser 2 | -------------------------------------------------------------------------------- /Chapter21/2.2.2.2.Visualizing the AST.ps1: -------------------------------------------------------------------------------- 1 | Show-Ast 'Get-Process -ID $PID | Select-Object Name, Path' 2 | -------------------------------------------------------------------------------- /Chapter21/2.2.3.2.Searching the AST.ps1: -------------------------------------------------------------------------------- 1 | $predicate = { $true } 2 | -------------------------------------------------------------------------------- /Chapter21/3.0.0.1.Testing with Pester.ps1: -------------------------------------------------------------------------------- 1 | Install-Module Pester -Force -SkipPublisherCheck 2 | -------------------------------------------------------------------------------- /Chapter21/3.10.2.1.Adding methods to PSCustomObject.ps1: -------------------------------------------------------------------------------- 1 | [PSCustomObject]@{ 2 | Property = "Value" 3 | } 4 | -------------------------------------------------------------------------------- /Chapter21/3.10.4.1.Mocking CIM objects.ps1: -------------------------------------------------------------------------------- 1 | function Enable-PhysicalAdapter { 2 | Get-NetAdapter -Physical | Enable-NetAdapter 3 | } 4 | -------------------------------------------------------------------------------- /Chapter21/3.10.4.4.Mocking CIM objects.ps1: -------------------------------------------------------------------------------- 1 | Microsoft.Management.Infrastructure.CimInstance#MSFT_NetAdapter 2 | -------------------------------------------------------------------------------- /Chapter21/3.11.1.4.InModuleScope.ps1: -------------------------------------------------------------------------------- 1 | BeforeAll { 2 | Mock GetRegistryParameter -ModuleName LocalMachine 3 | } 4 | -------------------------------------------------------------------------------- /Chapter21/3.12.1.3.Pester in scripts.ps1: -------------------------------------------------------------------------------- 1 | @' 2 | Invoke-Pester -Path .\Get-ComputerDescription.tests.ps1 3 | '@ | Set-Content script.ps1 4 | -------------------------------------------------------------------------------- /Chapter21/3.5.2.1.Using the ForEach parameter.ps1: -------------------------------------------------------------------------------- 1 | choco list -e terraform -l -r 2 | -------------------------------------------------------------------------------- /Chapter21/3.9.1.2.Mocking commands.ps1: -------------------------------------------------------------------------------- 1 | Mock Start-Service -ModuleName ServiceState 2 | Mock Stop-Service -ModuleName ServiceState 3 | -------------------------------------------------------------------------------- /Chapter22/1.1.1.4.Terminating errors.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = 'Continue' 2 | -------------------------------------------------------------------------------- /Chapter22/2.0.0.2.Error actions.ps1: -------------------------------------------------------------------------------- 1 | $Error[0] 2 | 3 | # Expects output: 4 | # 5 | # Start-Task: Something went wrong 6 | -------------------------------------------------------------------------------- /Chapter22/2.1.1.1.About Get-Error.ps1: -------------------------------------------------------------------------------- 1 | $Error[4] | Get-Error 2 | -------------------------------------------------------------------------------- /Chapter22/3.1.1.1.Error records.ps1: -------------------------------------------------------------------------------- 1 | 100 / 0 2 | $record = $Error[0] 3 | -------------------------------------------------------------------------------- /Chapter22/3.1.1.2.Error records.ps1: -------------------------------------------------------------------------------- 1 | $record.ScriptStackTrace 2 | 3 | # Expects output: 4 | # 5 | # at , : line 1 6 | -------------------------------------------------------------------------------- /Chapter22/3.2.1.1.Raising non-terminating errors.ps1: -------------------------------------------------------------------------------- 1 | Write-Error -Message 'Message' 2 | -------------------------------------------------------------------------------- /Chapter22/3.3.1.3.Using the WriteError method.ps1: -------------------------------------------------------------------------------- 1 | $? 2 | 3 | # Expects output: 4 | # 5 | # False 6 | -------------------------------------------------------------------------------- /Chapter22/3.4.1.1.Raising terminating errors.ps1: -------------------------------------------------------------------------------- 1 | throw 'Error message' 2 | -------------------------------------------------------------------------------- /Chapter22/3.4.1.2.Raising terminating errors.ps1: -------------------------------------------------------------------------------- 1 | throw [ArgumentException]::new('Unsupported value') 2 | -------------------------------------------------------------------------------- /Chapter22/4.1.1.3.ErrorVariable.ps1: -------------------------------------------------------------------------------- 1 | $MyErrorVariable 2 | 3 | # Expects output: 4 | # 5 | # Invoke-Something: Invoke-Something Failed 6 | -------------------------------------------------------------------------------- /Chapter22/4.1.1.4.ErrorVariable.ps1: -------------------------------------------------------------------------------- 1 | $MyErrorVariable.Count -eq 0 2 | -------------------------------------------------------------------------------- /Chapter22/4.1.1.5.ErrorVariable.ps1: -------------------------------------------------------------------------------- 1 | Invoke-Something -ErrorVariable MyErrorVariable 2 | Invoke-Something -ErrorVariable +MyErrorVariable 3 | -------------------------------------------------------------------------------- /Chapter22/4.2.1.2.try, catch, and finally.ps1: -------------------------------------------------------------------------------- 1 | try { 2 | 1/0 3 | } catch { 4 | Write-Error -ErrorRecord $_ 5 | } 6 | -------------------------------------------------------------------------------- /Chapter22/4.2.1.3.try, catch, and finally.ps1: -------------------------------------------------------------------------------- 1 | try { 2 | throw 'An error' 3 | } catch { 4 | Write-Host 'Caught an error' 5 | } 6 | -------------------------------------------------------------------------------- /Chapter22/4.2.1.4.try, catch, and finally.ps1: -------------------------------------------------------------------------------- 1 | try { 2 | 1/0 3 | } catch { 4 | Write-Host $_.Exception.Message 5 | } 6 | -------------------------------------------------------------------------------- /Chapter22/4.2.1.5.try, catch, and finally.ps1: -------------------------------------------------------------------------------- 1 | try { 2 | 1/0 3 | } catch [Exception] { 4 | Write-Host $_.Exception.Message 5 | } 6 | -------------------------------------------------------------------------------- /Chapter22/4.4.1.1.Nesting try, catch, and finally.ps1: -------------------------------------------------------------------------------- 1 | function Connect-Server {} 2 | -------------------------------------------------------------------------------- /Chapter22/5.1.1.1.Using trap.ps1: -------------------------------------------------------------------------------- 1 | trap { 2 | Write-Host 'An error occurred' 3 | } 4 | -------------------------------------------------------------------------------- /Chapter22/5.1.1.2.Using trap.ps1: -------------------------------------------------------------------------------- 1 | trap [ArgumentException] { 2 | Write-Host 'Argument exception' 3 | } 4 | -------------------------------------------------------------------------------- /Chapter23/1.1.1.1.Dash characters.ps1: -------------------------------------------------------------------------------- 1 | Get–Process | Where-Object WorkingSet64 –gt 100MB 2 | -------------------------------------------------------------------------------- /Chapter23/1.1.1.2.Dash characters.ps1: -------------------------------------------------------------------------------- 1 | "Get$([char]8211)Process | Where-Object WorkingSet64 $([char]8211)gt 100MB" 2 | -------------------------------------------------------------------------------- /Chapter23/1.2.2.1.Assignment instead of equality.ps1: -------------------------------------------------------------------------------- 1 | ($variable = $true) 2 | 3 | # Expects output: 4 | # 5 | # True 6 | -------------------------------------------------------------------------------- /Chapter23/1.3.3.2.Pipeline without process.ps1: -------------------------------------------------------------------------------- 1 | 1..5 | Write-Number 2 | 3 | # Expects output: 4 | # 5 | # 5 6 | -------------------------------------------------------------------------------- /Chapter23/1.4.2.1.About strict mode.ps1: -------------------------------------------------------------------------------- 1 | Set-StrictMode -Version Latest 2 | -------------------------------------------------------------------------------- /Chapter23/1.4.2.7.About strict mode.ps1: -------------------------------------------------------------------------------- 1 | Set-StrictMode -Off 2 | -------------------------------------------------------------------------------- /Chapter23/1.4.3.1.Variables and types.ps1: -------------------------------------------------------------------------------- 1 | [string]$string = 'Hello world' 2 | -------------------------------------------------------------------------------- /Chapter23/1.4.3.2.Variables and types.ps1: -------------------------------------------------------------------------------- 1 | $string = @{} 2 | $string 3 | 4 | # Expects output: 5 | # 6 | # System.Collections.Hashtable 7 | -------------------------------------------------------------------------------- /Chapter23/1.4.4.1.Types and reserved variables.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_automatic_variables 2 | -------------------------------------------------------------------------------- /Chapter23/1.4.4.4.Types and reserved variables.ps1: -------------------------------------------------------------------------------- 1 | Remove-Variable switch 2 | -------------------------------------------------------------------------------- /Chapter23/2.0.0.1.Debugging in the console.ps1: -------------------------------------------------------------------------------- 1 | Get-Help about_Debuggers 2 | -------------------------------------------------------------------------------- /Chapter23/2.1.1.2.Setting a command breakpoint.ps1: -------------------------------------------------------------------------------- 1 | $name 2 | 3 | # Expects output: 4 | # 5 | # powershell 6 | -------------------------------------------------------------------------------- /Chapter23/2.1.1.4.Setting a command breakpoint.ps1: -------------------------------------------------------------------------------- 1 | $name 2 | 3 | # Expects output: 4 | # 5 | # pwsh 6 | -------------------------------------------------------------------------------- /Chapter23/2.1.1.5.Setting a command breakpoint.ps1: -------------------------------------------------------------------------------- 1 | Get-PSBreakpoint | Remove-PSBreakpoint 2 | -------------------------------------------------------------------------------- /Chapter23/2.2.1.1.Using variable breakpoints.ps1: -------------------------------------------------------------------------------- 1 | foreach ($value in 1..5) { 2 | $newValue = $value 3 | } 4 | -------------------------------------------------------------------------------- /Chapter23/2.3.1.4.Setting a line breakpoint.ps1: -------------------------------------------------------------------------------- 1 | $PSBoundParameters -------------------------------------------------------------------------------- /Chapter23/3.2.1.1.Viewing the CALL STACK.ps1: -------------------------------------------------------------------------------- 1 | Write-Host 'Hello world' 2 | -------------------------------------------------------------------------------- /Chapter23/4.0.0.3.Debugging other PowerShell processes.ps1: -------------------------------------------------------------------------------- 1 | Detach 2 | --------------------------------------------------------------------------------