Skip to content

Commit 0f631c0

Browse files
updates
1 parent 1cee6bf commit 0f631c0

30 files changed

+1160
-286
lines changed

PSModuleDevelopment/PSModuleDevelopment.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
RootModule = 'PSModuleDevelopment.psm1'
55

66
# Version number of this module.
7-
ModuleVersion = '2.2.10.134'
7+
ModuleVersion = '2.2.11.138'
88

99
# ID used to uniquely identify this module
1010
GUID = '37dd5fce-e7b5-4d57-ac37-832055ce49d6'

PSModuleDevelopment/changelog.md

Lines changed: 175 additions & 147 deletions
Large diffs are not rendered by default.

PSModuleDevelopment/functions/utility/Restart-PSMDShell.ps1

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
function Restart-PSMDShell
2-
{
3-
<#
1+
function Restart-PSMDShell {
2+
<#
43
.SYNOPSIS
54
A swift way to restart the PowerShell console.
65
@@ -33,13 +32,8 @@
3332
PS C:\> Restart-PSMDShell -Admin -NoExit
3433
3534
Creates a new PowerShell process, run with elevation, while keeping the current console around.
36-
37-
.NOTES
38-
Version 1.0.0.0
39-
Author: Friedrich Weinmann
40-
Created on: August 6th, 2016
4135
#>
42-
[Alias('rss', 'Restart-Shell')]
36+
[Alias('rss', 'Restart-Shell')]
4337
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')]
4438
Param (
4539
[Switch]
@@ -52,25 +46,36 @@
5246
$NoProfile
5347
)
5448

55-
begin
56-
{
57-
$powershellPath = (Get-Process -id $pid).Path
49+
begin {
50+
$process = Get-Process -Id $pid
51+
$powershellPath = $process.Path
52+
$isWindowsTerminal = $process.Parent.ProcessName -eq 'WindowsTerminal'
5853
}
59-
process
60-
{
61-
if ($PSCmdlet.ShouldProcess("Current shell", "Restart"))
62-
{
63-
if ($NoProfile)
64-
{
65-
if ($Admin) { Start-Process $powershellPath -Verb RunAs -ArgumentList '-NoProfile' }
66-
else { Start-Process $powershellPath -ArgumentList '-NoProfile' }
54+
process {
55+
if (-not $PSCmdlet.ShouldProcess("Current shell", "Restart")) { return }
56+
57+
if ($isWindowsTerminal) {
58+
$psVersionName = 'powershell'
59+
if ($PSVersionTable.PSVersion.Major -gt 5) { $psVersionName = 'pwsh' }
60+
61+
$param = @{
62+
FilePath = 'wt'
63+
ArgumentList = @('-w', 0, 'nt','--title', $psVersionName, $powershellPath)
6764
}
68-
else
69-
{
70-
if ($Admin) { Start-Process $powershellPath -Verb RunAs }
71-
else { Start-Process $powershellPath }
65+
if ($NoProfile) { $param.ArgumentList = @('-w', 0, 'nt', '--title', $psVersionName, $powershellPath, '-NoProfile') }
66+
if ($Admin) { $param.Verb = 'RunAs' }
67+
Start-Process @param
68+
}
69+
else {
70+
$param = @{
71+
FilePath = $powershellPath
7272
}
73-
if (-not $NoExit) { exit }
73+
if ($NoProfile) { $param.ArgumentList = '-NoProfile' }
74+
if ($Admin) { $param.Verb = 'RunAs' }
75+
Start-Process @param
7476
}
7577
}
78+
end {
79+
if (-not $NoExit) { exit }
80+
}
7681
}

templates/AzureFunction/function/profile.ps1

Lines changed: 1 addition & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -18,115 +18,4 @@ if ($env:MSI_SECRET -and (Get-Module -ListAvailable Az.Accounts))
1818

1919
# Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
2020
# Enable-AzureRmAlias
21-
# You can also define functions or aliases that can be referenced in any of your PowerShell functions.
22-
23-
function Write-FunctionResult {
24-
<#
25-
.SYNOPSIS
26-
Reports back the output / result of the function app.
27-
28-
.DESCRIPTION
29-
Reports back the output / result of the function app.
30-
31-
.PARAMETER Status
32-
Whether the function succeeded or not.
33-
34-
.PARAMETER Body
35-
Any data to include in the response.
36-
37-
.EXAMPLE
38-
PS C:\> Write-FunctionResult -Status OK -Body $newUser
39-
40-
Reports success while returning the content of $newUser as output
41-
#>
42-
[CmdletBinding()]
43-
param (
44-
[Parameter(Mandatory = $true)]
45-
[System.Net.HttpStatusCode]
46-
$Status,
47-
48-
[AllowNull()]
49-
$Body
50-
)
51-
52-
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
53-
StatusCode = $Status
54-
Body = $Body
55-
})
56-
}
57-
58-
function Get-RestParameterValue {
59-
<#
60-
.SYNOPSIS
61-
Extract the exact value of a parameter provided by the user.
62-
63-
.DESCRIPTION
64-
Extract the exact value of a parameter provided by the user.
65-
Expects either query or body parameters from the rest call to the http trigger.
66-
67-
.PARAMETER Request
68-
The request object provided as part of the function call.
69-
70-
.PARAMETER Name
71-
The name of the parameter to provide.
72-
73-
.EXAMPLE
74-
PS C:\> Get-RestParameterValue -Request $Request -Name Type
75-
76-
Returns the value of the parameter "Type", as provided by the caller
77-
#>
78-
[CmdletBinding()]
79-
param (
80-
[Parameter(Mandatory = $true)]
81-
$Request,
82-
83-
[Parameter(Mandatory = $true)]
84-
[string]
85-
$Name
86-
)
87-
88-
if ($Request.Query.$Name) {
89-
return $Request.Query.$Name
90-
}
91-
$Request.Body.$Name
92-
}
93-
94-
function Get-RestParameter {
95-
<#
96-
.SYNOPSIS
97-
Parses the rest request parameters for all values matching parameters on the specified command.
98-
99-
.DESCRIPTION
100-
Parses the rest request parameters for all values matching parameters on the specified command.
101-
Returns a hashtable ready for splatting.
102-
Does NOT assert mandatory parameters are specified, so command invocation may fail.
103-
104-
.PARAMETER Request
105-
The original rest request object, containing the caller's information such as parameters.
106-
107-
.PARAMETER Command
108-
The command to which to bind input parameters.
109-
110-
.EXAMPLE
111-
PS C:\> Get-RestParameter -Request $Request -Command Get-AzUser
112-
113-
Retrieves all parameters on the incoming request that match a parameter on Get-AzUser
114-
#>
115-
[CmdletBinding()]
116-
Param (
117-
[Parameter(Mandatory = $true)]
118-
$Request,
119-
120-
[Parameter(Mandatory = $true)]
121-
[string]
122-
$Command
123-
)
124-
125-
$commandInfo = Get-Command -Name $Command
126-
$results = @{ }
127-
foreach ($parameter in $commandInfo.Parameters.Keys) {
128-
$value = Get-RestParameterValue -Request $Request -Name $parameter
129-
if ($null -ne $value) { $results[$parameter] = $value }
130-
}
131-
$results
132-
}
21+
# You can also define functions or aliases that can be referenced in any of your PowerShell functions.
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
@{
2-
Az = '1.*'
2+
# Do you really need ALL of the AZ modules?
3+
# Az = '1.*'
4+
5+
# If you only need Key Vault access, this is your choice
6+
# 'Az.KeyVault' = '4.*'
7+
8+
# Basic tools used in your function app
9+
'Azure.Function.Tools' = '1.*'
310
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github:
4+
FriedrichWeinmann
5+
patreon: # Replace with a single Patreon username
6+
open_collective: # Replace with a single Open Collective username
7+
ko_fi: # Replace with a single Ko-fi username
8+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
9+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
10+
liberapay: # Replace with a single Liberapay username
11+
issuehunt: # Replace with a single IssueHunt username
12+
otechie: # Replace with a single Otechie username
13+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
6+
jobs:
7+
build:
8+
9+
runs-on: windows-2019
10+
11+
steps:
12+
- uses: actions/checkout@v1
13+
- name: Install Prerequisites
14+
run: .\build\vsts-prerequisites.ps1
15+
shell: powershell
16+
- name: Validate
17+
run: .\build\vsts-validate.ps1
18+
shell: powershell
19+
- name: Build
20+
run: .\build\vsts-build.ps1 -ApiKey $env:APIKEY
21+
shell: powershell
22+
env:
23+
APIKEY: ${{ secrets.ApiKey }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
on: [pull_request]
2+
3+
jobs:
4+
validate:
5+
6+
runs-on: windows-2019
7+
8+
steps:
9+
- uses: actions/checkout@v1
10+
- name: Install Prerequisites
11+
run: .\build\vsts-prerequisites.ps1
12+
shell: powershell
13+
- name: Validate
14+
run: .\build\vsts-validate.ps1
15+
shell: powershell

templates/MiniModule/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) þ!year!þ þauthorþ
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

templates/MiniModule/PSMDInvoke.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
param (
2+
$Path
3+
)
4+
New-PSMDTemplate -ReferencePath "$PSScriptRoot" -OutPath $Path

0 commit comments

Comments
 (0)