-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemove-TriliumBranch.ps1
More file actions
69 lines (59 loc) · 2.04 KB
/
Copy pathRemove-TriliumBranch.ps1
File metadata and controls
69 lines (59 loc) · 2.04 KB
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
function Remove-TriliumBranch {
<#
.SYNOPSIS
Removes a specific Trilium branch.
.DESCRIPTION
This function removes a specific Trilium branch based on the provided branch ID.
.PARAMETER BranchID
The branch ID to remove.
Required? true
Position? 0
Default value None
Accept pipeline input? false
Accept wildcard characters? false
.PARAMETER SkipCertCheck
Option to skip certificate check.
Required? false
Position? Named
Default value None
Accept pipeline input? false
Accept wildcard characters? false
.EXAMPLE
Remove-TriliumBranch -BranchID "A2PGuqZgT03z_sxhoPPMkVIuO"
.NOTES
This function requires that the authentication has been set using Connect-TriliumAuth.
.LINK
https://github.com/ptmorris1/TriliumNext-Powershell-Module
#>
[CmdletBinding(SupportsShouldProcess = $true)]
param (
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string]$BranchID,
[switch]$SkipCertCheck
)
process {
try {
if ($SkipCertCheck -eq $true) {
$PSDefaultParameterValues = @{'Invoke-RestMethod:SkipCertificateCheck' = $true }
}
$TriliumHeaders = @{}
$TriliumHeaders.Add('Authorization', "$($TriliumCreds.Authorization)")
# API call run
try {
$uri = "$($TriliumCreds.URL)/branches/$BranchID"
if ($PSCmdlet.ShouldProcess($uri, 'Removing branch')) {
Invoke-RestMethod -Uri $uri -Headers $TriliumHeaders -SkipHeaderValidation -Method Delete
}
} catch {
$_.Exception.Response
}
} catch {
$_.Exception.Response
}
}
begin {
if (!$global:TriliumCreds) { Write-Error -Message 'Need to run: Connect-TriliumAuth'; exit }
}
end {
return
}
}