Skip to content

Return Different value then when is shown in -Entries #6

@Joepiler11

Description

@Joepiler11

Hi,

I was wondering if it's possible to return a different property from the initial variable?

Here I am using the property displayname to build the menu (because in this case they are more readable) but what i need to extract based on the script user's input is the .userprincipalname from my initial get-msoluser command.

``function Search-User {
Param ($Question )

Write-Host $Question`n
$Answer = Read-Host "User"
$Result = Get-MsolUser -SearchString "$Answer"
    switch ($Result.count)
    {
        {$_ -eq 0} {
            Write-Host "`nUser not found!" -ForegroundColor Red
            Start-Sleep -Seconds 3
            $Output = $null
            Break;
        }
        {$_ -gt 1} {
            $Output = Write-Menu -Title "Select the user you want to add" -Entries $Result.DisplayName
            Break;
        }
        Default {
            $Output = $Result.UserPrincipalName
            Break;
        }
    }
Return $Output

}``

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions