Repository navigation
Fix parameter variable name conflict #927 #928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a703db0
d4df6f4
63b15a9
5321278
4e01d21
d6308ce
32f317f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -379,4 +379,4 @@ function Import-D365Bacpac { | |
| } | ||
|
|
||
| Invoke-TimeSignal -End | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,4 +197,4 @@ function Invoke-D365AzCopyTransfer { | |
|
|
||
| Invoke-TimeSignal -End | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -352,4 +352,4 @@ function New-D365Bacpac { | |
| } | ||
|
|
||
| Invoke-TimeSignal -End | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -263,4 +263,4 @@ function Repair-D365BacpacModelFile { | |
|
|
||
| Invoke-TimeSignal -End | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,15 @@ | |
| "IIS" | ||
| "IISExpress" | ||
|
|
||
| .PARAMETER Confirm | ||
| Switch parameter to require confirmation before making changes. | ||
|
|
||
| .PARAMETER WhatIf | ||
| Switch parameter to show what would happen if the cmdlet runs, without making any changes. | ||
|
|
||
| .PARAMETER Force | ||
| Switch parameter to force the operation without confirmation. | ||
|
|
||
| .EXAMPLE | ||
| PS C:\> Set-D365WebServerType -RuntimeHostType "IIS" | ||
|
|
||
|
|
@@ -30,20 +39,25 @@ | |
| Tag: Web Server, IIS, IIS Express, Development | ||
|
|
||
| Author: Sander Holvoet (@smholvoet) | ||
|
|
||
| Author: Mötz Jensen (@Splaxi) | ||
| Author: Florian Hopfner (@FH-Inway) | ||
| #> | ||
|
|
||
| function Set-D365WebServerType { | ||
| [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")] | ||
| [CmdletBinding()] | ||
| [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] | ||
| param ( | ||
| [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)] | ||
| [ValidateSet('IIS', 'IISExpress')] | ||
| [string] $RuntimeHostType | ||
| [string] $RuntimeHostType, | ||
|
|
||
| [switch] $Force | ||
| ) | ||
|
|
||
| begin { | ||
| if ($Force -and -not $PSBoundParameters.ContainsKey('Confirm')) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. didn't we have this discussion once? That contains would fire if -Confirm:$false? We should be able to have it be simpler with $Confirm I'm not entirely sure
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Splaxi In any case, since the |
||
| $ConfirmPreference = 'None' | ||
| } | ||
|
|
||
| if (-not ($script:IsAdminRuntime)) { | ||
| Write-PSFMessage -Level Host -Message "The cmdlet needs <c='em'>administrator permission</c> (Run As Administrator) to be able to update the configuration. Please start an <c='em'>elevated</c> session and run the cmdlet again." | ||
| Stop-PSFFunction -Message "Stopping because the function is not run elevated" | ||
|
|
@@ -58,20 +72,22 @@ function Set-D365WebServerType { | |
| process { | ||
| if (Test-PSFFunctionInterrupt) { return } | ||
|
|
||
| $filePathBackup = $filePath.Replace(".xml", ".xml$((Get-Date).Ticks)") | ||
| Copy-Item -Path $filePath -Destination $filePathBackup -Force | ||
| if ($PSCmdlet.ShouldProcess($filePath, "Set web server type to '$RuntimeHostType'")) { | ||
| $filePathBackup = $filePath.Replace(".xml", ".xml$((Get-Date).Ticks)") | ||
| Copy-Item -Path $filePath -Destination $filePathBackup -Force | ||
|
|
||
| $namespace = @{ns = "http://schemas.microsoft.com/dynamics/2012/03/development/configuration" } | ||
| $namespace = @{ns = "http://schemas.microsoft.com/dynamics/2012/03/development/configuration" } | ||
|
|
||
| $xmlDoc = [xml] (Get-Content -Path $filePath) | ||
| $runtimeHostType = Select-Xml -Xml $xmlDoc -XPath "/ns:DynamicsDevConfig/ns:RuntimeHostType" -Namespace $namespace | ||
| $xmlDoc = [xml] (Get-Content -Path $filePath) | ||
| $runtimeHostTypeNode = Select-Xml -Xml $xmlDoc -XPath "/ns:DynamicsDevConfig/ns:RuntimeHostType" -Namespace $namespace | ||
|
|
||
| $oldValue = $runtimeHostType.Node.InnerText | ||
| $oldValue = $runtimeHostTypeNode.Node.InnerText | ||
|
|
||
| Write-PSFMessage -Level Verbose -Message "Old value found in the file was: $oldValue" -Target $oldValue | ||
| Write-PSFMessage -Level Verbose -Message "Old value found in the file was: $oldValue" -Target $oldValue | ||
|
|
||
| $runtimeHostType.Node.InnerText = $RuntimeHostType | ||
| $xmlDoc.Save($filePath) | ||
| $runtimeHostTypeNode.Node.InnerText = $RuntimeHostType | ||
| $xmlDoc.Save($filePath) | ||
| } | ||
| } | ||
|
|
||
| end { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,4 +152,4 @@ function Invoke-Process { | |
| ExitCode = $p.ExitCode | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,4 +92,4 @@ function Test-PathExists { | |
| } | ||
|
|
||
| $res | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would "hate" that we would have to have documentation for all 3 standard parameter, across all cmdlets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FH-Inway - If we could settle without these, at least over time - then I'm happy.
We'll have to face what operations / actions should be medium or high - so people can accept things, without having to manage Confirm.
If we start with low - then all people will have non-breaking changes, while you can set "low" on your profile and you will be prompted.
Then over time, we can gradually promote different functions / cmdlets, to different levels.