Update install_obsidian.ps1

This commit is contained in:
Quinta
2024-06-09 01:33:52 +02:00
committed by GitHub
parent 54b503595f
commit 0df28b7f82
+11
View File
@@ -1,5 +1,10 @@
# PowerShell script to install Obsidian and configure plugins on Windows # PowerShell script to install Obsidian and configure plugins on Windows
function Test-Administrator {
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
return $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
function Install-Obsidian-Windows { function Install-Obsidian-Windows {
Write-Output "Installing Obsidian for Windows..." Write-Output "Installing Obsidian for Windows..."
if (-Not (Get-Command choco -ErrorAction SilentlyContinue)) { if (-Not (Get-Command choco -ErrorAction SilentlyContinue)) {
@@ -66,6 +71,12 @@ function Install-Plugins {
Write-Output "Plugins installed successfully." Write-Output "Plugins installed successfully."
} }
if (-Not (Test-Administrator)) {
Write-Output "This script needs to be run as an administrator. Re-launching with elevated privileges..."
Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
# Directly run Windows installation and plugin configuration # Directly run Windows installation and plugin configuration
Install-Obsidian-Windows Install-Obsidian-Windows
Install-Plugins Install-Plugins