Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions reference/7.5/Microsoft.PowerShell.Utility/Add-Member.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ The third command uses dot notation to get the value of the **Status** property
`$a`. As the output shows, the value is `Done`.

```powershell
$A = Get-ChildItem c:\ps-test\test.txt
$A = Get-ChildItem C:\ps-test\test.txt
$A | Add-Member -NotePropertyName Status -NotePropertyValue Done
$A.Status
```
Expand Down Expand Up @@ -211,25 +211,35 @@ In this example we create a custom object that contains two **NoteProperty** mem
property is a string.

```powershell
PS> $obj = [pscustomobject]@{
Name = 'Doris'
Age = '20'
$user = [pscustomobject]@{
Name = 'Doris'
Age = '20'
}
$addMemberSplat = @{
MemberType = 'AliasProperty'
Name = 'intAge'
Value = 'Age'
SecondValue = 'UInt32'
}
PS> $obj | Add-Member -MemberType AliasProperty -Name 'intAge' -Value age -SecondValue uint32
PS> $obj | Get-Member
$user | Add-Member @addMemberSplat
$user | Get-Member
```

```Output
TypeName: System.Management.Automation.PSCustomObject

Name MemberType Definition
---- ---------- ----------
intAge AliasProperty intAge = (System.UInt32)age
intAge AliasProperty intAge = (System.UInt32)Age
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Age NoteProperty string Age=20
Name NoteProperty string Name=Doris
```

