Question: Nowhere have I found anyone attempting to prompt for first and last names and then put that into a variable with a wildcard.

If I substitute real values with the asterisk, it works but attempting to do so with a variable returns nothing.

```
$LastName = Read-Host "Enter user's Last Name" 
$FirstName = Read-Host "Enter users's First Name" 

$GroupMembershipList = (Get-ADUser -Filter {(GivenName -like $FirstName*) -and (Surname -like $LastName*)}).SAMAccountName

Foreach ($Name in $GroupMembershipList) {

  $GroupMemberShip = Get-ADPrincipalGroupMembership -Identity "$Name" | Sort Name |ForEach-Object {$_.name -replace ".*:"} 
  $FullName = Get-ADUser $Name -Properties * | Select -Property DisplayName 
  $UserPrincipalName = Get-ADUser $Name -Properties * | Select -Property UserPrincipalName

  #Write-Output $PrincipalName
  Write-Output $FullName
  Write-Output $Name
  Write-Output $GroupMembership
  Write-Output " "

}

```

Answer: 
I used the second suggestion and it worked. I am new to PS and also to programming in general.

I find PS confusing at times regarding the placement of parenthesis, brackets, etc. I generally have the logic but mess up on placing these delimiters.

You mentioned formatting my code. I am sorry I don't know what you mean by that.

Also, I would rather use Write-Host to allow for formatting but when I do, all of the data is on a single line and the user returned is specified as @{DisplayName=Doe, John}.

Can you address that or should this be posted to a new subject?

I worked on it more and figured the Write Host stuff. Also added a Do Loop

```
$ErrorActionPreference = "Stop"
$Continue = "Quit"

Do {

$LastName = Read-Host "Enter user's Last Name" 
$FirstName = Read-Host "Enter users's First Name" 
$GroupMembershipList = (Get-ADUser -Filter "GivenName -like '$FirstName*' -and Surname -like '$LastName*'").SamAccountName

    Foreach ($Name in $GroupMembershipList) {

    $GroupMemberShip = Get-ADPrincipalGroupMembership -Identity "$Name" | Sort Name |ForEach-Object {$_.name -replace ".*:"} 

    Write-Host " "
    Write-Host $FirstName, $LastName -ForegroundColor Yellow
    Write-Host IMC UserName = $Name 
    Write-Host "*****************************" -ForegroundColor Red
    Write-Host "Groups $Firstname $LastName is a member of:" -ForegroundColor Yellow
    $GroupMembership 
    Write-Host " " 

}

$Continue = Read-Host "Do you want to check another name? (Y/N)"

    If($Continue -eq "Y"){
    }
}
until ($Continue -eq "N")

```
```
$GivenName = read-host "What's the users first name (wildcard * ok)?"
$Surname = read-host "What's the users last name (wildcard * ok)?"
Get-ADUser -filter{(Surname -like $Surname -and GivenName -like $GivenName)} -properties GivenName, Surname, UserPrincipalName, mobile

```