# SQL Server Msg 15281: SQL Server blocked access to procedure 'sys.xp_cmdshell' (component 'xp_cmdshell' turned off)

**Code:** `15281` · **Category:** SQL · **Seen on:** SQL Server, Windows

xp_cmdshell is disabled by default for security, so the call is refused.

## Meaning

Enable it only if you must (`sp_configure 'show advanced options'`, then `xp_cmdshell`), restrict who can run it, or better, avoid it: use SQL Agent job steps, SSIS, PowerShell or an application layer instead. Msg 15281 also applies to Ole Automation and other surface-area options.

## Common causes

- xp_cmdshell disabled (default)
- Surface area configuration
- Needed for file/OS operations
- Proxy account not configured
- Security hardening policy

## Quick fix

1. Prefer SQL Agent/PowerShell instead
2. Enable only if justified with `sp_configure`
3. Restrict permissions and audit usage

## Detailed fix by platform

### SQL

1. 

```sql
EXEC sp_configure 'show advanced options', 1; RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;
```


## How to diagnose

1. **Option** — Disabled?
2. **Alternative** — Agent job?
3. **Access** — Restricted?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/sql/mssql-xp-cmdshell-disabled-15281)
