SQLServerPSModule icon indicating copy to clipboard operation
SQLServerPSModule copied to clipboard

Invoke-Sqlcmd with -NewPassword throws: Value cannot be null. (Parameter 'path2')

Open BeniFreitag opened this issue 6 months ago • 0 comments

The documentation says -NewPassword can be used to change the password of a SQL Server Authentication login ID. When I run this Cmdlet it shows an error and it also changes the password:

Invoke-Sqlcmd -ServerInstance . -Username "TestLogin" -Password "OldPw" -NewPassword "NewPw"

Error: Invoke-Sqlcmd: Value cannot be null. (Parameter 'path2')

Exception Details:

Message        : Value cannot be null. (Parameter 'path2')
ParamName      : path2
TargetSite     : Void Throw(System.String)
Data           : {}
InnerException :
HelpLink       :
Source         : System.Private.CoreLib
HResult        : -2147467261
StackTrace     :    at System.ArgumentNullException.Throw(String paramName)
                    at System.IO.Path.Combine(String path1, String path2)
                    at Microsoft.SqlServer.Management.PowerShell.GetScriptCommand.ProcessRecord()

Image

Environment:

  • Invoke-Sqlcmd Version: 22.4.5.1 (latest)
  • PowerShell 7.5.1 (latest)
  • Windows 11 (26100.4349, latest)

BeniFreitag avatar Jun 24 '25 09:06 BeniFreitag