Skip to content

Commit 3ebff3b

Browse files
authored
Get-Vc CA, Set-Vc template (#382)
1 parent 122b378 commit 3ebff3b

File tree

110 files changed

+739
-424
lines changed

Some content is hidden

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

110 files changed

+739
-424
lines changed

RELEASE.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
- Add `Get-VdcCertificate -IncludeStatus` to include `Status` and `StatusText` properties in the response. These correspond to the Certificate Status as seen in the WebAdmin Certificate -> Summary tab.
2-
- Add `Export-VcReport` to export a Certificate Manager SaaS custom report either to a file or pipeline as a pscustomobject.
3-
- Final round of VenafiSession improvements. All advanced use cases, eg. pipe from one environment to another, are now working across ps5/ps7 and parallel processing or not.
1+
- Add `Set-VcIssuingTemplate` to update template settings. This is super helpful if you want to change the CA associated with your templates in bulk. Currently, CA product options are supported with additional product details to be supported in the future.
2+
- Add `Get-VcIssuingTemplate -CertificateAuthority` to retrieve templates for a specific CA
3+
- Add `Get-VcCertificateAuthority` and associated `Get-VcData -Type 'CertificateAuthority'`
4+
- Rename TLSPDC/TLSPC to Certificate Manager Self-Hosted/SaaS in documentation/help
5+
- Add `Get-ThreadJobAvailability` to look for and load module on demand and only PSv5 when using `Invoke-VenafiParallel`. This should slightly enhance module load speed and parallel processing on PSv7.

Tests/New-VenafiSession.Tests.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ BeforeAll {
44
}
55
Describe 'New-VenafiSession' {
66
BeforeAll {
7+
# not a real api key. made up for unit testing.
78
$cred = New-Object System.Management.Automation.PSCredential('AccessToken', ('9655b66c-8e5e-4b2b-b43e-edfa33b70e5f' | ConvertTo-SecureString -AsPlainText -Force))
89
}
9-
Context 'TLSPC key' {
10+
Context 'Certificate Manager, SaaS key' {
1011
# BeforeAll {
1112
# Mock New-VenafiSession -MockWith {
1213
# $newSession = [VenafiSession] @{
@@ -18,8 +19,8 @@ Describe 'New-VenafiSession' {
1819
# }
1920
# $sess = New-VenafiSession -VaasKey $cred -PassThru
2021
# }
21-
# It 'should set platform to TLSPC' {
22-
# $sess.Platform | Should -Be 'TLSPC'
22+
# It 'should set platform to Certificate Manager, SaaS' {
23+
# $sess.Platform | Should -Be 'Certificate Manager, SaaS'
2324
# }
2425
# It 'should set AuthType to Key' {
2526
# $sess.AuthType | Should -Be 'Key'

VenafiPS/Private/Find-VcObject.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
function Find-VcObject {
22
<#
33
.SYNOPSIS
4-
Find different objects on TLSPC
4+
Find different objects on Certificate Manager, SaaS
55
66
.DESCRIPTION
7-
Find objects of type ActivityLog, Machine, MachineIdentity, CertificateRequest, CertificateInstance on TLSPC.
7+
Find objects of type ActivityLog, Machine, MachineIdentity, CertificateRequest, CertificateInstance on Certificate Manager, SaaS.
88
Supports -First for page size; the max page size is 1000.
99
To find certificate objects, use Find-VcCertificate.
1010
@@ -32,7 +32,7 @@ function Find-VcObject {
3232
.PARAMETER VenafiSession
3333
Authentication for the function.
3434
The value defaults to the script session object $VenafiSession created by New-VenafiSession.
35-
A TLSPC key can also provided.
35+
A Certificate Manager, SaaS key can also provided.
3636
3737
.OUTPUTS
3838
PSCustomObject
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function Get-ThreadJobAvailability {
2+
if ($null -eq $script:ThreadJobAvailable) {
3+
$script:ThreadJobAvailable = ($null -ne (Get-Module -Name Microsoft.PowerShell.ThreadJob -ListAvailable))
4+
}
5+
return $script:ThreadJobAvailable
6+
}

VenafiPS/Private/Get-VcData.ps1

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Get-VcData {
1919
[string] $InputObject,
2020

2121
[parameter(Mandatory)]
22-
[ValidateSet('Application', 'VSatellite', 'Certificate', 'IssuingTemplate', 'Team', 'Machine', 'Tag', 'Plugin', 'Credential', 'Algorithm', 'User', 'CloudProvider', 'CloudKeystore')]
22+
[ValidateSet('Application', 'VSatellite', 'Certificate', 'IssuingTemplate', 'Team', 'Machine', 'Tag', 'Plugin', 'Credential', 'Algorithm', 'User', 'CloudProvider', 'CloudKeystore', 'CertificateAuthority')]
2323
[string] $Type,
2424

2525
[parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'Name')]
@@ -168,6 +168,24 @@ function Get-VcData {
168168
break
169169
}
170170

171+
'CertificateAuthority' {
172+
if ( -not $script:vcCertificateAuthority ) {
173+
$script:vcCertificateAuthority = Get-VcCertificateAuthority -All | Sort-Object -Property name
174+
$latest = $true
175+
}
176+
177+
$allObject = $script:vcCertificateAuthority
178+
179+
if ( $InputObject ) {
180+
$thisObject = $allObject | Where-Object { $InputObject -in $_.name, $_.certificateAuthorityId }
181+
if ( -not $thisObject -and -not $latest ) {
182+
$script:vcCertificateAuthority = Get-VcCertificateAuthority -All | Sort-Object -Property name
183+
$thisObject = $script:vcCertificateAuthority | Where-Object { $InputObject -in $_.name, $_.certificateAuthorityId }
184+
}
185+
}
186+
break
187+
}
188+
171189
'Credential' {
172190
if ( -not $script:vcCredential ) {
173191
$script:vcCredential = Invoke-VenafiRestMethod -UriLeaf "credentials" |

VenafiPS/Private/Get-VenafiSession.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ function Get-VenafiSession {
2626
}
2727
# elseif ( $env:VDC_TOKEN ) {
2828
# $env:VDC_TOKEN
29-
# Write-Debug 'Using TLSPDC token environment variable'
29+
# Write-Debug 'Using Certificate Manager, Self-Hosted token environment variable'
3030
# }
3131
# elseif ( $env:VC_KEY ) {
3232
# $env:VC_KEY
33-
# Write-Debug 'Using TLSPC key environment variable'
33+
# Write-Debug 'Using Certificate Manager, SaaS key environment variable'
3434
# }
3535
else {
36-
throw [System.ArgumentException]::new('Please run New-VenafiSession or provide a TLSPC key or TLSPDC token to -VenafiSession.')
36+
throw [System.ArgumentException]::new('Please run New-VenafiSession or provide a Certificate Manager, SaaS key or Certificate Manager, Self-Hosted token to -VenafiSession.')
3737
}
3838

3939
# find out the platform from the calling function

VenafiPS/Private/Invoke-VenafiParallel.ps1

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ function Invoke-VenafiParallel {
7777

7878
# if ThreadJob module is not available, throttle to 1 so multithreading isn't used
7979
if ( $PSVersionTable.PSVersion.Major -eq 5 ) {
80-
if ( -not $script:ThreadJobAvailable ) {
81-
$goParallel = $false
82-
}
80+
$goParallel = Get-ThreadJobAvailability
8381
}
8482

8583
# no need for parallel processing overhead if just processing a few
@@ -133,7 +131,8 @@ function Invoke-VenafiParallel {
133131
# import via path instead of just module name to support non-standard paths, eg. development work
134132

135133
# ParallelImportPath is set during module import
136-
Import-Module $using:script:ParallelImportPath -Force
134+
# bypass is skipping items in psm1 that aren't needed during parallel processing
135+
Import-Module $using:script:ParallelImportPath -Force -ArgumentList 'bypass'
137136

138137
# bring in the venafi session from the calling ps session
139138
$script:VenafiSession = $using:VenafiSession

VenafiPS/Private/Test-VenafiSession.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function Test-VenafiSession {
44
Validate authentication session/key/token
55
66
.DESCRIPTION
7-
Validate authentication session from New-VenafiSession, a TLSPC key, or TLSPDC token.
7+
Validate authentication session from New-VenafiSession, a Certificate Manager, SaaS key, or Certificate Manager, Self-Hosted token.
88
99
.PARAMETER InvocationInfo
1010
InvocationInfo from calling function
@@ -56,15 +56,15 @@ function Test-VenafiSession {
5656
$VenafiSession = $script:VenafiSession
5757
}
5858
else {
59-
throw 'Please run New-VenafiSession or provide a TLSPC key or TLSPDC token.'
59+
throw 'Please run New-VenafiSession or provide a Certificate Manager, SaaS key or Certificate Manager, Self-Hosted token.'
6060
}
6161
}
6262

6363
switch ($VenafiSession.GetType().Name) {
6464
'PSCustomObject' {
6565

6666
if ( -not $VenafiSession.Key -and -not $VenafiSession.Token ) {
67-
throw "You must first connect to either TLSPC or a TLSPDC server with New-VenafiSession"
67+
throw "You must first connect to either Certificate Manager, SaaS or a Certificate Manager, Self-Hosted server with New-VenafiSession"
6868
}
6969

7070
# make sure the auth type and url we have match
@@ -75,7 +75,7 @@ function Test-VenafiSession {
7575

7676
if ( $Platform -eq 'VDC' ) {
7777
if ( $VenafiSession.Token.Expires -and $VenafiSession.Token.Expires -lt (Get-Date).ToUniversalTime() ) {
78-
throw 'TLSPDC token has expired. Execute New-VenafiSession and rerun your command.'
78+
throw 'Certificate Manager, Self-Hosted token has expired. Execute New-VenafiSession and rerun your command.'
7979
}
8080
}
8181

@@ -93,7 +93,7 @@ function Test-VenafiSession {
9393
}
9494

9595
Default {
96-
throw "Unknown session '$VenafiSession'. Please run New-VenafiSession or provide a TLSPC key or TLSPDC access token."
96+
throw "Unknown session '$VenafiSession'. Please run New-VenafiSession or provide a Certificate Manager, SaaS key or Certificate Manager, Self-Hosted access token."
9797
}
9898
}
9999

VenafiPS/Public/Add-VcTeamMember.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function Add-VcTeamMember {
44
Add members to a team
55
66
.DESCRIPTION
7-
Add members to a TLSPC team
7+
Add members to a Certificate Manager, SaaS team
88
99
.PARAMETER Team
1010
Team ID or name to add to
@@ -15,15 +15,15 @@ function Add-VcTeamMember {
1515
.PARAMETER VenafiSession
1616
Authentication for the function.
1717
The value defaults to the script session object $VenafiSession created by New-VenafiSession.
18-
A TLSPC key can also provided.
18+
A Certificate Manager, SaaS key can also provided.
1919
2020
.INPUTS
2121
Team
2222
2323
.EXAMPLE
2424
Add-VcTeamMember -ID 'ca7ff555-88d2-4bfc-9efa-2630ac44c1f2' -Member @('ca7ff555-88d2-4bfc-9efa-2630ac44c1f3', 'ca7ff555-88d2-4bfc-9efa-2630ac44c1f4')
2525
26-
Add members to a TLSPC team
26+
Add members to a Certificate Manager, SaaS team
2727
2828
#>
2929

VenafiPS/Public/Add-VcTeamOwner.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function Add-VcTeamOwner {
44
Add owners to a team
55
66
.DESCRIPTION
7-
Add owners to a TLSPC team
7+
Add owners to a Certificate Manager, SaaS team
88
99
.PARAMETER Team
1010
Team ID or name
@@ -16,7 +16,7 @@ function Add-VcTeamOwner {
1616
.PARAMETER VenafiSession
1717
Authentication for the function.
1818
The value defaults to the script session object $VenafiSession created by New-VenafiSession.
19-
A TLSPC key can also provided.
19+
A Certificate Manager, SaaS key can also provided.
2020
2121
.INPUTS
2222
Team

0 commit comments

Comments
 (0)