From 2b515e363159221d5bdfe7b7acacfc8cd4ca33c7 Mon Sep 17 00:00:00 2001 From: Florian Hopfner Date: Sun, 28 Jan 2024 12:00:18 +0000 Subject: [PATCH 1/3] Add parameter types and validation in Import-D365RsatSelfServiceCertificates function --- .../import-d365rsatselfservicecertificates.ps1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/d365fo.tools/functions/import-d365rsatselfservicecertificates.ps1 b/d365fo.tools/functions/import-d365rsatselfservicecertificates.ps1 index f44960dd..f1f33b56 100644 --- a/d365fo.tools/functions/import-d365rsatselfservicecertificates.ps1 +++ b/d365fo.tools/functions/import-d365rsatselfservicecertificates.ps1 @@ -1,4 +1,4 @@ - + <# .SYNOPSIS Import certificates for RSAT @@ -39,13 +39,15 @@ function Import-D365RsatSelfServiceCertificates { param ( [Parameter( Mandatory = $true, - ValueFromPipelineByPropertyName)] - $Path, + ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [string] $Path, [Parameter( Mandatory = $true, - ValueFromPipelineByPropertyName)] - $Password + ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [string] $Password ) begin { From 7e8b6963b6b638e2d12776e77ef02b817e0f9084 Mon Sep 17 00:00:00 2001 From: Florian Hopfner Date: Sun, 28 Jan 2024 12:01:24 +0000 Subject: [PATCH 2/3] Move begin logic to process block to enable pipelining parameters --- .../import-d365rsatselfservicecertificates.ps1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/d365fo.tools/functions/import-d365rsatselfservicecertificates.ps1 b/d365fo.tools/functions/import-d365rsatselfservicecertificates.ps1 index f1f33b56..7b107eb9 100644 --- a/d365fo.tools/functions/import-d365rsatselfservicecertificates.ps1 +++ b/d365fo.tools/functions/import-d365rsatselfservicecertificates.ps1 @@ -1,4 +1,4 @@ - + <# .SYNOPSIS Import certificates for RSAT @@ -51,12 +51,14 @@ function Import-D365RsatSelfServiceCertificates { ) begin { - [Security.SecureString] $PasswordSecure = (ConvertTo-SecureString -String $Password -Force -AsPlainText) - - if (-not (Test-PathExists -Path $Path -Type Container)) { return } + } process { + [Security.SecureString] $PasswordSecure = (ConvertTo-SecureString -String $Password -Force -AsPlainText) + + if (-not (Test-PathExists -Path $Path -Type Container)) { return } + if (Test-PSFFunctionInterrupt) { return } $pathCertFile = (Get-ChildItem -Path "$Path\*.cer" | Select-Object -First 1).FullName From 058101614bf248a8f8f519d97eb3fd111654fb1b Mon Sep 17 00:00:00 2001 From: FH-Inway Date: Sun, 28 Jan 2024 12:04:26 +0000 Subject: [PATCH 3/3] 'Update comment based help and tests This pull request was automatically created by the d365fo.tools-Generate-Text action' --- .../Import-D365RsatSelfServiceCertificates.Tests.ps1 | 4 ++-- docs/Import-D365RsatSelfServiceCertificates.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/d365fo.tools/tests/functions/Import-D365RsatSelfServiceCertificates.Tests.ps1 b/d365fo.tools/tests/functions/Import-D365RsatSelfServiceCertificates.Tests.ps1 index c9aca0d7..a12bc07d 100644 --- a/d365fo.tools/tests/functions/Import-D365RsatSelfServiceCertificates.Tests.ps1 +++ b/d365fo.tools/tests/functions/Import-D365RsatSelfServiceCertificates.Tests.ps1 @@ -14,7 +14,7 @@ It 'Should have the expected parameter Path' { $parameter = (Get-Command Import-D365RsatSelfServiceCertificates).Parameters['Path'] $parameter.Name | Should -Be 'Path' - $parameter.ParameterType.ToString() | Should -Be System.Object + $parameter.ParameterType.ToString() | Should -Be System.String $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets' $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets' @@ -27,7 +27,7 @@ It 'Should have the expected parameter Password' { $parameter = (Get-Command Import-D365RsatSelfServiceCertificates).Parameters['Password'] $parameter.Name | Should -Be 'Password' - $parameter.ParameterType.ToString() | Should -Be System.Object + $parameter.ParameterType.ToString() | Should -Be System.String $parameter.IsDynamic | Should -Be $False $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets' $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets' diff --git a/docs/Import-D365RsatSelfServiceCertificates.md b/docs/Import-D365RsatSelfServiceCertificates.md index e038b099..13dc3c54 100644 --- a/docs/Import-D365RsatSelfServiceCertificates.md +++ b/docs/Import-D365RsatSelfServiceCertificates.md @@ -13,7 +13,7 @@ Import certificates for RSAT ## SYNTAX ``` -Import-D365RsatSelfServiceCertificates [-Path] [-Password] [] +Import-D365RsatSelfServiceCertificates [-Path] [-Password] [] ``` ## DESCRIPTION @@ -44,7 +44,7 @@ Path to the folder where the .cer and .pxf files are located The files needs to be extracted from the zip archive ```yaml -Type: Object +Type: String Parameter Sets: (All) Aliases: @@ -61,7 +61,7 @@ Password for the .pxf file Working with self-service environments, the password will be displayed during the download of the zip archive ```yaml -Type: Object +Type: String Parameter Sets: (All) Aliases: