January 6, 2014 at 7:43 am
Hi Experts,
Is there any way we can find the list of applications installed in a SQL Server box using SSMS?
January 6, 2014 at 8:16 am
Below is an answer, but I have to ask. Why do you need this?
The actual PS code was taken from This Web Site. All I did was wrap it into a SQL job. You will probably need to change the output location. For me it's going to Z:\SQL\Test.txt
USE [msdb]
GO
/****** Object: Job [Testing_PS] Script Date: 01/06/2014 09:13:55 ******/
BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
/****** Object: JobCategory [[Uncategorized (Local)]]] Script Date: 01/06/2014 09:13:55 ******/
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]' AND category_class=1)
BEGIN
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'[Uncategorized (Local)]'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
END
DECLARE @jobId BINARY(16)
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'Testing_PS',
@enabled=1,
@notify_level_eventlog=0,
@notify_level_email=0,
@notify_level_netsend=0,
@notify_level_page=0,
@delete_level=0,
@description=N'No description available.',
@category_name=N'[Uncategorized (Local)]',
@owner_login_name=N'sa', @job_id = @jobId OUTPUT
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
/****** Object: Step [Testing] Script Date: 01/06/2014 09:13:56 ******/
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'Testing',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=1,
@on_success_step_id=0,
@on_fail_action=2,
@on_fail_step_id=0,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0, @subsystem=N'PowerShell',
@command=N'if (!([Diagnostics.Process]::GetCurrentProcess().Path -match ''\\syswow64\\''))
{
$unistallPath = "\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
$unistallWow6432Path = "\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
@(
if (Test-Path "HKLM:$unistallWow6432Path" ) { Get-ChildItem "HKLM:$unistallWow6432Path"}
if (Test-Path "HKLM:$unistallPath" ) { Get-ChildItem "HKLM:$unistallPath" }
if (Test-Path "HKCU:$unistallWow6432Path") { Get-ChildItem "HKCU:$unistallWow6432Path"}
if (Test-Path "HKCU:$unistallPath" ) { Get-ChildItem "HKCU:$unistallPath" }
) |
ForEach-Object { Get-ItemProperty $_.PSPath } |
Where-Object {
$_.DisplayName -and !$_.SystemComponent -and !$_.ReleaseType -and !$_.ParentKeyName -and ($_.UninstallString -or $_.NoRemove)
} |
Sort-Object DisplayName |
Select-Object DisplayName
}
else
{
"You are running 32-bit Powershell on 64-bit system. Please run 64-bit Powershell instead." | Write-Host -ForegroundColor Red
}',
@database_name=N'master',
@output_file_name=N'z:\SQL\test.txt',
@flags=0
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
EndSave:
GO
.
January 6, 2014 at 9:04 am
Good answer, but that's not even "from SSMS" That's Agent using PowerShell. There's no way I know of through SSMS directly. You'd have to do some command line magic of PowerShell as shown above. I'd do PowerShell.
But, the bigger question is, why on earth do you want to do this type of thing through SQL Server at all? SQL Server, T-SQL, SQL Agent, etc., are all for manage data and databases, not server management. Application inventory should be managed through other apps (although the data is frequently stored in SQL Server).
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 6, 2014 at 9:31 am
You could probably query the registry through xp_regread, but as Grant mentioned, really this is managed elsewhere.
If you don't have access and you're troubleshooting, I'd go ask someone else that has access as you'll probably want to know if things are running, memory usage, etc.
January 6, 2014 at 10:02 am
Thanks a lot Bill.
Thanks Grant and Steve .
We are creating a report to all server and just want to know whether i can find the apps installed from SSMS.
Thanks everyone.
January 6, 2014 at 10:07 am
I'd agree with Grant and Steve, it's still something I'd keep out of SQL.
.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply