Revert function text output
This commit is contained in:
@@ -181,13 +181,13 @@ Function Import-JSONConfig () {
|
|||||||
Return (Get-Content -Raw -Path $ConfigFile | ConvertFrom-Json)
|
Return (Get-Content -Raw -Path $ConfigFile | ConvertFrom-Json)
|
||||||
}
|
}
|
||||||
Catch {
|
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 $_
|
Write-Output $_
|
||||||
Exit 1
|
Exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Else {
|
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 $_
|
Write-Output $_
|
||||||
Exit 1
|
Exit 1
|
||||||
}
|
}
|
||||||
@@ -236,19 +236,19 @@ Function Import-YAMLConfig () {
|
|||||||
Return (Get-Content -Raw -Path $ConfigFile | ConvertFrom-Yaml)
|
Return (Get-Content -Raw -Path $ConfigFile | ConvertFrom-Yaml)
|
||||||
}
|
}
|
||||||
Catch {
|
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 $_
|
Write-Output $_
|
||||||
Exit 1
|
Exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Else {
|
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 $_
|
Write-Output $_
|
||||||
Exit 1
|
Exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Else {
|
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
|
Exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,20 +262,20 @@ Function Set-RegistryKey {
|
|||||||
[Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] $TestType
|
[Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] $TestType
|
||||||
)
|
)
|
||||||
If (-Not (Test-Path -Path $TestPath)) {
|
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
|
New-Item $TestPath -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
}
|
}
|
||||||
If ($null -ne (Get-Item -Path $TestPath).GetValue($TestKey)) {
|
If ($null -ne (Get-Item -Path $TestPath).GetValue($TestKey)) {
|
||||||
If ((Get-ItemPropertyValue -Path $TestPath -Name $TestKey) -eq $TestValue) {
|
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 {
|
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
|
Set-ItemProperty -Path $TestPath -Name $TestKey -Value $TestValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Else {
|
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
|
New-ItemProperty -Path $TestPath -Name $TestKey -Value $TestValue -PropertyType $TestType -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -322,9 +322,9 @@ Function Test-AsAdmin () {
|
|||||||
Param (
|
Param (
|
||||||
[Parameter(Mandatory = $false)] [String] $AdditionalFlags
|
[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')) {
|
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
|
Start-Sleep -Seconds 3
|
||||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
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
|
$CommandLine = "$AdditionalFlags -File `"" + $MyInvocation.MyCommand.Path + "`" " + (Save-Parameters $MyInvocation.BoundParameters) + " " + $MyInvocation.UnboundArguments
|
||||||
@@ -333,7 +333,7 @@ Function Test-AsAdmin () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Else {
|
Else {
|
||||||
Write-Output "Script already running as admin"
|
Add-LogEntry "Script already running as admin"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user