Try below PowerShell.
#Variables
$SiteURL = "site URL"
$LibraryName = "library name"
$FolderName = "folder name"
Try {
#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
#Get the Library
$Library = $Ctx.web.Lists.GetByTitle($LibraryName)
$Folders = $Library.RootFolder.Folders
$Ctx.Load($Folders)
$Ctx.executeQuery()
#Get the Folder by Name
$Folder = $Folders | Where {$_.Name -eq $FolderName}
$Ctx.Load($Folder)
$Ctx.ExecuteQuery()
#Get Some Folder Properties
Write-host -f Green "Folder URL:"$Folder.ServerRelativeUrl
}
Catch {
write-host -f Red "Error Getting Folder!" $_.Exception.Message
}
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.