Skip to content

Set-MgmtGraphUserMailFolderChildFolder

MgmtGraph: Updates child mail folder properties

#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.Mail

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $true, Position = 0)]
    [string]$Identity,

    [Parameter(Mandatory = $true)]
    [string]$MailFolderId,

    [Parameter(Mandatory = $true)]
    [string]$ChildFolderId,

    [Parameter(Mandatory = $true)]
    [string]$DisplayName
)

Process {
    try {
        $params = @{
            'UserId'       = $Identity
            'MailFolderId' = $MailFolderId
            'MailFolderId1' = $ChildFolderId
            'DisplayName'  = $DisplayName
            'Confirm'      = $false
            'ErrorAction'  = 'Stop'
        }

        Update-MgUserMailFolderChildFolder @params
        
        $result = [PSCustomObject]@{
            UserId        = $Identity
            ParentId      = $MailFolderId
            ChildFolderId = $ChildFolderId
            DisplayName   = $DisplayName
            Action        = "ChildFolderUpdated"
            Status        = "Success"
            Timestamp     = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        }

        Write-Output $result
    }
    catch {
        throw
    }
}

Specifies the UserPrincipalName or ID of the user.

Specifies the ID of the parent mail folder.

Specifies the ID of the child folder to update.

Specifies the new display name for the child folder.

An interactive directory of PowerShell scripts.