PetSerAl

My feedback

  1. 32 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    5 comments  ·  PowerShell » ISE and tooling  ·  Flag idea as inappropriate…  ·  Admin →
    An error occurred while saving the comment
    PetSerAl commented  · 

    You can always write your own little wrapper for that:

    function Out-GridViewSelect {
    param($Property)
    $input | Select-Object -Property @($Property; @{ Name = 'InputObject'; Expression = { ,$_ } }) | ForEach-Object {
    Add-Member -InputObject $_ -MemberType MemberSet -Name PSStandardMembers -Value (
    [System.Management.Automation.PSPropertySet]::new('DefaultDisplayPropertySet', [String[]]@(
    $_.PSObject.Properties | Where-Object Name -ne InputObject | ForEach-Object Name
    ))
    ) -PassThru
    } | Out-GridView @args | ForEach-Object InputObject
    }

    Get-ChildItem -File | Out-GridViewSelect Name, @{ Name = 'SizeGB'; Expression = { $_.Length / 1gb } } -OutputMode Multiple | ForEach-Object FullName

    PetSerAl supported this idea  · 
  2. 2 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  2 comments  ·  PowerShell » PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
    An error occurred while saving the comment
    PetSerAl commented  · 

    > Typically in programming languages
    PowerShell is not typical programming language, it is shell programming language. Loops (for, foreach, while, do, switch) do not create scope in PowerShell. And I think, that your proposal will break to much existing code, so it not worth it.

  3. 9 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  0 comments  ·  PowerShell » PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
    PetSerAl supported this idea  · 
  4. 2 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  2 comments  ·  PowerShell » Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
    An error occurred while saving the comment
    PetSerAl commented  · 

    -eq use [StringComparison]::InvariantCultureIgnoreCase comparison rather than [StringComparison]::Ordinal, used by [String]::Equals by default.

    [string]::Equals("`0",'',[StringComparison]::InvariantCultureIgnoreCase)

  5. 5 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  4 comments  ·  PowerShell » Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
    PetSerAl supported this idea  · 
    An error occurred while saving the comment
    PetSerAl commented  · 
  6. 5 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  4 comments  ·  PowerShell » PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
    An error occurred while saving the comment
    PetSerAl commented  · 

    @响叮咚 IMHO, it is a bug, but not PowerShell one. It is about how `ProcessStartInfo.RedirectStandardInput` is handled.

    An error occurred while saving the comment
    PetSerAl commented  · 

    Use this as workaround:

    if(
        [Console]::InputEncoding -is [Text.UTF8Encoding] -and
        [Console]::InputEncoding.GetPreamble().Length -ne 0
    ) {
        [Console]::InputEncoding = New-Object Text.UTF8Encoding $false
    }

    PetSerAl supported this idea  · 
  7. 2 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    6 comments  ·  PowerShell » PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
    An error occurred while saving the comment
    PetSerAl commented  · 

    My first language is not English, but it is not Chinese either.

    An error occurred while saving the comment
    PetSerAl commented  · 

    @响叮咚
    `print.exe` it built-in program, so `print` command exist. Also it is not a parser responsibility to do command name resolution. After all you can write it like this:

    $test=$(&(Read-Host) "<any string>(<any string>")

    Where command name depend on runtime user input.

    @Sam Attia
    Interesting bug. This code work well in v2. You can use this command to demonstrate bug in console:

    iex '$test=$(print "<any string>(<any string>")'

    PetSerAl supported this idea  · 
  8. 52 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    16 comments  ·  PowerShell » PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
    survey  ·  Zachary Alexander responded

    Thank you for your input. Based on its current ranking compared to other feedback items and product schedule, work on this item is pending (and will be driven by) further customer input. If you did not open this issue and are also impacted by it, please vote this item up.

    An error occurred while saving the comment
    PetSerAl commented  · 

    @Frode F.

    >Then why shouldn't this work?

    1..3|Select-Object @(@{Name='Value';Expression={$_}})

    Should it be splatting or should it retain its original meaning?

    PetSerAl supported this idea  · 
    An error occurred while saving the comment
    PetSerAl commented  · 

    Any proposition about how syntax for this should look like?

  9. 4 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    7 comments  ·  PowerShell » PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
    An error occurred while saving the comment
    PetSerAl commented  · 

    >I'd like splatting to have a functional advantage.

    Splatting already have functional advantage. Compare this:

    if(ShouldUseParameter1) {
        if(ShouldUseParameter2) {
            if(ShouldUseParameter3) {
                Command -Parameter1 Value1 -Parameter2 Value2 -Parameter3 Value3
            } else {
                Command -Parameter1 Value1 -Parameter2 Value2
            }
        } else {
            if(ShouldUseParameter3) {
                Command -Parameter1 Value1 -Parameter3 Value3
            } else {
                Command -Parameter1 Value1
            }
        }
    } else {
        if(ShouldUseParameter2) {
            if(ShouldUseParameter3) {
                Command -Parameter2 Value2 -Parameter3 Value3
            } else {
                Command -Parameter2 Value2
            }
        } else {
            if(ShouldUseParameter3) {
                Command -Parameter3 Value3
            } else {
                Command
            }
        }
    }

    To this:

    $Params=@{}
    if(ShouldUseParameter1) {
        $Params['Parameter1']='Value1'
    }
    if(ShouldUseParameter2) {
        $Params['Parameter2']='Value2'
    }
    if(ShouldUseParameter3) {
        $Params['Parameter3']='Value3'
    }
    Command @Params

    Now imagine you have ten such parameters.

    An error occurred while saving the comment
    PetSerAl commented  · 

    I see your point now, but personally I do not agree with it.

    If I mistype parameter name in hash table, I want that error to popup at my face right now. I does not want to debug why parameter not bound.

    I definitely will not use this feature against anyone else's functions/cmdlets. New version of command can include new parameter, which can be silently bound from existing extra parameter in hash table.

    And what about array spatting? Currently I can write this:

    function WithForce { Get-ChildItem @args -Force }
    WithForce X:\ -Recurse # Works
    WithForce X:\ -Random # A parameter cannot be found that matches parameter name 'Random'

    Should it also ignore this splatting error?

    An error occurred while saving the comment
    PetSerAl commented  · 

    Blog post just says that you can not splat not existing parameters to advanced functions. I really does not see how it related to parameter being mandatory.

    function f{param([Parameter()]$NonMandatoryParameter)'All OK'}
    $Params=@{NonExistingParameter=12345}
    f @Params # A parameter cannot be found that matches parameter name 'NonExistingParameter'
    f -NonExistingParameter 12345 # Exanctly same error

    You specifying parameter that function does not have and that is error. Why specifying parameter thru splatting should not produce error?

    An error occurred while saving the comment
    PetSerAl commented  · 

    Can you provide example of this issue? I can not reproduce it with this code:

    function f{param([Parameter(Mandatory)]$MandatoryParameter)'All OK'}
    $Params=@{MandatoryParameter=12345}
    f @Params

  10. 6 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    7 comments  ·  PowerShell » PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
    An error occurred while saving the comment
    PetSerAl commented  · 

    Another example of this issue:
    "Begin$('(')This is completely ignored)End"

    PetSerAl supported this idea  · 
  11. 4 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    2 comments  ·  PowerShell » PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
    An error occurred while saving the comment
    PetSerAl commented  · 

    Additional case related to native application:

    function f {
    cmd /c echo @args
    }
    cmd /c echo -Param:Value 1,2,3,4,5
    # -Param:Value 1,2,3,4,5
    f -Param:Value 1,2,3,4,5
    # -Param: Value 1 2 3 4 5

    PetSerAl shared this idea  · 
  12. 2 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    1 comment  ·  PowerShell » PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
    An error occurred while saving the comment
    PetSerAl commented  · 

    Looks like it is not related to Parser. What matter is that enumerator of collection is a value type, so it copied into $foreach variable by value and does linked to enumerator, PowerShell use to enumerate collection.

    $List = New-Object System.Collections.Generic.List[Object] (,(1..10))
    foreach($i in $List) {
    if($i -gt 5) {
    [void]$foreach.MoveNext()
    }
    "`$i:$i `$foreach.Current:$($foreach.Current)"
    }

    PetSerAl supported this idea  · 

Feedback and Knowledge Base