dataplat / dbatools

🚀 SQL Server automation and instance migrations have never been safer, faster or freer

Home Page:https://dbatools.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Install-DbaWhoIsActive - on first run, doesn't create subfolder, so fails. Creating folder, still fails, but says success.

mbourgon opened this issue · comments

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

Installing DBATOOLS on a brand new machine, then running it against an Azure SQL Database.

  1. it initially says that the folder doesn't exist
  2. creating the folder hides that error, and then running it, it says Installed, even though it's not

Here's the error from the command prompt

Get-ChildItem : Cannot find path 'C:\Users\azure-admin\AppData\Roaming\PowerShell\dbatools\WhoIsActive' because it does not exist.
At line:45031 char:25
+ ... $sqlfile = (Get-ChildItem -Path $localCachedCopy -Filter 'sp_WhoIsAct ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\azure-...ols\WhoIsActive:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
Get-ChildItem : Cannot find path 'C:\Users\azure-admin\AppData\Roaming\PowerShell\dbatools\WhoIsActive' because it does not exist.
At line:45034 char:29
+ ... $sqlfile = (Get-ChildItem -Path $localCachedCopy -Filter 'who_is_acti ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\azure-...ols\WhoIsActive:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
Exception calling "ReadAllText" with "1" argument(s): "Empty path name is not legal."
At line:45038 char:13
+             $sql = [IO.File]::ReadAllText($sqlfile)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException

and the error command gives

PSMessageDetails      : 
Exception             : System.Management.Automation.MethodInvocationException: Exception calling "ReadAllText" with "1" argument(s): "Empty path name is not legal." ---> System.ArgumentException: Empty path name is not legal.
                           at System.IO.File.ReadAllText(String path)
                           at CallSite.Target(Closure , CallSite , Type , Object )
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
                           at CallSite.Target(Closure , CallSite , Type , Object )
                           at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject          : 
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : ArgumentException
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Install-DbaWhoIsActive<Begin>, <No file>: line 45038
                        at <ScriptBlock>, <No file>: line 2
PipelineIterationInfo : {}

if I then create the folder, I get different errors:

Install-DbaWhoIsActive `
    -SqlInstance myservername.database.windows.net `
    -SqlCredential $creds `
    -Database billing_capture
    

Exception calling "ReadAllText" with "1" argument(s): "Empty path name is not legal."
At line:45038 char:13
+             $sql = [IO.File]::ReadAllText($sqlfile)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException

ComputerName : az-2668p-eastus2-rxns-switchclaims-sql.database.windows.net
InstanceName : 
SqlInstance  : az-2668p-eastus2-rxns-switchclaims-sql
Database     : billing_capture
Name         : sp_WhoisActive
Version      : 
Status       : Installed

but if I select from sys.objects, it's not in there. Nor has it been updated in master.

PS C:\Users\myusername> $error[0] | select *


PSMessageDetails      : 
Exception             : System.Management.Automation.MethodInvocationException: Exception calling "ReadAllText" with "1" argument(s): "Empty path name is not legal." ---> System.ArgumentException: Empty path name is not legal.
                           at System.IO.File.ReadAllText(String path)
                           at CallSite.Target(Closure , CallSite , Type , Object )
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
                           at CallSite.Target(Closure , CallSite , Type , Object )
                           at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject          : 
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : ArgumentException
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Install-DbaWhoIsActive<Begin>, <No file>: line 45038
                        at <ScriptBlock>, <No file>: line 7
PipelineIterationInfo : {}

Steps to Reproduce

$securepassword = ConvertTo-SecureString -String "password" -AsPlainText -Force;
$username = "myusername"
$creds = New-Object System.Management.Automation.PSCredential($username,$securepassword)


Install-DbaWhoIsActive `
    -SqlInstance myAzureSQLDB.database.windows.net `
    -SqlCredential $creds `
    -Database my_dbname
    
$error[0] | select *

Please confirm that you are running the most recent version of dbatools

2.1.14

Other details or mentions

No response

What PowerShell host was used when producing this error

Windows PowerShell ISE (powershell_ise.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.17763.5576
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.5576
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server Edition and Build number

Microsoft SQL Azure (RTM) - 12.0.2000.8 Feb 2 2024 04:20:23 Copyright (C) 2022 Microsoft Corporation

.NET Framework Version

.NET Framework 4.8.4645.0

I can not reproduce the issue.

Please remove the folder "C:\Users\azure-admin\AppData\Roaming\PowerShell\dbatools\WhoIsActive", run the following command and share the output: Save-DbaCommunitySoftware -Software WhoIsActive -Verbose.

I think I see what happened. The box I'm on doesn't have full access to github, and I didn't think about that. So it must have tried to grab it, failed, and went on its way.

VERBOSE: GET https://api.github.com/repos/amachanic/sp_whoisactive/releases with 0-byte payload
VERBOSE: GET https://api.github.com/repos/amachanic/sp_whoisactive/releases with 0-byte payload
WARNING: [16:52:06][Save-DbaCommunitySoftware] Unable to get release information from https://api.github.com/repos/amachanic/sp_whoisactive/releases. | An existing connection was forcibly closed by the remote host

Thanks for the feedback.