Friday, September 10, 2010

Access Blocked To xp_cmdshell

Hello and welcome back!...

Today I was attempting to execute a stored procedure in SQL Server 2008 R2 that calls xp_cmdshell to get a directory listing and I received the following error message:

SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell'

Now there are 2 ways to enable xp_cmdshell in SQL Server 2008 R2 they are:
1. In a query window execute the following t-sql:
exec sp_configure 'xp_cmdshell', '1'
reconfigure with override
go
2. The other way is through SQL Server Management Studio (SSMS). Here are the
steps to enable xp_cmdshell through SSMS:

Step 1 - In Management Studio connect to a component of SQL Server
Step 2 - In Object Explorer, right-click the server, and then click Facets
Step 3 - In the View Facets dialog box, expand the Facet list, and select
Surface
Area Configuration
Step 4 - The last in the list is XPCmdShellEnabled and you want to select this to read 'Yes'
and then click OK. Here is a screenshot of this Facet:



0 comments:

  © Blogger template 'A Click Apart' by Ourblogtemplates.com 2008

Back to TOP