Revert function text output

This commit is contained in:
2025-02-28 17:27:31 -06:00
parent bcea6127db
commit f5bfd672ff

View File

@@ -181,13 +181,13 @@ Function Import-JSONConfig () {
Return (Get-Content -Raw -Path $ConfigFile | ConvertFrom-Json)
}
Catch {
Write-Output "Error loading config file! Please make sure the correct path was provided, and that it is a properly formatted JSON file" -As Error
Add-LogEntry "Error loading config file! Please make sure the correct path was provided, and that it is a properly formatted JSON file" -As Error
Write-Output $_
Exit 1
}
}
Else {
Write-Output "Error loading config file! Please make sure the correct path was provided, and that it is a properly formatted JSON file" -As Error
Add-LogEntry "Error loading config file! Please make sure the correct path was provided, and that it is a properly formatted JSON file" -As Error
Write-Output $_
Exit 1
}
@@ -236,19 +236,19 @@ Function Import-YAMLConfig () {
Return (Get-Content -Raw -Path $ConfigFile | ConvertFrom-Yaml)
}
Catch {
Write-Output "Error loading config file! Please make sure the correct path was provided, and that it is a properly formatted JSON file" -As Error
Add-LogEntry "Error loading config file! Please make sure the correct path was provided, and that it is a properly formatted JSON file" -As Error
Write-Output $_
Exit 1
}
}
Else {
Write-Output "Error loading config file! Please make sure the correct path was provided, and that it is a properly formatted JSON file" -As Error
Add-LogEntry "Error loading config file! Please make sure the correct path was provided, and that it is a properly formatted JSON file" -As Error
Write-Output $_
Exit 1
}
}
Else {
Write-Output "Cannot import YAML config, module `"powershell-yaml`" is not installed"
Add-LogEntry "Cannot import YAML config, module `"powershell-yaml`" is not installed"
Exit 1
}
@@ -262,20 +262,20 @@ Function Set-RegistryKey {
[Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] $TestType
)
If (-Not (Test-Path -Path $TestPath)) {
Write-Output "Registry path not found, creating..."
Add-LogEntry "Registry path not found, creating..."
New-Item $TestPath -Force -ErrorAction SilentlyContinue | Out-Null
}
If ($null -ne (Get-Item -Path $TestPath).GetValue($TestKey)) {
If ((Get-ItemPropertyValue -Path $TestPath -Name $TestKey) -eq $TestValue) {
Write-Output "Current key value is `"$((Get-Item -Path $TestPath).GetValue($TestKey))`", no action needed"
Add-LogEntry "Current key value is `"$((Get-Item -Path $TestPath).GetValue($TestKey))`", no action needed"
}
Else {
Write-Output "Setting value of `"$($TestKey)`" to `"$($TestValue)`""
Add-LogEntry "Setting value of `"$($TestKey)`" to `"$($TestValue)`""
Set-ItemProperty -Path $TestPath -Name $TestKey -Value $TestValue
}
}
Else {
Write-Output "Registry key does not exist, creating..."
Add-LogEntry "Registry key does not exist, creating..."
New-ItemProperty -Path $TestPath -Name $TestKey -Value $TestValue -PropertyType $TestType -Force -ErrorAction SilentlyContinue | Out-Null
}
}
@@ -322,9 +322,9 @@ Function Test-AsAdmin () {
Param (
[Parameter(Mandatory = $false)] [String] $AdditionalFlags
)
Write-Output "Checking to see if script has been run with administrative privileges"
Add-LogEntry "Checking to see if script has been run with administrative privileges"
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
Write-Output "Performing script elevation, please approve the admin prompt"
Add-LogEntry "Performing script elevation, please approve the admin prompt"
Start-Sleep -Seconds 3
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
$CommandLine = "$AdditionalFlags -File `"" + $MyInvocation.MyCommand.Path + "`" " + (Save-Parameters $MyInvocation.BoundParameters) + " " + $MyInvocation.UnboundArguments
@@ -333,7 +333,7 @@ Function Test-AsAdmin () {
}
}
Else {
Write-Output "Script already running as admin"
Add-LogEntry "Script already running as admin"
}
}