Very new to UD, ive got the enterprise license, and trying to port over a working console app that simply takes a search string and drops it in the “-Filter” value while running Get-ADUser.
Maybe by posting my console version, you guys can see what im trying to mimic. Just want a New-UDInput form to take $searchString and then try to find all the results it can from AD and output that to a grid or some other element that lets you choose final member to actually run the mfh-disableUser portion of my search script…which in turn runs a lot of other stuff when offboarding a user…like any 3rd party software we disable via API’s, removing dist lists, azure groups, running AD Sync afterwards, moving to a disabled OU, ect… below is just the search portion…if i could get a UD form wired up this way it would be awesome.
param($searchString)
$wildCard = "*"
$searchString = $wildCard + $searchString + $wildCard
try {
[array] $result = Get-ADUser -filter {name -like $searchString} -Properties * -server \\redacted
Write-Host " "
if ($result){
$menu = @{}
for ($i=1;$i -le $result.count; $i++)
{
$menu.Add($i,($result[$i-1].DistinguishedName))
Write-Host "$i. $($result[$i-1].name),$($result[$i-1].Samaccountname),$($result[$i-1].DistinguishedName)"
Write-Host " "
}
[int]$ans = Read-Host 'Enter selection number to DISABLE!'
$selection = $menu.Item($ans)
$user = Get-ADUser -Identity $selection -server \\redacted
mfh-disableUser -loginName $user.SamAccountName
}
}
catch {
Write-Host No results found with $searchString -ForegroundColor Yellow}