… unless you understand that a) ArrayList.Add() returns an integer, being the index of the item in the array, b) that goes onto the pipeline (unless you do something to eat it before it returns to the caller).
Here are the MSDN docs on ArrayList, where you can find the point about the Add method return value.
Here is a snippet where you can test the point in PowerShell
While I might not always use it, when you’ve been away for a while and forgotten syntax, New-Fixture scaffolds up a PowerShell script (the script under test – SUT), and a PowerShell pester script to test the SUT. The wiki is very good and is here.
I don’t like the idea of having the test and production script in the same folder, but that is easy enough to adjust (see posts passim).
Given a column of data (e.g. in Excel, Sheets), convert it to a delimited string (using PowerShell)
If I have data like this in a spreadsheet:
I want to create a single delimited string from that:
This is one way:
However, those were numbers/integers, so nice and easy.
If I now make one of them an alphanumeric…
… not so smooth this time:
Neither Sheets nor Excel will surround alphas with the necessary quotes. If we do that by hand…
, then this time no objections, and the quotes have been removed, which for my purposes is what I want anyway:
I’ll wrap this up another time, but this is the essence:
You could in fact then use Out-GridView to display and filter, or just use the filter in the Grid, and remove the [where-Object] from the original query. However, that would be less manageable if you had a farm of VMs to query. But it’s there, if needed.
The SQLServer package has taken over from SQLPS. Basic backup and restore examples on my GitHub, and the data I used to create the tables (just create the databases by hand for now).
And the screenshots as I got the hang of it…
Short examples of a mix of passing and failing Pester tests being rendered in a browser, using ReportUnit, available on NuGet, and ingesting NUnit output format. Check out the browser screenshots below first for the end result.
# Runs all test suites, passes the output to the NUnit format, renders it, displays in a browser
# see my article here for installing nuget via Choco:
nuget.exe install ReportUnit
#Then, for example...
# Execute all the tests
$outputName = Get-Random
$outputFile = "$PSScriptRoot/$outputName.xml"
$htmlFile = "$PSScriptRoot/$outputName.html"
Invoke-Pester -PassThru -Strict -OutputFile $outputFile -OutputFormat NUnitXml
Start-Process chrome $htmlFile