Sitecore PowerShell Extensions (SPE) là một module mạnh mẽ cho phép chạy PowerShell trực tiếp trong Sitecore để:
✔ Tự động tạo/thay đổi hàng loạt item
✔ Triển khai template, rendering, Media Item
✔ Xử lý case migration & cleanup
✔ Hỗ trợ DevOps/CI/CD
✔ Quản trị user/role
✔ Sinh report, kiểm tra broken link
✔ Tích hợp Ribbon tùy chỉnh trong Content Editor
SPE là công cụ bắt buộc phải biết khi làm việc chuyên sâu với Sitecore.
SPE là module mở rộng cung cấp:
PowerShell ISE (trong Sitecore Desktop)
PowerShell Toolbox
Script Library
Integration vào Context Menu, Ribbon
Job Runner cho script lâu
API PowerShell mạnh mẽ cho Sitecore
Thông qua Sitecore Marketplace hoặc Sitecore Install Assistant (SIA):
🟦 Tên module:Sitecore PowerShell Extensions
Thường cài trên cả CM lẫn CD nếu cần, nhưng CD chỉ cần cài runtime (không cần ISE).
Truy cập:
Desktop → PowerShell ISE
Content Editor → PowerShell Toolbox
Start Menu: Development Tools → PowerShell ISE
Trong PowerShell ISE, bạn có đầy đủ script editor + autocomplete.
SPE lưu script giống như item trong Content Tree:
Trong đây có:
Scripts
Tasks
Reports
Functions
Menu Items
Content Editor
Integration Points
Bạn có thể:
✔ Tạo script mới
✔ Tạo script automation chạy theo menu chuột phải
✔ Gắn script vào Ribbon
SPE có built-in command cho việc này.
Bạn có thể thêm script vào:
Ví dụ tạo Menu Item:
Copy script vào:
Chọn Integration Point → Context Menu
Chọn rule hiển thị (ví dụ: chỉ hiện khi chọn Template XYZ)
Nếu script chạy lâu → SPE tự động chuyển sang Background Job:
| Tình huống | SPE có lợi? |
|---|---|
| Update 1000+ item field | ✔✔✔ |
| Clone structure từ môi trường UAT → DEV | ✔✔✔ |
| Migrate content giữa project | ✔✔✔ |
| Cleanup media, broken link | ✔✔ |
| Fix permission | ✔✔ |
| Import/export JSON | ✔ |
Hôm nay bạn đã học:
PowerShell Extension là gì
Tại sao SPE quan trọng
Cấu trúc Script Library
Các lệnh PowerShell cho Sitecore
Script thực tế dùng trong dự án
Tích hợp SPE vào Content Editor
Best practices