Skip to content

Commit 6f5e09e

Browse files
Added Country value to json files (issue #3)
Added code to generate output by location Added IconUrl value to json files (issue #2) Renamed 'Group Name' to Name in json files (Issue #10) Archived previous json file versions Updated README.md Updated Build.ps1
1 parent 7dc2290 commit 6f5e09e

File tree

92 files changed

+787
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+787
-147
lines changed

New-LocationMarkdown.ps1

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#requires -version 5.0
2+
# generate a version of the user groups as a list in Markdown
3+
# grouped by country and state
4+
5+
<#
6+
This script will create a markdown version of PowerShell user groups
7+
based on the json entries in the Data folder.
8+
#>
9+
10+
[cmdletbinding(SupportsShouldProcess)]
11+
Param(
12+
[ValidateNotNullOrEmpty()]
13+
[ValidatePattern("\.md$")]
14+
[string]$OutputFile = "PowerShellGroupsbyLocation.md",
15+
#the path to the folder with json data files
16+
[string]$Path = ".\data",
17+
[switch]$Passthru
18+
)
19+
20+
$grouped = &$PSScriptRoot\get-uglist.ps1 -Path $path |
21+
Sort-Object -property Country, State, Name |
22+
Group-object -Property Country
23+
24+
$md = @"
25+
# PowerShell Groups by Location
26+
27+
"@
28+
29+
foreach ($item in $Grouped) {
30+
#strip off {} for country values with multiple entries like Australia,New Zealand
31+
$name = $item.name -replace "{|}", ""
32+
Write-Verbose "Processing $name"
33+
$md += "`n## $name`n"
34+
35+
#group each user group by state
36+
$states = $item.group | Group-Object -Property State
37+
38+
foreach ($state in $states) {
39+
40+
if ($state.name -match "\w+") {
41+
write-Verbose "Adding $($state.name)"
42+
$md += "`n### $($state.name)`n"
43+
}
44+
foreach ($group in $state.group) {
45+
write-Verbose $group.name
46+
47+
$group.psobject.properties.name |
48+
foreach-object {
49+
if ($group.$_ -is [array]) {
50+
$group.$_ = $group.$_ -join ","
51+
}
52+
}
53+
$details = ($group | Select-Object -property Name, Owner, Location, WebSiteURL, Twitter, Email | Out-String).trim() -split "`n"
54+
foreach ($detail in $details) {
55+
56+
$md += "`n$($detail.trim()) "
57+
}
58+
$md += "`n"
59+
} #foreach state group
60+
} #foreach group
61+
}
62+
63+
$utc = &$PSScriptRoot\get-utc.ps1
64+
$md += "`n_Generated $($utc)_"
65+
66+
$md | Out-File "$PSScriptRoot\$OutputFile" -Encoding utf8 -Width 80
67+
68+
if ($Passthru) {
69+
Get-Item -Path "$psscriptroot\$OutputFile"
70+
}

New-MarkdownList.ps1

+12-8
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,27 @@ $md = @"
2121
2222
"@
2323

24-
&$PSScriptRoot\get-uglist.ps1 -path $path| Sort-object -Property "Group Name" |
25-
foreach-object {
26-
$md+= "`n## $($_.'Group Name'.trim())`n"
24+
&$PSScriptRoot\get-uglist.ps1 -path $path| Sort-object -Property Name |
25+
foreach-object {
26+
$md += "`n## $($_.Name.trim())`n"
2727
#define a variable for the processed group to make it easier to track
2828
$group = $_
2929
#test each property to see if the value is an array
3030
#and if so update the object with a comma separated string
3131
$group.psobject.properties.name | foreach-object { if ($group.$_ -is [array]) {$group.$_ = $group.$_ -join ","}}
32-
$details = ($group | select-object -property * -exclude group*| out-string).trim() -split "`n"
32+
$details = ($group | select-object -property * -exclude Name | out-string).trim() -split "`n"
3333
foreach ($detail in $details) {
3434

35-
$md+= "`n$($detail.trim()) "
35+
$md += "`n$($detail.trim()) "
3636
}
37-
$md+="`n"
37+
$md += "`n"
3838
}
3939

4040
$utc = &$PSScriptRoot\get-utc.ps1
41-
$md+="`n_Generated $($utc)_"
41+
$md += "`n_Generated $($utc)_"
4242

43-
$md | Out-File "$PSScriptRoot\$OutputFile" -Encoding utf8
43+
$md | Out-File "$PSScriptRoot\$OutputFile" -Encoding utf8 -Width 80
44+
45+
if ($Passthru) {
46+
Get-Item -Path "$psscriptroot\$OutputFile"
47+
}

New-UserGroupEntry.ps1

+18-7
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,28 @@ Param(
2424
[alias("websiteURL")]
2525
[string[]]$URL,
2626
[Parameter(HelpMessage = "Enter the Twitter account(s) for the user group. Markdown is allowed", ValueFromPipelineByPropertyName)]
27-
[string[]]$Twitter
27+
[string[]]$Twitter,
28+
[Parameter(HelpMessage = "Enter the Country for the user group.", ValueFromPipelineByPropertyName)]
29+
[string]$Country = "USA",
30+
[Parameter(HelpMessage = "Enter the postal code abbreviation for your state if in the USA.", ValueFromPipelineByPropertyName)]
31+
[string]$State = "",
32+
[Parameter(HelpMessage = "Enter url to an icon file or graphic for your group. It may be resized.", ValueFromPipelineByPropertyName)]
33+
[string]$IconUrl = ""
34+
35+
2836
)
2937

3038
Process {
3139
[pscustomobject]@{
32-
'Group Name' = $Name
33-
Owner = $owner
34-
Location = $Location
35-
WebsiteURL = $Url
36-
Twitter = $Twitter
37-
Email = $email
40+
Name = $Name
41+
Owner = $owner
42+
Location = $Location
43+
WebsiteURL = $Url
44+
Twitter = $Twitter
45+
Email = $email
46+
Country = $Country
47+
State = $state
48+
Icon = $IconUrl
3849
} | Convertto-Json
3950
}
4051

New-UserGroupMarkdown.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ Param(
1818
$md = @"
1919
# PowerShell User Groups
2020
21-
|Group Name|Owner|Location|WebsiteURL|Twitter|Email|
22-
|----------|-----|--------|----------|-------|-----|
21+
|Name|Owner|Location|WebsiteURL|Twitter|Email|
22+
|----|-----|--------|----------|-------|-----|
2323
2424
"@
2525

2626
&$PSScriptRoot\get-uglist.ps1 -Path $path |
2727
Sort-Object "Group Name" |
2828
foreach-object {
29-
$md += "|{0}|{1}|{2}|{3}|{4}|{5}|`n" -f $_."Group Name", $($_.Owner -join ","), $_.location, ($_.WebSiteURL -join ","), $($_.Twitter -join ","), $($_.Email -join ",")
29+
$md += "|{0}|{1}|{2}|{3}|{4}|{5}|`n" -f $_.Name, $($_.Owner -join ","), $_.location, ($_.WebSiteURL -join ","), $($_.Twitter -join ","), $($_.Email -join ",")
3030
}
3131

3232
$md +=
3333
"`nList generated _$((Get-Date).toUniversaltime().DateTime) UTC_"
3434

35-
$md | Out-file -FilePath "$psscriptroot\$OutputFile" -Encoding utf8
35+
$md | Out-file -FilePath "$psscriptroot\$OutputFile" -Encoding utf8 -Width 80
3636

3737
if ($Passthru) {
3838
Get-Item -Path "$psscriptroot\$OutputFile"

0 commit comments

Comments
 (0)