Modifying an item by using the pipe, thru the Set-ItemProperty cmdlet

Tagged: 

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Al Al 3 months, 1 week ago.

  • Author
    Posts
  • #60429
    Profile photo of Al
    Al
    Participant

    Reading the documentation about the Set-ItemProperty cmdlet here, I got a doubt:

    In example #3, which ParameterSet is being used by the Set-ItemProperty cmdlet?

    Here's the code:

    Get-ChildItem weekly.txt  |  Set-ItemProperty -Name IsReadOnly -Value $true
    

    Which ParameterSet is being used?

  • #60433
    Profile photo of Max Kozlov
    Max Kozlov
    Participant
    Trace-Command -Name ParameterBinding -Expression { Get-ChildItem weekly.txt | Set-ItemProperty -Name IsReadOnly -Value $True } -PSHost
    
  • #60444
    Profile photo of i255d
    i255d
    Participant

    DEBUG: ParameterBinding Information: 0 : BIND PIPELINE object to parameters: [Set-ItemProperty]
    DEBUG: ParameterBinding Information: 0 : PIPELINE object TYPE = [System.IO.FileInfo]
    DEBUG: ParameterBinding Information: 0 : RESTORING pipeline parameter's original values
    DEBUG: ParameterBinding Information: 0 : Parameter [Credential] PIPELINE INPUT ValueFromPipelineByPropertyName NO COERCION
    DEBUG: ParameterBinding Information: 0 : Parameter [Path] PIPELINE INPUT ValueFromPipelineByPropertyName NO COERCION
    DEBUG: ParameterBinding Information: 0 : Parameter [Credential] PIPELINE INPUT ValueFromPipelineByPropertyName NO COERCION
    DEBUG: ParameterBinding Information: 0 : Parameter [LiteralPath] PIPELINE INPUT ValueFromPipelineByPropertyName NO COERCION
    DEBUG: ParameterBinding Information: 0 : BIND arg [Microsoft.PowerShell.Core\FileSystem::C:\01Servers\error.txt] to parameter [LiteralPath]
    DEBUG: ParameterBinding Information: 0 : Binding collection parameter LiteralPath: argument type [String], parameter type [System.String[]], collection type Array, element type [System.Strin
    g], no coerceElementType
    DEBUG: ParameterBinding Information: 0 : Creating array with element type [System.String] and 1 elements
    DEBUG: ParameterBinding Information: 0 : Argument type String is not IList, treating this as scalar
    DEBUG: ParameterBinding Information: 0 : Adding scalar element of type String to array position 0
    DEBUG: ParameterBinding Information: 0 : BIND arg [System.String[]] to param [LiteralPath] SUCCESSFUL

    Looks like it is LiteralPath that is receiving the property from Get-Childitem.

  • #60504
    Profile photo of Al
    Al
    Participant

    @i255d : thanks. Checking the doc, I see LiteralPath PARAMETER has an alias ( PSPath ), which, AFAIR, is added ( along with others properties ) to all PSObject's that contain a path. It would be great if Trace-Command could make this clear in its output, i.e., that the binding occurs due to the alias PSPath.

You must be logged in to reply to this topic.