Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed Get/Set config #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions SecretServer/Public/Get-SecretServerConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@
[ValidateSet("Variable","ConfigFile")]$Source = "Variable"
)

if(-not (Test-Path -Path "$PSScriptRoot\SecretServer_$($env:USERNAME).xml" -ErrorAction SilentlyContinue)) {
if(-not (Test-Path -Path "$PSScriptRoot\..\SecretServer.xml" -ErrorAction SilentlyContinue)) {
try {
Write-Verbose "Did not find config file $PSScriptRoot\SecretServer_$($env:USERNAME).xml attempting to create"
Write-Verbose "Did not find config file $PSScriptRoot\..\SecretServer.xml attempting to create"
[pscustomobject]@{
Uri = $null
Token = $null
ServerInstance = $null
Database = $null
} | Export-Clixml -Path "$PSScriptRoot\SecretServer_$($env:USERNAME).xml" -Force -ErrorAction Stop
} | Export-Clixml -Path "$PSScriptRoot\..\SecretServer.xml" -Force -ErrorAction Stop
}
catch {
Write-Warning "Failed to create config file $PSScriptRoot\SecretServer_$($env:USERNAME).xml: $_"
Write-Warning "Failed to create config file $PSScriptRoot\..\SecretServer.xml: $_"
}
}

if($Source -eq "Variable" -and $SecretServerConfig) {
$SecretServerConfig
}
else {
Import-Clixml -Path "$PSScriptRoot\SecretServer_$($env:USERNAME).xml"
Import-Clixml -Path "$PSScriptRoot\..\SecretServer.xml"
}
}

Expand Down
2 changes: 1 addition & 1 deletion SecretServer/Public/Set-SecretServerConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

#Write the global variable and the xml
$Global:SecretServerConfig = $Existing
$Existing | Select -Property * -ExcludeProperty Proxy | Export-Clixml -Path "$PSScriptRoot\SecretServer_$($env:USERNAME).xml" -Force
$Existing | Select -Property * -ExcludeProperty Proxy | Export-Clixml -Path "$PSScriptRoot\..\SecretServer.xml" -Force
}

#publish
Expand Down