private/dynamicparams/dynamicparams.ps1
#region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["alert"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["alert"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["alert"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["alert"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["alert"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name alert #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["alert"][$FullSmoName] = $server.JobServer.Alerts.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["alertcategory"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["alertcategory"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["alertcategory"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["alertcategory"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["alertcategory"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name AlertCategory #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["alertcategory"][$FullSmoName] = $server.JobServer.AlertCategories.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["audit"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["audit"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["audit"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["audit"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["audit"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name Audit #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["audit"][$FullSmoName] = $server.Audits.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["auditspecification"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["auditspecification"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["auditspecification"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["auditspecification"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["auditspecification"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name AuditSpecification #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["auditspecification"][$FullSmoName] = $server.AuditSpecifications.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["availabilitygroup"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["availabilitygroup"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["availabilitygroup"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["availabilitygroup"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["availabilitygroup"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name AvailabilityGroup #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["availabilitygroup"][$FullSmoName] = $server.AvailabilityGroups.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["backupdevice"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["backupdevice"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["backupdevice"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["backupdevice"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["backupdevice"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name BackupDevice #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["backupdevice"][$FullSmoName] = $server.BackupDevices.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Tepp Data return: FullName $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) foreach ($name in ([Dataplat.Dbatools.Configuration.ConfigurationHost]::Configurations.Values | Where-Object { -not $_.Hidden -and ($_.FullName -Like "$wordToComplete*") } | Select-Object -ExpandProperty FullName | Sort-Object)) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name config #endregion Tepp Data return: FullName #region Tepp Data return: Name $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $moduleName = "*" if ($fakeBoundParameter.Module) { $moduleName = $fakeBoundParameter.Module } foreach ($name in ([Dataplat.Dbatools.Configuration.ConfigurationHost]::Configurations.Values | Where-Object { (-not $_.Hidden) -and ($_.Name -Like "$wordToComplete*") -and ($_.Module -like $moduleName) } | Select-Object -ExpandProperty Name | Sort-Object)) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name config_name #endregion Tepp Data return: Name #region Tepp Data return: Module $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) foreach ($name in ([Dataplat.Dbatools.Configuration.ConfigurationHost]::Configurations.Values.Module | Select-Object -Unique | Where-DbaObject -Like "$wordToComplete*" | Sort-Object )) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name configmodule #endregion Tepp Data return: Module #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["configname"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["configname"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["configname"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["configname"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["configname"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name ConfigName #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["configname"][$FullSmoName] = (Get-Member -InputObject $server.Configuration -MemberType Property -Force | Where-Object Name -NotIn 'Parent', 'Properties').Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["credential"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["credential"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["credential"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["credential"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["credential"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name Credential #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["credential"][$FullSmoName] = $server.Credentials.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["customerror"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["customerror"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["customerror"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["customerror"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["customerror"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name CustomError #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["customerror"][$FullSmoName] = $server.UserDefinedMessages.ID } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["database"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["database"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["database"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["database"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["database"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name Database #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["database"][$FullSmoName] = $server.Databases.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["delimiter"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["delimiter"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) @("``t", "|", ";", " ", ",", " ") } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name Delimiter #endregion Tepp Data return #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["endpoint"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["endpoint"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["endpoint"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["endpoint"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["endpoint"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name Endpoint #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["endpoint"][$FullSmoName] = ($server.Endpoints | Where-Object IsSystemObject -eq $false).Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["group"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["group"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["group"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["group"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["group"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name Group #endregion Tepp Data return #region Update Cache $ScriptBlock = { $cms = New-Object Microsoft.SqlServer.Management.RegisteredServers.RegisteredServersStore($server.ConnectionContext.SqlConnectionObject) [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["group"][$FullSmoName] = $cms.DatabaseEngineServerGroup.ServerGroups.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["instanceproperty"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["instanceproperty"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["instanceproperty"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["instanceproperty"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["instanceproperty"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name InstanceProperty #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["instanceproperty"][$FullSmoName] = $server.Information.Properties.Name + $server.UserOptions.Properties.Name + $server.Settings.Properties.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["job"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["job"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["job"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["job"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["job"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name Job #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["job"][$FullSmoName] = $server.JobServer.Jobs.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["jobcategory"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["jobcategory"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["jobcategory"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["jobcategory"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["jobcategory"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name JobCategory #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["jobcategory"][$FullSmoName] = $server.JobServer.JobCategories.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["linkedserver"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["linkedserver"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["linkedserver"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["linkedserver"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["linkedserver"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name LinkedServer #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["linkedserver"][$FullSmoName] = $server.LinkedServers.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["login"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["login"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["login"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["login"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["login"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name Login #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["login"][$FullSmoName] = $server.Logins.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailaccount"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailaccount"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailaccount"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailaccount"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailaccount"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name MailAccount #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailaccount"][$FullSmoName] = $server.Mail.Accounts.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailprofile"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailprofile"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailprofile"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailprofile"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailprofile"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name MailProfile #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailprofile"][$FullSmoName] = $server.Mail.Profiles.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailserver"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailserver"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailserver"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailserver"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailserver"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name MailServer #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["mailserver"][$FullSmoName] = $server.Mail.Accounts.MailServers.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["newagentschedule"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["newagentschedule"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) 'EveryDay', 'Weekdays', 'Weekend', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name newagentschedule #endregion Tepp Data return #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["operator"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["operator"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["operator"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["operator"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["operator"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name Operator #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["operator"][$FullSmoName] = $server.JobServer.Operators.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["operatorcategory"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["operatorcategory"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["operatorcategory"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["operatorcategory"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["operatorcategory"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name OperatorCategory #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["operatorcategory"][$FullSmoName] = $server.JobServer.OperatorCategories.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Tepp Data return: Path $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) foreach ($name in (([Dataplat.Dbatools.Configuration.ConfigurationHost]::Configurations.Values | Where-Object FullName -like "path.managed.*").FullName -replace '^path\.managed\.')) { if ($name -notlike "$wordToComplete*") { continue } New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name path #endregion Tepp Data return: Path #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["perfmontemplate"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["perfmontemplate"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $files = (Get-ChildItem "$script:PSModuleRoot\bin\perfmontemplates\collectorsets\*.xml").BaseName foreach ($file in $files) { "'$file'" } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name perfmontemplate #endregion Tepp Data return #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["powerplan"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["powerplan"] = @() } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["powerplan"] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name "powerplan" #endregion Tepp Data return #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["powerplan"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["powerplan"] = 'High Performance', 'Balanced', 'Power saver' } #endregion Initialize Cache Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name powerplan #endregion Tepp Data return $scriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { return } $sqlCredential = $fakeBoundParameter['SqlCredential'] try { if ($sqlCredential) { $instance = Connect-DbaInstance -SqlInstance $server -SqlCredential $sqlCredential -ErrorAction Stop } else { $instance = Connect-DbaInstance -SqlInstance $server -ErrorAction Stop } $instance.EnumProcesses().Host | Select-Object -Unique | Where-DbaObject -Like "$wordToComplete*" | ForEach-Object { if (-not ([string]::IsNullOrWhiteSpace($_))) { New-DbaTeppCompletionResult -CompletionText $_ -ToolTip $_ } } } catch { return } finally { } } Register-DbaTeppScriptblock -ScriptBlock $scriptBlock -Name processhostname $scriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { return } $sqlCredential = $fakeBoundParameter['SqlCredential'] try { if ($sqlCredential) { $instance = Connect-DbaInstance -SqlInstance $server -SqlCredential $sqlCredential -ErrorAction Stop } else { $instance = Connect-DbaInstance -SqlInstance $server -ErrorAction Stop } $instance.EnumProcesses().Program | Select-Object -Unique | Where-DbaObject -Like "$wordToComplete*" | ForEach-Object { if (-not ([string]::IsNullOrWhiteSpace($_))) { New-DbaTeppCompletionResult -CompletionText $_ -ToolTip $_ } } } catch { return } finally { } } Register-DbaTeppScriptblock -ScriptBlock $scriptBlock -Name processprogram $scriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { return } $sqlCredential = $fakeBoundParameter['SqlCredential'] try { if ($sqlCredential) { $instance = Connect-DbaInstance -SqlInstance $server -SqlCredential $sqlCredential -ErrorAction Stop } else { $instance = Connect-DbaInstance -SqlInstance $server -ErrorAction Stop } $instance.EnumProcesses().Spid | Select-Object -Unique | Where-DbaObject -Like "$wordToComplete*" | ForEach-Object { if (-not ([string]::IsNullOrWhiteSpace($_))) { New-DbaTeppCompletionResult -CompletionText $_ -ToolTip $_ } } } catch { return } finally { } } Register-DbaTeppScriptblock -ScriptBlock $scriptBlock -Name processspid #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["proxyaccount"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["proxyaccount"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["proxyaccount"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["proxyaccount"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["proxyaccount"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name ProxyAccount #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["proxyaccount"][$FullSmoName] = $server.JobServer.ProxyAccounts.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["resourcepool"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["resourcepool"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["resourcepool"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["resourcepool"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["resourcepool"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name ResourcePool #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["resourcepool"][$FullSmoName] = ($server.ResourceGovernor.ResourcePools | Where-Object Name -NotIn 'internal', 'default').Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["schedule"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["schedule"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["schedule"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["schedule"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["schedule"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name Schedule #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["schedule"][$FullSmoName] = $server.JobServer.SharedSchedules.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["servertrigger"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["servertrigger"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["servertrigger"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["servertrigger"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["servertrigger"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name ServerTrigger #endregion Tepp Data return #region Update Cache $ScriptBlock = { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["servertrigger"][$FullSmoName] = $server.Triggers.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["session"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["session"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["session"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["session"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { $serverObject = Connect-DbaInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["session"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name session #endregion Tepp Data return #region Update Cache $ScriptBlock = { $SqlConn = $server.ConnectionContext.SqlConnectionObject $SqlStoreConnection = New-Object Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection $SqlConn $XEStore = New-Object Microsoft.SqlServer.Management.XEvent.XEStore $SqlStoreConnection $xesessions = $XEStore.sessions [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["session"][$FullSmoName] = $xesessions.Name } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["setagentschedule"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["setagentschedule"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) 'EveryDay', 'Weekdays', 'Weekend', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 62, 64, 65, 127 } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name setagentschedule #endregion Tepp Data return #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["snapshot"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["snapshot"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $server = $fakeBoundParameter['SqlInstance'] if (-not $server) { $server = $fakeBoundParameter['Source'] } if (-not $server) { $server = $fakeBoundParameter['ComputerName'] } if (-not $server) { return } try { [DbaInstanceParameter]$parServer = $server | Select-Object -First 1 } catch { return } if ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["snapshot"][$parServer.FullSmoName.ToLowerInvariant()]) { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["snapshot"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } try { foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["snapshot"][$parServer.FullSmoName.ToLowerInvariant()] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } return } catch { return } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name snapshot #endregion Tepp Data return #region Update Cache $ScriptBlock = { if ($PSVersionTable.PSVersion.Major -ge 4) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["snapshot"][$FullSmoName] = $server.Databases.Where( { $_.IsDatabaseSnapShot }).Name } else { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["snapshot"][$FullSmoName] = ($server.Databases | Where-Object IsDatabaseSnapShot).Name } } Register-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock #endregion Update Cache #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["sqlinstance"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["sqlinstance"] = @() } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) foreach ($name in ([Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["sqlinstance"] | Where-DbaObject -Like "$wordToComplete*")) { New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name "sqlinstance" #endregion Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) # Hack till we get this working function New-CompletionResult { param ([Parameter(ValueFromPipelineByPropertyName, Mandatory, ValueFromPipeline)] [ValidateNotNullOrEmpty()] [string] $CompletionText, [Parameter(Position = 1, ValueFromPipelineByPropertyName)] [string] $ToolTip, [Parameter(Position = 2, ValueFromPipelineByPropertyName)] [string] $ListItemText, [System.Management.Automation.CompletionResultType] $CompletionResultType = [System.Management.Automation.CompletionResultType]::ParameterValue, [switch] $NoQuotes = $false ) process { $toolTipToUse = if ($ToolTip -eq '') { $CompletionText } else { $ToolTip } $listItemToUse = if ($ListItemText -eq '') { $CompletionText } else { $ListItemText } # If the caller explicitly requests that quotes # not be included, via the -NoQuotes parameter, # then skip adding quotes. if ($CompletionResultType -eq [System.Management.Automation.CompletionResultType]::ParameterValue -and -not $NoQuotes) { # Add single quotes for the caller in case they are needed. # We use the parser to robustly determine how it will treat # the argument. If we end up with too many tokens, or if # the parser found something expandable in the results, we # know quotes are needed. $tokens = $null $null = [System.Management.Automation.Language.Parser]::ParseInput("echo $CompletionText", [ref]$tokens, [ref]$null) if ($tokens.Length -ne 3 -or ($tokens[1] -is [System.Management.Automation.Language.StringExpandableToken] -and $tokens[1].Kind -eq [System.Management.Automation.Language.TokenKind]::Generic)) { $CompletionText = "'$CompletionText'" } } return New-Object System.Management.Automation.CompletionResult ` ($CompletionText, $listItemToUse, $CompletionResultType, $toolTipToUse.Trim()) } } $moduledirectory = $env:PSModuleRoot $idxfile = "$moduledirectory\bin\dbatools-index.json" $json = Get-Content $idxfile | ConvertFrom-Json $cleantags = @() $tags = $json.Tags foreach ($tag in $tags) { if ($null -ne $tag) { $cleantags += $tag.Trim() } } $collection = $cleantags | Select-Object -Unique if ($collection) { foreach ($item in $collection) { New-CompletionResult -CompletionText $item -ToolTip $item } } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name "tag" #region Initialize Cache if (-not [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["xesessiontemplate"]) { [Dataplat.Dbatools.TabExpansion.TabExpansionHost]::Cache["xesessiontemplate"] = @{ } } #endregion Initialize Cache #region Tepp Data return $ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $files = (Get-ChildItem "$script:PSModuleRoot/bin/XEtemplates/*.xml").BaseName foreach ($file in $files) { "'$file'" } } Register-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name xesessiontemplate #endregion Tepp Data return |