-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleInitHelpers.ps1
More file actions
60 lines (52 loc) · 1.58 KB
/
Copy pathModuleInitHelpers.ps1
File metadata and controls
60 lines (52 loc) · 1.58 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
function Test-IsAdmin
{
$currentIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object System.Security.Principal.WindowsPrincipal($currentIdentity)
return $principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
}
function Test-PandocInstalled {
[CmdletBinding()]
[OutputType([bool])]
param()
try {
$null = Get-Command pandoc -ErrorAction Stop
Write-Verbose "Pandoc is installed and available in PATH"
return $true
}
catch {
Write-Verbose "Pandoc is not installed or not available in PATH"
return $false
}
}
function Test-ChocolateyInstalled {
[CmdletBinding()]
[OutputType([bool])]
param()
try {
$null = Get-Command choco -ErrorAction Stop
Write-Verbose "Chocolatey is installed and available in PATH"
return $true
}
catch {
Write-Verbose "Chocolatey is not installed or not available in PATH"
return $false
}
}
function Install-PandocWithChocolatey {
[CmdletBinding()]
param()
Write-Information "Installing Pandoc using Chocolatey..."
try {
$process = Start-Process choco -ArgumentList "install", "pandoc", "-y" -NoNewWindow -Wait -PassThru
if ($process.ExitCode -eq 0) {
Write-Information "Pandoc installation completed successfully."
Write-Information "You may need to restart your PowerShell session for Pandoc to be available in PATH."
}
else {
Write-Error "Pandoc installation failed with exit code: $($process.ExitCode)"
}
}
catch {
Write-Error "Failed to install Pandoc: $($_.Exception.Message)"
}
}