Searching Queued Builds on a given Agent / Controller

I am trying to retrieve queued builds from TFS Server using the IBuildServer Interface. However I am not able to retrieve queued builds on specific agents for a given controller. That is required because if there is a build in progress the Cache Deletion should not happen.

$tfsservername = 'TFS LINK'


$server = new-object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(New-Object Uri($tfsservername)) 
# creating TFSServer Instance
$buildServer = $server.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer]) 

$spec = $buildServer.CreateBuildQueueSpec('*','*')
$build = $buildServer.QueryQueuedBuilds($spec).QueuedBuilds

I tried searching for methods of IBuildServer but there is no method that links Agents and Queued Builds.

I want to use IQueuedBuild Interface here but i don’t know how to use it.

Any suggestions how can i find Queued builds on an specific agent ?