PowerShell icon indicating copy to clipboard operation
PowerShell copied to clipboard

Error: missing Private folder

Open jtmoree-github-com opened this issue 7 years ago • 2 comments

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 avatar Jul 11 '18 21:07 jtmoree-github-com

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?

jtmoree-github-com avatar Jul 11 '18 21:07 jtmoree-github-com