Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8938369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:36:34+00:00 2026-06-15T10:36:34+00:00

Quite simply, I’m trying to get a list of workspaces by calling the QueryWorkspaces

  • 0

Quite simply, I’m trying to get a list of workspaces by calling the QueryWorkspaces method of the VersionControlServer class in powershell. I’m passing null across to the parameters and according to the documentation it should give me a list of workspaces.

If I name the workspace it works fine and returns a single workspace but the documentation says a null name should give all the workspaces.

function Get-Workspace
{
    param
    (
        [Parameter(Mandatory=$true)]
        [string]$TeamProjectCollection,
        [string]$Owner,
        [string]$Computer,
        [parameter(ValueFromPipeline=$true)]
        [string]$Name
    )

    begin
    {    
        [Microsoft.TeamFoundation.Client.TfsTeamProjectCollection]$tfsTeamProjectCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($TeamProjectCollection)
        [Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer]$versionControlServer = $tfsTeamProjectCollection.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
    }

    process
    {
        Write-Output $versionControlServer.QueryWorkspaces($Name, $Owner, $Computer)
    }
}

I am running with Project Collection Administrator rights.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:36:35+00:00Added an answer on June 15, 2026 at 10:36 am

    The problem appears to be PowerShell does not pass null as null when the .net class is expecting string. Somewhere in the PowerShell layer the null was translated to an empty string. This prevented the code path which returns all the workspaces from executing. Instead it was trying to match a workspace called “”.

    The details of the issue are on a Microsoft Connect article which reports the issue to be fixed in PowerShell 3.0.

    Knowing what the problem and with hints on how to fix it I started down the Reflection route. However this got more complicated because the QueryWorkspaces method is overloaded so a simple call to GetType threw an exception. Attempts to pass the array of types into the GetType call failed because PowerShell passed it as an array of Object instead of an array of Type. Thus it had to be done long hand …

    function Get-Workspace
    {
        param
        (
            [Parameter(Mandatory=$true)]
            [string]$TeamProjectCollection,
            [string]$Owner,
            [string]$Computer,
            [parameter(ValueFromPipeline=$true)]
            [string]$Name
        )
    
        begin
        {    
            [Microsoft.TeamFoundation.Client.TfsTeamProjectCollection]$tfsTeamProjectCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($TeamProjectCollection)
            [Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer]$versionControlServer = $tfsTeamProjectCollection.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
            [array]$methods = $versionControlServer.GetType().GetMethods()
            [System.Reflection.MethodInfo]$methodToInvoke = $null
            foreach($method in $methods)
            {
                if ($method.Name -eq "QueryWorkspaces")
                {
                    if ($method.GetParameters().Length -eq 3)
                    {
                        $methodToInvoke = $method
                    }
                }
            }
        }
    
        process
        {
            if ([string]::IsNullOrEmpty($Name))
            {
                $params = @($null, $Owner, $Computer)
                Write-Output $methodToInvoke.Invoke($versionControlServer, $params)
            }
            else
            {
                Write-Output $versionControlServer.QueryWorkspaces($Name, $userName, $computerName)
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is quite frustrating. I am simply trying to create a dynamic text and
Quite simply, when designing a new class, how do I figure out what the
Quite simply, I want an ordered list to work like this: 1. Foo 2.
Quite simply: > powershell.exe -command & '\\RemoteServer\c$\My Script.ps1' does not work at all. My
Quite simply my question is as the title: Is there any way to get
Quite simply, I'm trying to connect to a MongoDB via Node.js: Db = require('../v2/node_modules/mongodb').Db
I'm trying to quite simply take the number that is inside the variable $output
Quite simply this is my question: class A(models.Model): x = DateTimeField(...) class B(models.Model): x
Quite simply, I'm trying to generate and download a CSV file from a CakePHP
So quite simply, the question is how to get the system boot up time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.