Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Joepiler11 opened this issue Feb 15, 2023 · 0 comments
Open

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

Joepiler11 opened this issue Feb 15, 2023 · 0 comments

Comments

@Joepiler11
Copy link

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

}``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant