From 5d930e5eb85cdba288aea2cbecc4dfd2f699b5cb Mon Sep 17 00:00:00 2001 From: James Ruskin Date: Fri, 22 Mar 2024 08:35:27 +0000 Subject: [PATCH] (#160) Brings Set-*Cert Scripts Into Consistancy Adds an argument completer for thumbprint, standardises on Thumbprint and Port as arguments. --- scripts/Set-CCMCert.ps1 | 15 ++++++++++++--- scripts/Set-JenkinsCert.ps1 | 10 ++++++++++ scripts/Set-NexusCert.ps1 | 14 +++++++++++--- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/scripts/Set-CCMCert.ps1 b/scripts/Set-CCMCert.ps1 index 1ff5c0f..07a2596 100644 --- a/scripts/Set-CCMCert.ps1 +++ b/scripts/Set-CCMCert.ps1 @@ -10,14 +10,23 @@ Thumbprint value of the certificate you would like the Chocolatey Central Manage Please make sure the certificate is located in both the Cert:\LocalMachine\TrustedPeople\ and Cert:\LocalMachine\My certificate stores. .EXAMPLE -PS> .\Set-CCMCert.ps1 -CertificateThumbprint 'Your_Certificate_Thumbprint_Value' +PS> .\Set-CCMCert.ps1 -Thumbprint 'Your_Certificate_Thumbprint_Value' #> [CmdletBinding()] param( [Parameter(Mandatory)] - [String] - $CertificateThumbprint + [ArgumentCompleter({ + Get-ChildItem Cert:\LocalMachine\My | ForEach-Object { + [System.Management.Automation.CompletionResult]::new( + $_.Thumbprint, + $_.Thumbprint, + 'ParameterValue', + $_.FriendlyName + ) + } + })] + [string]$Thumbprint ) begin { diff --git a/scripts/Set-JenkinsCert.ps1 b/scripts/Set-JenkinsCert.ps1 index 0193ae0..e802e23 100644 --- a/scripts/Set-JenkinsCert.ps1 +++ b/scripts/Set-JenkinsCert.ps1 @@ -11,6 +11,16 @@ param( # Thumbprint of the certificate stored in the Trusted People cert-store. [Parameter(Mandatory)] + [ArgumentCompleter({ + Get-ChildItem Cert:\LocalMachine\My | ForEach-Object { + [System.Management.Automation.CompletionResult]::new( + $_.Thumbprint, + $_.Thumbprint, + 'ParameterValue', + $_.FriendlyName + ) + } + })] [string]$Thumbprint, # Port number to use for Jenkins HTTPS. diff --git a/scripts/Set-NexusCert.ps1 b/scripts/Set-NexusCert.ps1 index 4a00397..44cc300 100644 --- a/scripts/Set-NexusCert.ps1 +++ b/scripts/Set-NexusCert.ps1 @@ -12,14 +12,22 @@ Thumbprint value of certificate you want to run Nexus on. Make sure certificate Port you have Nexus configured to run on. .EXAMPLE -PS> .\Set-NexusCert.ps1 -Thumbprint 'Your_Certificate_Thumbprint_Value' -NexusPort 'Port_Number' +PS> .\Set-NexusCert.ps1 -Thumbprint 'Your_Certificate_Thumbprint_Value' -Port 'Port_Number' #> [CmdletBinding()] param( [Parameter(Mandatory)] - [string] - $Thumbprint, + [ArgumentCompleter({ + Get-ChildItem Cert:\LocalMachine\My | ForEach-Object { + [System.Management.Automation.CompletionResult]::new( + $_.Thumbprint, + $_.Thumbprint, + 'ParameterValue', + $_.FriendlyName + ) + } + })] [string]$Thumbprint, [Parameter()]