28 lines
755 B
PowerShell
28 lines
755 B
PowerShell
|
## AI Generated
|
||
|
|
||
|
# Replace with your actual values
|
||
|
$siteID = "mpeeng.sharepoint.com,a39156fa-de97-42ae-b37e-8d2798786586,2b81c888-6319-4649-b505-c26225324fb8"
|
||
|
$parentItemID = "your-parent-item-id"
|
||
|
$accessToken = "your-access-token"
|
||
|
|
||
|
# API endpoint
|
||
|
$url = "https://graph.microsoft.com/v1.0/sites/$siteID/drive/items/$parentItemID/children"
|
||
|
|
||
|
# Folder details
|
||
|
$folder = @{
|
||
|
name = "New Folder"
|
||
|
folder = @{}
|
||
|
"@microsoft.graph.conflictBehavior" = "rename"
|
||
|
}
|
||
|
|
||
|
# Convert folder details to JSON
|
||
|
$folderJSON = $folder | ConvertTo-Json
|
||
|
|
||
|
# Create HTTP request
|
||
|
$response = Invoke-RestMethod -Uri $url -Method Post -Headers @{
|
||
|
Authorization = "Bearer $accessToken"
|
||
|
'Content-Type' = 'application/json'
|
||
|
} -Body $folderJSON
|
||
|
|
||
|
# Output response
|
||
|
$response
|