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

New-D365Bacpag faling ( teste on 0.7.1 07.0.2 and 0.7.3 ) #769

Closed
HC-Pin opened this issue Oct 23, 2023 · 8 comments
Closed

New-D365Bacpag faling ( teste on 0.7.1 07.0.2 and 0.7.3 ) #769

HC-Pin opened this issue Oct 23, 2023 · 8 comments

Comments

@HC-Pin
Copy link

HC-Pin commented Oct 23, 2023

SQLpackage : sqlpackage-win7-x64-en-162.1.167.1 ( https://aka.ms/sqlpackage-windows )

New-D365Bacpac -ExportModeTier1 -BackupDirectory $AXTempFolder -NewDatabaseName $AxSqlInstance -BacpacFile $NewBackup -DiagnosticFile $AXExportLog

Error:
Get-SQLCommand : A parameter cannot be found that matches parameter name 'EnableException'.
At line:4482 char:34

  • $sqlCommand = Get-SQLCommand @PsBoundParameters
    
  •                              ~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (:) [Get-SQLCommand], ParameterBindingException
    • FullyQualifiedErrorId : NamedParameterNotFound,Get-SQLCommand

The property 'CommandText' cannot be found on this object. Verify that the property exists and can be set.
At line:4486 char:5

  • $sqlCommand.CommandText = $commandText
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

[09:24:29][Invoke-ClearSqlSpecificObjects] Something went wrong while clearing the SQL specific objects in the database. | You cannot

call a method on a null-valued expression.
Write-PSFMessage : You cannot call a method on a null-valued expression.
At line:4499 char:9

  •     Write-PSFMessage -Level Host -Message $messageString -Excepti ...
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:String) [Write-PSFMessage], RuntimeException
    • FullyQualifiedErrorId : d365fo.tools_Invoke-ClearSqlSpecificObjects,PSFramework.Commands.WritePSFMessageCommand

You cannot call a method on a null-valued expression.
At line:4505 char:13

  •         $sqlCommand.Connection.Close()
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:4508 char:9

  •     $sqlCommand.Dispose()
    
  •     ~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull

Something went wrong while clearing the SQL specific objects in the database.
At C:\Program Files\WindowsPowerShell\Modules\PSFramework\1.9.310\PSFramework.psm1:5644 char:23

  •     if (-not $Cmdlet) { throw $records[0] }
    
  •                         ~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], Exception
    • FullyQualifiedErrorId : d365fo.tools_Invoke-ClearSqlSpecificObjects
@Splaxi
Copy link
Collaborator

Splaxi commented Oct 23, 2023

@FH-Inway

Could it be that you are taking to many of the outer parameters, via the @PsBoundParameters object?

@Splaxi
Copy link
Collaborator

Splaxi commented Oct 23, 2023

@HC-Pin

Can you look at this PR, to see if these changes will work for you?

#770

@FH-Inway
Copy link
Member

@FH-Inway

Could it be that you are taking to many of the outer parameters, via the @PsBoundParameters object?

Are you maybe mixing this up with some other change I made? I don't think I changed any of the cmdlets involved, but maybe I'm missing something.

I think you are right, and #770 should address the immediate issue. However, I would recommend the same approach used in other cmdlets is implemented: Creating a new $Params instance that gets explicitely assigned the parameters that are to be used with Get-SQLCommand. E.g. how Clear-D365TempDBTables does it:

$Params = @{DatabaseServer = $DatabaseServer; DatabaseName = $DatabaseName;
SqlUser = $SqlUser; SqlPwd = $SqlPwd; TrustedConnection = $UseTrustedConnection;
}
$sqlCommand = Get-SQLCommand @Params

Otherwise, once a new parameter gets added to one of the four cmdlets from #770 and that new parameter is not also a parameter for Get-SQLCommand, the same error will occur again.

@FH-Inway FH-Inway mentioned this issue Oct 23, 2023
@FH-Inway
Copy link
Member

After I played around with this for a bit, I was able to reproduce the issue. Seems that it only occurs if the -EnableException switch is set. Since the switch was not specified in the issue description, I assume it was enabled using the Enable-D365Exception cmdlet. This could also explain why this issue has not been reported so far, although it seems to been have in place for some time.

@Splaxi I tried your fix and it works!

@Splaxi Splaxi closed this as completed in 15c4edb Oct 24, 2023
Splaxi added a commit that referenced this issue Oct 24, 2023
@FH-Inway
Copy link
Member

@HC-Pin New version 0.7.4 is out, check if it resolves your issue.

@Splaxi Thanks for the quick release.

@HC-Pin
Copy link
Author

HC-Pin commented Oct 25, 2023

Works without: #Enable-D365Exception -Verbose

image

@FH-Inway
Copy link
Member

@HC-Pin Did you try the newest version with Enable-D365Exception? It should work there now as well.

@HC-Pin
Copy link
Author

HC-Pin commented Oct 31, 2023

No did not test it with Enable-D365Exception

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

3 participants