```powershell
PS> $obj

Name Age intAge
Expand Down Expand Up @@ -561,7 +571,7 @@ Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand Down Expand Up @@ -611,4 +621,4 @@ methods are being added. For more information about the `$this` variable, see

[about_Automatic_Variables](../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md)

[System.Type.GetMethod()](/dotnet/api/system.type.getmethod)
[System.Type.GetMethod()](xref:System.Type.GetMethod%2a)
27 changes: 14 additions & 13 deletions reference/7.5/Microsoft.PowerShell.Utility/Add-Type.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Adds a Microsoft .NET class to a PowerShell session.
### FromSource (Default)

```
Add-Type [-TypeDefinition] <String> [-Language <Language>] [-ReferencedAssemblies <String[]>]
[-OutputAssembly <String>] [-OutputType <OutputAssemblyType>] [-PassThru] [-IgnoreWarnings]
Add-Type [-TypeDefinition] <String> [-Language <Language>]
[-ReferencedAssemblies <String[]>] [-OutputAssembly <String>]
[-OutputType <OutputAssemblyType>] [-PassThru] [-IgnoreWarnings]
[-CompilerOptions <String[]>] [<CommonParameters>]
```

Expand All @@ -28,24 +29,24 @@ Add-Type [-TypeDefinition] <String> [-Language <Language>] [-ReferencedAssemblie
```
Add-Type [-Name] <String> [-MemberDefinition] <String[]> [-Namespace <String>]
[-UsingNamespace <String[]>] [-Language <Language>] [-ReferencedAssemblies <String[]>]
[-OutputAssembly <String>] [-OutputType <OutputAssemblyType>] [-PassThru] [-IgnoreWarnings]
[-CompilerOptions <String[]>] [<CommonParameters>]
[-OutputAssembly <String>] [-OutputType <OutputAssemblyType>] [-PassThru]
[-IgnoreWarnings] [-CompilerOptions <String[]>] [<CommonParameters>]
```

### FromPath

```
Add-Type [-Path] <String[]> [-ReferencedAssemblies <String[]>] [-OutputAssembly <String>]
[-OutputType <OutputAssemblyType>] [-PassThru] [-IgnoreWarnings] [-CompilerOptions <String[]>]
[<CommonParameters>]
[-OutputType <OutputAssemblyType>] [-PassThru] [-IgnoreWarnings]
[-CompilerOptions <String[]>] [<CommonParameters>]
```

### FromLiteralPath

```
Add-Type -LiteralPath <String[]> [-ReferencedAssemblies <String[]>] [-OutputAssembly <String>]
[-OutputType <OutputAssemblyType>] [-PassThru] [-IgnoreWarnings] [-CompilerOptions <String[]>]
[<CommonParameters>]
Add-Type -LiteralPath <String[]> [-ReferencedAssemblies <String[]>]
[-OutputAssembly <String>] [-OutputType <OutputAssemblyType>] [-PassThru]
[-IgnoreWarnings] [-CompilerOptions <String[]>] [<CommonParameters>]
```

### FromAssemblyName
Expand Down Expand Up @@ -451,7 +452,7 @@ Accept wildcard characters: True
Specifies the output type of the output assembly. By default, no output type is specified. This
parameter is valid only when an output assembly is specified in the command. For more information
about the values, see
[OutputAssemblyType Enumeration](/dotnet/api/microsoft.powershell.commands.outputassemblytype).
[OutputAssemblyType Enumeration](xref:Microsoft.PowerShell.Commands.OutputAssemblyType).

The acceptable values for this parameter are as follows:

Expand Down Expand Up @@ -541,7 +542,7 @@ Accept wildcard characters: False

Specifies the source code that contains the type definitions. Enter the source code in a string or
here-string, or enter a variable that contains the source code. For more information about
here-strings, see [about_Quoting_Rules](../Microsoft.PowerShell.Core/about/about_Quoting_Rules.md).
here-strings, see [about_Quoting_Rules](../Microsoft.PowerShell.Core/About/about_Quoting_Rules.md).

Include a namespace declaration in your type definition. If you omit the namespace declaration, your
type might have the same name as another type or the shortcut for another type, causing an
Expand Down Expand Up @@ -628,15 +629,15 @@ arbitrary path requires `Add-Type`, since those assemblies can't not be loaded a

## RELATED LINKS

[about_Profiles](../Microsoft.PowerShell.Core/About/about_profiles.md)
[about_Profiles](../Microsoft.PowerShell.Core/About/about_Profiles.md)

[about_Quoting_Rules](../Microsoft.PowerShell.Core/About/about_Quoting_Rules.md)

[Add-Member](Add-Member.md)

[New-Object](New-Object.md)

[OutputAssemblyType](/dotnet/api/microsoft.powershell.commands.outputassemblytype)
[OutputAssemblyType](xref:Microsoft.PowerShell.Commands.OutputAssemblyType)

[Platform Invoke (P/Invoke)](/dotnet/standard/native-interop/pinvoke)

Expand Down
12 changes: 7 additions & 5 deletions reference/7.5/Microsoft.PowerShell.Utility/Clear-Variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Deletes the value of a variable.
## SYNTAX

```
Clear-Variable [-Name] <String[]> [-Include <String[]>] [-Exclude <String[]>] [-Force] [-PassThru]
[-Scope <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
Clear-Variable [-Name] <String[]> [-Include <String[]>] [-Exclude <String[]>] [-Force]
[-PassThru] [-Scope <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -39,7 +39,7 @@ This command removes the value of global variables that have names that begin wi
### Example 2: Clear a variable in a child scope but not the parent scope

```powershell
$a=3
$a = 3
&{ Clear-Variable a }
$a
```
Expand Down Expand Up @@ -163,7 +163,8 @@ The acceptable values for this parameter are:
- `Script`

You can also use a number relative to the current scope (0 through the number of scopes, where 0 is
the current scope and 1 is its parent). Local is the default. For more information, see [about_Scopes](../Microsoft.PowerShell.Core/About/about_Scopes.md).
the current scope and 1 is its parent). Local is the default. For more information, see
[about_Scopes](../Microsoft.PowerShell.Core/About/about_Scopes.md).

```yaml
Type: System.String
Expand Down Expand Up @@ -213,7 +214,8 @@ Accept wildcard characters: False

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand Down
17 changes: 13 additions & 4 deletions reference/7.5/Microsoft.PowerShell.Utility/Compare-Object.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Compares two sets of objects.

```
Compare-Object [-ReferenceObject] <PSObject[]> [-DifferenceObject] <PSObject[]>
[-SyncWindow <Int32>] [-Property <Object[]>] [-ExcludeDifferent] [-IncludeEqual] [-PassThru]
[-Culture <String>] [-CaseSensitive] [<CommonParameters>]
[-SyncWindow <Int32>] [-Property <Object[]>] [-ExcludeDifferent] [-IncludeEqual]
[-PassThru] [-Culture <String>] [-CaseSensitive] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -56,7 +56,11 @@ The output displays only the lines that are different between the files. `Testfi
content that appear in both files aren't displayed.

```powershell
Compare-Object -ReferenceObject (Get-Content -Path C:\Test\Testfile1.txt) -DifferenceObject (Get-Content -Path C:\Test\Testfile2.txt)
$objects = @{
ReferenceObject = (Get-Content -Path C:\Test\Testfile1.txt)
DifferenceObject = (Get-Content -Path C:\Test\Testfile2.txt)
}
Compare-Object @objects
```

```Output
Expand Down Expand Up @@ -174,7 +178,12 @@ output displayed by the default format for **System.Boolean** objects didn't dis
In this example, we compare two different string that have the same length.

```powershell
Compare-Object -ReferenceObject 'abc' -DifferenceObject 'xyz' -Property Length -IncludeEqual
$objects = @{
ReferenceObject = 'abc'
DifferenceObject = 'xyz'
Property = 'Length'
}
Compare-Object @objects -IncludeEqual
```

```Output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ ConvertFrom-Csv [[-Delimiter] <Char>] [-InputObject] <PSObject[]> [-Header <Stri
### UseCulture

```
ConvertFrom-Csv -UseCulture [-InputObject] <PSObject[]> [-Header <String[]>] [<CommonParameters>]
ConvertFrom-Csv -UseCulture [-InputObject] <PSObject[]> [-Header <String[]>]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -89,7 +90,7 @@ $Header = 'State', 'MoreData', 'StatusMessage', 'Location', 'Command',
'BeginTime', 'EndTime', 'JobType', 'Output', 'Error', 'Progress',
'Verbose', 'Debug', 'Warning', 'Information'
# Delete the default header from $J
$J = $J[1..($J.count - 1)]
$J = $J[1..($J.Count - 1)]
$J | ConvertFrom-Csv -Header $Header
```

Expand Down
13 changes: 8 additions & 5 deletions reference/7.5/Microsoft.PowerShell.Utility/ConvertFrom-Json.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Converts a JSON-formatted string to a custom object or a hash table.
## SYNTAX

```
ConvertFrom-Json [-InputObject] <String> [-AsHashtable] [-DateKind <JsonDateKind>] [-Depth <Int32>]
[-NoEnumerate] [<CommonParameters>]
ConvertFrom-Json [-InputObject] <String> [-AsHashtable] [-DateKind <JsonDateKind>]
[-Depth <Int32>] [-NoEnumerate] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -91,7 +91,8 @@ that can be managed in PowerShell.
```powershell
# Ensures that Invoke-WebRequest uses TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$j = Invoke-WebRequest 'https://api.github.com/repos/PowerShell/PowerShell/issues' | ConvertFrom-Json
$j = Invoke-WebRequest 'https://api.github.com/repos/PowerShell/PowerShell/issues' |
ConvertFrom-Json
```

You can also use the `Invoke-RestMethod` cmdlet, which automatically converts JSON content to
Expand Down Expand Up @@ -128,8 +129,10 @@ This command shows an example where the `-NoEnumerate` switch is used to round-t
JSON array.

```powershell
Write-Output "With -NoEnumerate: $('[1]' | ConvertFrom-Json -NoEnumerate | ConvertTo-Json -Compress)"
Write-Output "Without -NoEnumerate: $('[1]' | ConvertFrom-Json | ConvertTo-Json -Compress)"
Write-Output "With -NoEnumerate: $('[1]' | ConvertFrom-Json -NoEnumerate |
ConvertTo-Json -Compress)"
Write-Output "Without -NoEnumerate: $('[1]' | ConvertFrom-Json |
ConvertTo-Json -Compress)"
```

```Output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ title: ConvertFrom-Markdown
# ConvertFrom-Markdown

## SYNOPSIS
Convert the contents of a string or a file to a **MarkdownInfo**
object.
Convert the contents of a string or a file to a **MarkdownInfo** object.

## SYNTAX

Expand Down Expand Up @@ -161,7 +160,8 @@ Accept wildcard characters: True

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Converts a SDDL string to a custom object.
### All

```
ConvertFrom-SddlString [-Sddl] <String> [-Type <AccessRightTypeNames>] [<CommonParameters>]
ConvertFrom-SddlString [-Sddl] <String> [-Type <AccessRightTypeNames>]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -57,7 +58,7 @@ ConvertFrom-SddlString -Sddl $acl.Sddl -Type RegistryRights
```

The first command uses the `Get-Acl` cmdlet to get the security descriptor for the
HKLM:\SOFTWARE\Microsoft\ key and saves it in the variable.
`HKLM:\SOFTWARE\Microsoft\` key and saves it in the variable.

The second command uses the `ConvertFrom-SddlString` cmdlet to get the text representation of the
SDDL string, contained in the Sddl property of the object representing the security descriptor.
Expand All @@ -70,16 +71,22 @@ It uses the `-Type` parameter to specify that SDDL string represents a registry
$acl = Get-Acl -Path HKLM:\SOFTWARE\Microsoft\

ConvertFrom-SddlString -Sddl $acl.Sddl | Foreach-Object {$_.DiscretionaryAcl[0]}
```

```Output
BUILTIN\Administrators: AccessAllowed (ChangePermissions, CreateDirectories, Delete, ExecuteKey, FullControl, GenericExecute, GenericWrite, ListDirectory, ReadExtendedAttributes, ReadPermissions, TakeOwnership, Traverse, WriteData, WriteExtendedAttributes, WriteKey)
```

```powershell
ConvertFrom-SddlString -Sddl $acl.Sddl -Type RegistryRights | Foreach-Object {$_.DiscretionaryAcl[0]}
```

```Output
BUILTIN\Administrators: AccessAllowed (ChangePermissions, CreateLink, CreateSubKey, Delete, EnumerateSubKeys, ExecuteKey, FullControl, GenericExecute, GenericWrite, Notify, QueryValues, ReadPermissions, SetValue, TakeOwnership, WriteKey)
```

The first command uses the `Get-Acl` cmdlet to get the security descriptor for the
HKLM:\SOFTWARE\Microsoft\ key and saves it in the variable.
`HKLM:\SOFTWARE\Microsoft\` key and saves it in the variable.

The second command uses the `ConvertFrom-SddlString` cmdlet to get the text representation of the
SDDL string, contained in the Sddl property of the object representing the security descriptor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ string must conform to the rules for a **DATA** section. For more information, s
`ConvertFrom-StringData` supports escape character sequences that are allowed by conventional
machine translation tools. That is, the cmdlet can interpret backslashes (`\`) as escape characters
in the string data by using the
[Regex.Unescape Method](/dotnet/api/system.text.regularexpressions.regex.unescape), instead of the
[Regex.Unescape Method](xref:System.Text.RegularExpressions.Regex.Unescape%2a), instead of the
PowerShell backtick character (`` ` ``) that would normally signal the end of a line in a script.
Inside the here-string, the backtick character doesn't work. You can also preserve a literal
backslash in your results by escaping it with a preceding backslash, like this: `\\`. Unescaped
Expand Down Expand Up @@ -288,7 +288,7 @@ Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand Down
8 changes: 5 additions & 3 deletions reference/7.5/Microsoft.PowerShell.Utility/ConvertTo-Csv.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ ConvertTo-Csv [-InputObject] <PSObject> [[-Delimiter] <Char>] [-IncludeTypeInfor
### UseCulture

```
ConvertTo-Csv [-InputObject] <PSObject> [-UseCulture] [-IncludeTypeInformation] [-NoTypeInformation]
[-QuoteFields <String[]>] [-UseQuotes <QuoteKind>] [-NoHeader] [<CommonParameters>]
ConvertTo-Csv [-InputObject] <PSObject> [-UseCulture] [-IncludeTypeInformation]
[-NoTypeInformation] [-QuoteFields <String[]>] [-UseQuotes <QuoteKind>] [-NoHeader]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -89,7 +90,8 @@ This example converts the Windows event log for PowerShell to a series of CSV st

```powershell
(Get-Culture).TextInfo.ListSeparator
Get-WinEvent -LogName 'PowerShellCore/Operational' | ConvertTo-Csv -UseCulture -NoTypeInformation
Get-WinEvent -LogName 'PowerShellCore/Operational' |
ConvertTo-Csv -UseCulture -NoTypeInformation
```

```Output
Expand Down
Loading