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

  • Home
  • SEARCH
  • 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 8399775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:23:45+00:00 2026-06-09T21:23:45+00:00

I am writing a script which automatically provisions users in groups when the request

  • 0

I am writing a script which automatically provisions users in groups when the request is sent off. I am running a check to see if it is in a specific group out of a list or contains a phrase such as HDS. I cannot currently get the “contains” command working quite right for me. Here is what I got:

$memberof = get-QADMemberOf -Identity tpatry
if($memberof -contains "HDS" -eq $true){
Write-Host "User is already a member of one of the Job Roles"}

When I run this:

$memberof = get-QADMemberOf tpatry
Write-Host $memberof

I get these groups that I am part of. This is what $memberof returns:

USERS\Domain Users USERS\CCNet-HDS-ADMIN USERS\HDS-CP-STUDENT-ACL USERS\ME-513 USERS\HDS-IT-FTE-ACL USERS\MNE-STUDENTS-O USERS\HDS-ADMIN

When I run this, just gives me a new prompt to run another prompt to input my next command.

  • 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-09T21:23:47+00:00Added an answer on June 9, 2026 at 9:23 pm

    I’ll have to look up the documentation on -contains. Seems like I’ve seen it before, yet I always overlook, or forget, that one.

    Don’t know if the main issue has anything to do with what get-QADMemberOf is returning? I don’t have that function available to me, checking online looks like it might return a collection/list of objects, instead of a string? If its not a string, you may need to iterate through each item in the collection at test for the value your looking for.

    $groups = get-QADMemberOf -identity tpatry
    foreach($group in $groups)
    {
    
      # pipe one of them to gm (e.g. $group | gm) to get a list of properties
    
      if ($group.Name -like "*HDS*" -eq $true) 
      { 
           write-host "found" 
      }
    }
    

    If the return value IS a string, you can try the -like operator:

    $str = "this is a test"
    if ( $str -like "*test*" -eq $true )
    {
       write-host "found"
    }
    

    We can also drop to C# as needed:

    $str = "this is a test"
    if ($str.Contains("test") -eq $true )
    {
        write-host "found"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a fairly long running script, which prints progress messages as it goes.
I am writing a Ruby script which automatically crawls websites for data analysis, and
I am writing a script which is likely to be modified by users. Currently
I've been working on writing a script which automatically logs me into my school's
I am currently writing a script which parses the ServiceTage, Computername and Username from
I am writing a script which counts all files and folders recursively. I tried
I'm writing a script which is to be executed hourly. It basically works as:
I am writing python script which gets links from website. But when I tried
I'm writing a backup script which Copies the data to backup disk. Flushes the
I'm writing a Groovy script which uses third party java code that I can't

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.