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

Error: missing Private folder #35

Open
jtmoree-github-com opened this issue Jul 11, 2018 · 2 comments
Open

Error: missing Private folder #35

jtmoree-github-com opened this issue Jul 11, 2018 · 2 comments

Comments

@jtmoree-github-com
Copy link

When running from cmd.exe (like a scheduled task) I get an error.

Cannot find path 'C:\Program Files\PowerShell\Modules\Invoke-SqlCmd2\1.6.4\Private' because it does not exist.

You can't easily see the error as the powershell sub process throws it away. To demonstrate I have created some scripts. I will attach to this issue.

@jtmoree-github-com
Copy link
Author

invokesqlcmd2_error.zip

@jtmoree-github-com
Copy link
Author

jtmoree-github-com commented Jul 11, 2018

invoke-sqlcmd2 bug

When run from cmd (such as a scheduled task) the invoke-sqlcmd2 module is missing a Private folder.

It does not do this when run from inside powershell.

Cannot find path 'C:\Program Files\PowerShell\Modules\Invoke-SqlCmd2\1.6.4\Private' because it does not exist.

Testing

To demonstrate I have created some test scripts. Since cmd.exe does not catch errors (does it)
this only shows up within powershell. Since I am running from scheduled tasks and cannot easily
see the output I had to create mailing processes. The test dumps to host and sends an email if
configured in Config.ps1

To recreate the problem run cmd.exe then run the script

c:\>cd test
c:\test\>"c:\program files\powershell\6.0.2\pwsh.exe" .\05_smoke.ps1
Get-ChildItem : Cannot find path 'C:\Program Files\PowerShell\Modules\Invoke-Sql
Cmd2\1.6.4\Private' because it does not exist.
At C:\Program Files\PowerShell\Modules\Invoke-SqlCmd2\1.6.4\Invoke-SqlCmd2.psm1:
10 char:19
+ ... rivate = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAct ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (C:\Program File...2\1.6.4\Private:Str
ing) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildIte
mCommand

Configuration

If you want email output and database testing, edit Config.ps1 and update all parameters for your network.

Workaround

I manually created the Private folder as a workaround but this should be done by
the installation process, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant