none
Supply multiple values to Role parameter of get-rdserver RRS feed

  • Question

  • This is going to seem stupid, but I've already wasted too much time on this... I'm trying to user get-rdserver to list out certain types of servers, being the connection brokers and the actual rd hosts. It says I can use an array of names of RDS service roles, but I can't for the life of me figure out how to specify it and have it work. I've tried just a space between values, a comma, setting up the value as a string array...but no luck. It usually comes back with nothing (literally, no error, no results). IF I specify "either" of these values, it works...I need a list of both. Help me, no coffee yet this am! :)

    get-rdserver -ConnectionBroker myserver -Role RDS-CONNECTION-BROKER,RDS-RD-SERVER

    mpleaf


    • Edited by mpleaf Wednesday, May 28, 2014 3:30 PM
    Wednesday, May 28, 2014 3:27 PM

Answers

  • That's right, assuming the -role parameter is declared as [String[]]. If it's [String], then you'll need to do


    "RDS-CONNECTION-BROKER","RDS-RD-SERVER" | foreach-object {
      get-rdserver -connectionbroker myserver -role $_
    }
    


    -- Bill Stewart [Bill_Stewart]

    Wednesday, May 28, 2014 4:45 PM
    Moderator

All replies

  • Run the command twice with two separate roles.

    -- Bill Stewart [Bill_Stewart]

    Wednesday, May 28, 2014 3:41 PM
    Moderator
  • get-rdserver -ConnectionBroker myserver -Role 'RDS-CONNECTION-BROKER','RDS-RD-SERVER'

    When you use an array you need to use explicit strings I believe.

    This is why:

    PS C:\scripts> $roles=RDS-CONNECTION-BROKER,RDS-RD-SERVER
    At line:1 char:29
    + $roles=RDS-CONNECTION-BROKER,RDS-RD-SERVER
    +                             ~
    Missing argument in parameter list.
        + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : MissingArgument
    
    PS C:\scripts> $roles='RDS-CONNECTION-BROKER','RDS-RD-SERVER'
    PS C:\scripts> $roles
    RDS-CONNECTION-BROKER
    RDS-RD-SERVER
    PS C:\scripts>


    ¯\_(ツ)_/¯

    Wednesday, May 28, 2014 4:35 PM
  • That's right, assuming the -role parameter is declared as [String[]]. If it's [String], then you'll need to do


    "RDS-CONNECTION-BROKER","RDS-RD-SERVER" | foreach-object {
      get-rdserver -connectionbroker myserver -role $_
    }
    


    -- Bill Stewart [Bill_Stewart]

    Wednesday, May 28, 2014 4:45 PM
    Moderator
  • Nope = this way:

    get-rdserver -ConnectionBroker myserver -Role 'RDS-CONNECTION-BROKER','RDS-RD-SERVER'

    He wants the server that has BOTH roles. 

    When not quoting the roles argument is not understandable and matches nothing.


    ¯\_(ツ)_/¯

    Wednesday, May 28, 2014 4:55 PM
  • The parameter Role is defined as:

    -Role<String[]>

    Specifies an array of names of RDS service roles

    Now, actually I want a list of servers that are either RDS-CONNECTION-BROKER, "or" RDS-RD-SERVER. So, I think jrv you hit the nail on the head. What I did was get the servers that are both, in which case, there are none. Which is why it does not error, and comes back with nothing. It appears that Bill's script does what I need, to get a list of both types. So, I learned that specifying the -Role as an array, means it must match "both values then?

    Thanks guys!

    mpleaf

    Wednesday, May 28, 2014 5:06 PM