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

dbatools module prevents Show-Command from working #9225

Open
corbob opened this issue Jan 25, 2024 · 0 comments
Open

dbatools module prevents Show-Command from working #9225

corbob opened this issue Jan 25, 2024 · 0 comments
Labels
bugs life triage required New issue that has not been reviewed by maintainers

Comments

@corbob
Copy link

corbob commented Jan 25, 2024

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?


PSMessageDetails      : 
Exception             : System.Reflection.TargetInvocationException: Exception has been thrown by the target of an 
                        invocation. ---> System.Management.Automation.RuntimeException: Unable to find type 
                        [Microsoft.SqlServer.Replication.Article].
                           at System.Management.Automation.TypeOps.ResolveTypeName(ITypeName typeName, IScriptExtent 
                        errorPos)
                           at System.Management.Automation.TypeOps.ResolveTypeName(ITypeName typeName, IScriptExtent 
                        errorPos)
                           at System.Management.Automation.Language.Compiler.GetAttribute(TypeConstraintAst 
                        typeConstraintAst)
                           at System.Management.Automation.Language.Compiler.GetRuntimeDefinedParameter(ParameterAst 
                        parameterAst, Boolean& customParameterSet, Boolean& usesCmdletBinding)
                           at System.Management.Automation.Language.Compiler.GetParameterMetaData(ReadOnlyCollection`1 
                        parameters, Boolean automaticPositions, Boolean& usesCmdletBinding)
                           at System.Management.Automation.CompiledScriptBlockData.InitializeMetadata()
                           at System.Management.Automation.CompiledScriptBlockData.get_CmdletBindingAttribute()
                           at System.Management.Automation.CommandMetadata..ctor(ScriptBlock scriptblock, String 
                        commandName, ExecutionContext context)
                           at System.Management.Automation.FunctionInfo.get_CommandMetadata()
                           at System.Management.Automation.CommandInfo.GenerateCommandParameterSetInfo()
                           at System.Management.Automation.CommandInfo.get_ParameterSets()
                           at 
                        Microsoft.PowerShell.Commands.ShowCommandExtension.ShowCommandCommandInfo..ctor(CommandInfo 
                        other)
                           at 
                        Microsoft.PowerShell.Commands.ShowCommandInternal.ShowCommandHelper.GetCommandList(Object[] 
                        commandObjects)
                           --- End of inner exception stack trace ---
                           at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature 
                        sig, Boolean constructor)
                           at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] 
                        parameters, Object[] arguments)
                           at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder 
                        binder, Object[] parameters, CultureInfo culture)
                           at Microsoft.PowerShell.Commands.ShowCommandProxy.GetCommandList(Object[] commandObjects)
                           at Microsoft.PowerShell.Commands.ShowCommandCommand.CanProcessRecordForAllCommands()
                           at Microsoft.PowerShell.Commands.ShowCommandCommand.ProcessRecord()
                           at System.Management.Automation.CommandProcessor.ProcessRecord()
TargetObject          : 
CategoryInfo          : NotSpecified: (:) [Show-Command], TargetInvocationException
FullyQualifiedErrorId : System.Reflection.TargetInvocationException,Microsoft.PowerShell.Commands.ShowCommandCommand
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}



Steps to Reproduce

Import-Module dbatools
Show-Command # Results in error
# For completeness, how I proved it was dbatools:
Remove-Module dbatools
Show-Command # No longer results in error.

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

2.1.7

Other details or mentions

After getting the full error details, it occurred to me based on the error that it was likely a command that took in a pipeline object, and something about the object. So to determine the command(s) causing issues I ran: get-command -Module dbatools | % { $cmd = $_.name; try { show-command $cmd } catch { Write-Host $cmd } } and just held down the Escape key to close all the Show-Command windows that appeared. It eventually came back with Remove-DbaReplArticle and Remove-DbaReplPublication. Based on the error variables from those commands it looks like it's the Microsoft.SqlServer.Replication.Publication and Microsoft.SqlServer.Replication.Article types causing issues.

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

Name                           Value                                                                                   
----                           -----                                                                                   
PSVersion                      5.1.20348.2227                                                                          
PSEdition                      Desktop                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
BuildVersion                   10.0.20348.2227                                                                         
CLRVersion                     4.0.30319.42000                                                                         
WSManStackVersion              3.0                                                                                     
PSRemotingProtocolVersion      2.3                                                                                     
SerializationVersion           1.1.0.1                                                                                 

SQL Server Edition and Build number

N/A

.NET Framework Version

PSChildName Version  
----------- -------  
Client      4.8.04161
Full        4.8.04161
Client      4.0.0.0  

@corbob corbob added bugs life triage required New issue that has not been reviewed by maintainers labels Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs life triage required New issue that has not been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

1 participant