forked from dataplat/dbatools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessProgram.ps1
More file actions
36 lines (27 loc) · 915 Bytes
/
processProgram.ps1
File metadata and controls
36 lines (27 loc) · 915 Bytes
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
33
34
35
36
$scriptBlock = {
param (
$commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameter
)
$server = $fakeBoundParameter['SqlInstance']
if (-not $server) {
return
}
$sqlCredential = $fakeBoundParameter['SqlCredential']
try {
if ($sqlCredential) { $instance = Connect-SqlInstance -SqlInstance $server -ErrorAction Stop }
else { $instance = Connect-SqlInstance -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