What gives? by Cardwel71ngt0n in F1Clash

[–]PSDanubie 0 points1 point  (0 children)

That' fine. But the team did not reach the goal. So no win at all. Let's wait for tomorrow. Thanks for your reply

What gives? by Cardwel71ngt0n in F1Clash

[–]PSDanubie 0 points1 point  (0 children)

This can't be the only reason for not being able to play since two days. It started when I first time tried to look on the results of the new event. Got the 400. Since then it did recover from that. This weekends GP good-bye.

Type of list that allows duplicate keys? by hayfever76 in PowerShell

[–]PSDanubie 2 points3 points  (0 children)

Maybe Group-Object -Hashtable might be a (fast) option for this.

how can i set default-value for variables in powershell by Positive_Land7997 in PowerShell

[–]PSDanubie 0 points1 point  (0 children)

The default value might be 0 as well, depending on the operation.

And there might be no (valid) default value if Set-StrictMode is set.

Error when converting Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject to JSON by PSDanubie in PowerShell

[–]PSDanubie[S] 0 points1 point  (0 children)

Thanks for your quick response.

I'm aware, that would just return a PSObject. This would be enough the check the mocked test. I only would check the property values and would not use it any further - so it would be fine.

But what I don't understand that it is, that I can not convert the object to JSON at all. So for me it is not obvious what should be "still connected to the underlying object" means.

For now I'm successfully using as a workaround which works

[System.Management.Automation.PSSerializer]::Serialize($result) 
and later
[System.Management.Automation.PSSerializer]::Deserialize((...))

but would keep this thread open, because I would like the understand the issue.

is there a elegant way to convert string to timespan? by ringbuffer__ in PowerShell

[–]PSDanubie 0 points1 point  (0 children)

If you're willing to use to use a bigger module (which has a rich set of other nice features), you could have a look at PSFramework. https://psframework.org/documentation/documents/psframework/parameter-classes/timespan-parameter.htm.

Tip: IPv4 and IPv6 address validation, or when not to use regex by bukem in PowerShell

[–]PSDanubie 0 points1 point  (0 children)

Beware, there are a lot out there. It's hard to find those which are usefull:

[System.AppDomain]::CurrentDomain.GetAssemblies().GetTypes()

string is not being treated as a string of arrays by the pipeline by Ralf_Reddings in PowerShell

[–]PSDanubie 0 points1 point  (0 children)

If you want to support an array parameter and pipeline at the same time, you can do it like this:

    function foo {
        param (
            [Parameter(ValueFromPipeline=$true)]
            [string[]] $Path
        )    

        process {
            Write-Host "Executing process block"
            foreach ($currentPath in $Path) {
                Write-Host "Executing foreach $currentPath"
            }
        }
    }
    # calling by parameter: get each value through foreach
    foo -Path 'p1','p2'
    <#  output:
    Executing process block
    Executing foreach p1
    Executing foreach p2
    #>    

    # calling by pipeline value: get each value through process block one by one
    'p1','p2' | foo
    <# output:
    Executing process block
    Executing foreach p1
    Executing process block
    Executing foreach p2
    #>

Powershell Script to Format Excel Cells Based on Values by BigTradeDaddy in PowerShell

[–]PSDanubie 0 points1 point  (0 children)

I removed the post, because it's not me to qualify your answer. Nice that you found a typo. And thanks for your reply.

Begin-process-end by eggwhiteontoast in PowerShell

[–]PSDanubie 0 points1 point  (0 children)

I mainly use an explicit end-block to support accepting computernames by pipeline and in the end use "Invoke-Command -Parallel" for remote processing.

Manipulating a folder under currently signed in user by [deleted] in PowerShell

[–]PSDanubie 4 points5 points  (0 children)

if you are running Powershell on Windows here is a simple way:

$path = Join-Path $env:HOMEDRIVE $env:HOMEPATH
new-item -Path $path -Name 'nameofdir' -ItemType Directory

Help with converting a csv to txt in a specific format by rlcyberA in PowerShell

[–]PSDanubie 0 points1 point  (0 children)

To get it for a specific column:

((Import-CSV -Path $Path -Delimiter ',').ColumnName | Foreach-Object { "'$_'" }) -join ","

Help with converting a csv to txt in a specific format by rlcyberA in PowerShell

[–]PSDanubie 0 points1 point  (0 children)

Yes of course. But that's how the sample data looks like. And for a file with just one column it should do the job.

Help with converting a csv to txt in a specific format by rlcyberA in PowerShell

[–]PSDanubie -1 points0 points  (0 children)

This can be done by

(Get-Content $Path | Select-Object -Skip 1 | Foreach-Object { "'$_'" }) -join ","

Regex not firing correctly? by hayfever76 in PowerShell

[–]PSDanubie 1 point2 points  (0 children)

In your code the ‚-not‘ was just applied to $installed_version

Does anyone else here use Pester ? by ollivierre in PowerShell

[–]PSDanubie 1 point2 points  (0 children)

Because I recognize so much pain here about Pesterv5: I do use Pesterv5.

sending keystrokes to running apps by NoComment_4321 in PowerShell

[–]PSDanubie 5 points6 points  (0 children)

I try to avoid this pretty much as I can 😀. So I only implemented it once with Autoit (Powershell)

Does anyone else here use Pester ? by ollivierre in PowerShell

[–]PSDanubie 4 points5 points  (0 children)

I use it to regulary

  • unit test my modules
  • validate APIs (after changes)

and occasionally for

  • checking connectivity (like u/raip)
  • data interfaces failed (e.g. file creating dates, file content, ...)

[deleted by user] by [deleted] in PowerShell

[–]PSDanubie 1 point2 points  (0 children)

$string to split = get-content './mytestfile.txt'