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

Extraneous Warnings on clean import #162

Closed
4 tasks done
lowlydba opened this issue Jan 28, 2022 · 0 comments
Closed
4 tasks done

Extraneous Warnings on clean import #162

lowlydba opened this issue Jan 28, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@lowlydba
Copy link
Contributor

lowlydba commented Jan 28, 2022

Before submitting the bug

  • Ensure you are able to reproduce it on the latest released version (we release often)
  • Verified this bug is not already reported in an issue
  • Verified errors are not related to permissions
  • Can reproduce in a clean PowerShell session (clean = powershell -NoProfile)

Describe the bug
I'm not sure how common of a scenario this is, but I ran into it while troubleshooting #159.

When doing an import without a PSDrive setup, but with a JSON file set through Set-DcnConfiguration, when dbaclone.psm1 imports the public function scripts, it results in two of them issuing warnings related to the PSDrive. These occur before the creation of the PSDrive in postimport.ps1, so will always be thrown in this case.

elseif ($informationStore -eq 'File') {
# Create the PS Drive and get the results
try {
if (Test-Path -Path "DCNJSONFolder:\") {
# Get the clones
$results = Get-ChildItem -Path "DCNJSONFolder:\" -Filter "*clones.json" | ForEach-Object { Get-Content $_.FullName | ConvertFrom-Json }
}
else {
Stop-PSFFunction -Message "Could not reach clone information location 'DCNJSONFolder:\'" -ErrorRecord $_ -Target "DCNJSONFolder:\"

and

elseif ($informationStore -eq 'File') {
try {
if (Test-Path -Path "DCNJSONFolder:\") {
# Get the clones
$results = Get-ChildItem -Path "DCNJSONFolder:\" -Filter "*images.json" | ForEach-Object { Get-Content $_.FullName | ConvertFrom-Json }
}
else {
Stop-PSFFunction -Message "Could not reach image information location 'DCNJSONFolder:\'" -ErrorRecord $_ -Target "DCNJSONFolder:\"

To Reproduce
Steps to reproduce the behavior:

Import-Module dbaclone
Set-DcnConfiguration -InformationStore File -Path "C:\"

Remove-Module dbaclone -Force
# Simulate it was removed, never created, or encountered an error when creating...
Remove-PSDrive "DCNJSONFolder"

Import-Module dbaclone

Expected behavior
Ideally loading these functions during import shouldn't run them in a way that attempts to read from the PSDrive, in the case where it doesn't exist for some reason.

Screenshots
I added a few debug warnings to illustrate:
image

Environmental data

Name                           Value
----                           -----
PSVersion                      5.1.14393.4583
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.4583
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
@sanderstad sanderstad self-assigned this Apr 19, 2022
@sanderstad sanderstad added the bug Something isn't working label Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants