/
Get-VdcObject.ps1
81 lines (61 loc) · 2.02 KB
/
Get-VdcObject.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function Get-VdcObject {
<#
.SYNOPSIS
Get object information
.DESCRIPTION
Return object information by either path or guid. This will return a TppObject which can be used with many other functions.
.PARAMETER Path
The full path to the object.
\ved\policy will be automatically applied if a full path isn't provided.
.PARAMETER Guid
Guid of the object
.PARAMETER VenafiSession
Authentication for the function.
The value defaults to the script session object $VenafiSession created by New-VenafiSession.
A TLSPDC token can also be provided.
If providing a TLSPDC token, an environment variable named VDC_SERVER must also be set.
.INPUTS
Path, Guid
.OUTPUTS
PSCustomObject
.EXAMPLE
Get-VdcObject -Path '\VED\Policy\My object'
Get an object by path
.EXAMPLE
[guid]'dab22152-0a81-4fb8-a8da-8c5e3d07c3f1' | Get-VdcObject
Get an object by guid
.LINK
http://VenafiPS.readthedocs.io/en/latest/functions/Get-VdcObject/
.LINK
https://github.com/Venafi/VenafiPS/blob/main/VenafiPS/Public/Get-VdcObject.ps1
#>
[CmdletBinding()]
[Alias('Get-TppObject', 'gvdo')]
param (
[Parameter(Mandatory, ParameterSetName = 'ByPath', ValueFromPipeline, ValueFromPipelineByPropertyName, Position = 0)]
[ValidateNotNullOrEmpty()]
[Alias('DN')]
[String[]] $Path,
[Parameter(Mandatory, ParameterSetName = 'ByGuid', ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[Alias('ObjectGuid')]
[guid[]] $Guid,
[Parameter()]
[psobject] $VenafiSession
)
begin {
Test-VenafiSession -VenafiSession $VenafiSession -Platform 'VDC'
}
process {
if ( $PSCmdLet.ParameterSetName -eq 'ByPath' ) {
$Path | ConvertTo-VdcFullPath | ForEach-Object {
ConvertTo-VdcObject -Path $_
}
}
else {
$Guid | ForEach-Object {
ConvertTo-VdcObject -Guid $_
}
}
}
}