Created
February 28, 2022 11:39
-
-
Save fatherjack/94e4414f3f0af7a658edae2c75d17865 to your computer and use it in GitHub Desktop.
Creates a quoted, comma separated list of values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-QuotedString { | |
<# | |
.SYNOPSIS | |
Takes a pasted set of cells from Excel and returns a quoted, comma separated string that can be pasted into SSMS for a SQL filter | |
.DESCRIPTION | |
Long description | |
.PARAMETER ItemsList | |
The cell list from Excel as a string - just paste inside a pair of quotes and assign that to a variable | |
.EXAMPLE | |
$x = "Books | |
Cheese and biscuits | |
Humous" | |
$x | New-QuotedString | |
result: | |
'Books','Cheese and biscuits','Humous' | |
.NOTES | |
Author: @fatherjack | |
Date: 20220228 | |
#> | |
[CmdletBinding()] | |
param ( | |
[Parameter(ValueFromPipeline = $true)] | |
[string] | |
$ItemsList | |
) | |
process { | |
"'{0}'" -f ($ItemsList -replace ("`r`n", "','")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment