I'm using the following
$prompt = @"
***************************************************
* *
* s = Search AD for deleted users *
* r = Restore user account *
* x = exit *
* *
***************************************************
"@
Clear-host
Do{
$originalcolor = $host.UI.RawUI.ForegroundColor
$host.UI.RawUI.ForegroundColor = "Yellow"
$choice = Read-Host -Prompt $prompt
$host.UI.RawUI.ForegroundColor = $originalcolor
Switch($choice){
s {Get-ADObject -Filter {displayName -eq "John Doe"} -IncludeDeletedObjects}
r {Get-ADObject -Filter {displayName -eq "John Doe"} -IncludeDeletedObjects | Restore-ADObject}
x {break}
default {write-host "Invalid selection, please try again." -ForegroundColor Red}
}
}Until($choice -eq "x")
To search for and restore deleted ADObjects, specifically user accounts.
However, as you can see I want to make this into a menu that can be used by others, and I don't want them playing with the code so I would like to make it ask them to enter the display name rather than it being hard coded in the script.
Does anyone have a way of doing this without making the user have to do more than select the option and type the name?