Trigger this skill for SharePoint Online — PRIMARILY the documents shared inside a GROUP/TEAM: the files in a team's "Shared Documents" library (the Files tab in Teams), said as "tài liệu nhóm", "tài liệu/file chia sẻ trên nhóm/team", "file của team X", "file trong nhóm", "Shared Documents", "thư viện tài liệu". Also covers SharePoint lists & list items, site files/folders (upload/download/checkin/checkout/copy/move), permissions, and creating sites. Fire whenever a request targets a TEAM/GROUP's files or a SharePoint site — đọc/list, tải lên (upload), tạo/xóa file & folder, tạo list, thêm item, chia sẻ link, phân quyền. Casual or unaccented phrasing still counts. This is SHARED/organizational storage, NOT personal — send the user's own private OneDrive ("onedrive của tôi", "lên onedrive cá nhân") to m365-onedrive. For Teams chat/channels/members (gửi tin nhắn, tạo channel, thành viên team) use m365-teams; for Google Drive use gws-drive.
Trigger this skill for SharePoint Online — PRIMARILY the documents shared inside a GROUP/TEAM: the files in a team's "Shared Documents" library (the Files tab in Teams), said as "tài liệu nhóm", "tài liệu/file chia sẻ trên nhóm/team", "file của team X", "file trong nhóm", "Shared Documents", "thư viện tài liệu". Also covers SharePoint lists & list items, site files/folders (upload/download/checkin/checkout/copy/move), permissions, and creating sites. Fire whenever a request targets a TEAM/GROUP's files or a SharePoint site — đọc/list, tải lên (upload), tạo/xóa file & folder, tạo list, thêm item, chia sẻ link, phân quyền. Casual or unaccented phrasing still counts. This is SHARED/organizational storage, NOT personal — send the user's own private OneDrive ("onedrive của tôi", "lên onedrive cá nhân") to m365-onedrive. For Teams chat/channels/members (gửi tin nhắn, tạo channel, thành viên team) use m365-teams; for Google Drive use gws-drive.
allowed-tools
["Bash","Read"]
m365-sharepoint — SharePoint Online Management
Prerequisites
which m365 || echo"Chưa cài m365 CLI. Chạy: npm i -g @pnp/cli-microsoft365"
m365 status || echo"Chưa đăng nhập. Chạy: m365 login"
For auth details, see ../m365-shared/references/authentication.md.
Operating Principles
All commands require --webUrl pointing to the SharePoint site URL
Output: always -o json with --query
List/library identification: prefer for readability, when title is ambiguous
--listTitle
--listId
File/folder URLs: can be server-relative (/sites/project/Shared Documents/file.pdf) or site-relative (Shared Documents/file.pdf)
Destructive operations (remove, delete): always confirm with user first
1. Sites
Trường hợp phổ biến nhất là truy cập tài liệu của một nhóm/team bạn là thành viên (KHÔNG cần quyền admin). Resolve site URL của nhóm qua Graph rồi dùng làm SITE_URL cho mục 4. Files / 5. Folders. Tài liệu nhóm nằm trong thư viện "Shared Documents" (tab Files trong Teams).
Resolve Team/Group Site URL (non-admin)
# 1. Liệt kê các nhóm/team bạn tham gia, lấy group id
m365 teams team list --joined -o json --query '[].{id:id, name:displayName}'# 2. Lấy SITE_URL (webUrl) của nhóm từ group id — non-admin, dùng cho mọi lệnh spo bên dưới
m365 request --url 'https://graph.microsoft.com/v1.0/groups/<GROUP_ID>/sites/root?$select=webUrl' -o json --query 'webUrl'# vd: https://miichisoftjsc.sharepoint.com/sites/AICLUB
List Sites (admin)
spo site list cần quyền SharePoint Administrator — user thường nhận lỗi Unauthorized. Để làm việc với tài liệu nhóm, dùng cách resolve site qua group ở trên.
# All sites
m365 spo site list -o json --query '[].{url:Url, title:Title, template:Template}'# Team sites only
m365 spo site list --type TeamSite -o json --query '[].{url:Url, title:Title}'# Communication sites only
m365 spo site list --type CommunicationSite -o json --query '[].{url:Url, title:Title}'# Filter by URL
m365 spo site list --filter "Url -like 'project'" -o json --query '[].{url:Url, title:Title}'
Get Site Details
m365 spo site get --url "https://contoso.sharepoint.com/sites/project" -o json
Create Site
# Team site (default)
m365 spo site add --type TeamSite --title "New Project" --alias"new-project" \
--description "Project collaboration site" -o json
# Communication site
m365 spo site add --type CommunicationSite --title "Company News" \
--url "https://contoso.sharepoint.com/sites/company-news" -o json
# Team site with owners
m365 spo site add --type TeamSite --title "HR Team" --alias"hr-team" \
--owners "admin@contoso.com" -o json
# Classic site (with wait)
m365 spo site add --type ClassicSite --title "Archive" \
--url "https://contoso.sharepoint.com/sites/archive" \
--timeZone 4 --wait -o json
2. Lists
List All Lists
m365 spo list list --webUrl "SITE_URL" -o json \
--query '[].{id:Id, title:Title, items:ItemCount, template:BaseTemplate}'# Filter by template
m365 spo list list --webUrl "SITE_URL" --filter "BaseTemplate eq 100" -o json \
--query '[].{id:Id, title:Title}'
Get List Details
# By title
m365 spo list get --webUrl "SITE_URL" --title "Tasks" -o json
# By ID
m365 spo list get --webUrl "SITE_URL" --id"LIST_GUID" -o json
# With permissions
m365 spo list get --webUrl "SITE_URL" --title "Tasks" --withPermissions -o json
# Confirm with user first! (option đúng là --url, KHÔNG phải --folderUrl)
m365 spo folder remove --webUrl "SITE_URL" --url "Shared Documents/Unwanted" --force
6. Permissions
List Site Users
m365 spo user list --webUrl "SITE_URL" -o json \
--query '[].{id:Id, name:Title, email:Email, login:LoginName}'
List Site Groups
m365 spo group list --webUrl "SITE_URL" -o json \
--query '[].{id:Id, name:Title, owner:OwnerTitle}'# Only associated groups (Owners, Members, Visitors)
m365 spo group list --webUrl "SITE_URL" --associatedGroupsOnly -o json
Get Group Members
m365 spo group member list --webUrl "SITE_URL" --groupId GROUP_ID -o json \
--query '[].{id:Id, name:Title, email:Email}'
m365 spo group member list --webUrl "SITE_URL" --groupName "Project Members" -o json
Add User to Group
m365 spo group member add --webUrl "SITE_URL" --groupName "Project Members" \
--userNames "user@contoso.com"# Add multiple users
m365 spo group member add --webUrl "SITE_URL" --groupName "Project Members" \
--userNames "user1@contoso.com,user2@contoso.com"
Remove User from Group
m365 spo group member remove --webUrl "SITE_URL" --groupId GROUP_ID \
--userName "user@contoso.com" --force