BellevueAdmin
asked on
Powershell - how do I.....
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.ForegroundC olor
$host.UI.RawUI.ForegroundC olor = "Yellow"
$choice = Read-Host -Prompt $prompt
$host.UI.RawUI.ForegroundC olor = $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?
$prompt = @"
**************************
* *
* s = Search AD for deleted users *
* r = Restore user account *
* x = exit *
* *
**************************
"@
Clear-host
Do{
$originalcolor = $host.UI.RawUI.ForegroundC
$host.UI.RawUI.ForegroundC
$choice = Read-Host -Prompt $prompt
$host.UI.RawUI.ForegroundC
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?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.