Skip to content

Commit

Permalink
Fixed edit+save config
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickGrub committed Feb 18, 2021
1 parent a78426f commit fd9720e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
$global:ErrorActionPreference = "Stop"
$commonModulePath = "C:\ProgramData\coolOrange\powerGate\Modules"
$modules = Get-ChildItem -path $commonModulePath -Recurse -Filter *.ps*
$modules | ForEach-Object { Import-Module -Name $_.FullName -Global }
try {
$commonModulePath = "C:\ProgramData\coolOrange\powerGate\Modules"
$modules = Get-ChildItem -path $commonModulePath -Recurse -Filter *.ps*
$modules | ForEach-Object { Import-Module -Name $_.FullName -Global }

$cfgPath = "c:\temp\powerGateCfg\powerGateConfiguration.xml"
[xml]$cfg = Get-PowerGateConfigFromVault
New-Item -Path "c:\temp\powerGateCfg" -ItemType Directory -Force
$cfg.Save($cfgPath)
$cfgPath = "c:\temp\powerGateCfg\powerGateConfiguration.xml"
[xml]$cfg = Get-PowerGateConfigFromVault
New-Item -Path "c:\temp\powerGateCfg" -ItemType Directory -Force
$cfg.Save($cfgPath)

Start-Process -FilePath C:\Windows\explorer.exe -ArgumentList "/select, ""$cfgPath"""
Start-Process -FilePath C:\Windows\explorer.exe -ArgumentList "/select, ""$cfgPath"""
}
catch {
(ShowMessageBox -Message $_.Exception.Message -Button "OK" -Icon "Error") | Out-Null
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
$global:ErrorActionPreference = "Stop"
$commonModulePath = "C:\ProgramData\coolOrange\powerGate\Modules"
$modules = Get-ChildItem -path $commonModulePath -Recurse -Filter *.ps*
$modules | ForEach-Object { Import-Module -Name $_.FullName -Global }
try {
$commonModulePath = "C:\ProgramData\coolOrange\powerGate\Modules"
$modules = Get-ChildItem -path $commonModulePath -Recurse -Filter *.ps*
$modules | ForEach-Object { Import-Module -Name $_.FullName -Global }

$cfgPath = "c:\temp\powerGateCfg\powerGateConfiguration.xml"
$testPath = Test-Path $cfgPath
if ($testPath -eq $false) {
ShowMessageBox -Message "No config file found in '$cfgPath' `n Please download/edit the config file first and then save it back to the Vault server!" -Button "OK" -Icon "Warning" | Out-Null
return
}
$cfgPath = "c:\temp\powerGateCfg\powerGateConfiguration.xml"
$testPath = Test-Path $cfgPath
if ($testPath -eq $false) {
ShowMessageBox -Message "No config file found in '$cfgPath' `n Please download/edit the config file first and then save it back to the Vault server!" -Button "OK" -Icon "Warning" | Out-Null
return
}

[byte[]]$cfg = [System.IO.File]::ReadAllBytes($cfgPath)
Set-PowerGateConfigFromVault -Content $cfg
ShowMessageBox -Message "Config file saved to Vault server" -Button "OK" -Icon "Information" | Out-Null
[byte[]]$cfg = [System.IO.File]::ReadAllBytes($cfgPath)
Set-PowerGateConfigFromVault -Content $cfg
ShowMessageBox -Message "Config file saved to Vault server" -Button "OK" -Icon "Information" | Out-Null

Remove-Item $cfgPath -Force
Remove-Item $cfgPath -Force
}
catch {
(ShowMessageBox -Message $_.Exception.Message -Button "OK" -Icon "Error") | Out-Null
}

0 comments on commit fd9720e

Please sign in to comment.