# Enable PowerShell Script Execution

You need to enable PowerShell script execution to use the Continuous Delivery system.

## Quick Fix (Recommended)

Run this **one-time command** in PowerShell **as Administrator**:

```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```

This allows you to run local scripts while still protecting against remote scripts.

### Step-by-Step:

1. **Right-click** the **Start Menu** or press `Win+X`
2. Select **"Windows PowerShell (Admin)"** or **"Terminal (Admin)"**
3. When UAC prompts, click **Yes**
4. Run: `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`
5. Type `Y` and press Enter
6. Close the admin window
7. Go back to your normal PowerShell terminal
8. Run: `.\start-cd.ps1 watch`

## Alternative: No Admin Required (Bypass Method)

If you **can't get admin access**, use the bypass method for each run:

```powershell
# Instead of:
.\start-cd.ps1 watch

# Use this:
powershell -ExecutionPolicy Bypass -File .\start-cd.ps1 watch
```

### Create a Shortcut (No Admin)

Create `run-cd-watch.bat` with this content:

```batch
@echo off
powershell -ExecutionPolicy Bypass -File "%~dp0start-cd.ps1" watch
pause
```

Then just double-click `run-cd-watch.bat` to start CD!

## Verify It's Working

After enabling, run:

```powershell
Get-ExecutionPolicy
```

Should show: `RemoteSigned` or `Bypass`

Then test the CD system:

```powershell
.\start-cd.ps1 watch
```

## Security Notes

**What does RemoteSigned mean?**
- ✅ You can run scripts you create locally
- ✅ You can run scripts from your organization
- ⚠️ Downloaded scripts must be signed by a trusted publisher
- ✅ This is the Microsoft-recommended policy for developers

**Is this safe?**
Yes! `RemoteSigned` is the recommended policy for developers. It protects you from running malicious scripts downloaded from the internet while allowing you to run your own scripts.

## Troubleshooting

**Still getting "UnauthorizedAccess"?**

Try this sequence:

```powershell
# Check current policy
Get-ExecutionPolicy -List

# Set for current user only (no admin needed)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

# If that fails, use bypass method
powershell -ExecutionPolicy Bypass -File .\start-cd.ps1 watch
```

**Group Policy is blocking?**

Some corporate environments block script execution via Group Policy. If you see "cannot be changed" errors, you must use the bypass method:

```powershell
powershell -ExecutionPolicy Bypass -File .\start-cd.ps1 watch
```

---

**Once enabled**, you're ready to use the CD system! See [CD_QUICK_START.md](CD_QUICK_START.md) for usage.
