I need help fixing this PowerShell script

I am creating a script that should be able to delete a specified Active Directory User. If no user is specified then it will prompt before deleting all users. If the user name is misspelled then it will error and say “User not found” I have the script here but it wont let me search a user for deletion by username, it only lets me use their first name which can be problem some for a bigger business. I also cant get the script to delete all the users. I am having a hard time finding someone who can help me. I’ve been working on this so long I dream about it. I honestly don’t know what I am doing wrong. Please help me. Thank you

Locates specified accounts for deletion
Locates specified accounts for deletion
Get-DELUSER [username]

$DN = "DC=AD-4313,DC=itnsntc,DC=org"
$Users = Get-ADUser -filter * -SearchBase $DN | Select-Object -Property samaccountname

Function Get-DELUSER {
    #create array to add multiple users for deletion
    $temp = @()
    do {
        $user = Read-Host "Enter the users first name "
        if ($user -ne '') {
            $temp += $user + "*"

    }until($user -eq '')

    foreach ($user in $temp) {
        #search through the users for each user in $temp array and set $userfullname to that users name.
        if (dsquery user -name $user ) {
            $userfullname = Get-ADUser -filter {name -like $user} -Properties DisplayName | Select-Object Name -ExpandProperty name
            #set usersamacctname to the user sam id for deletion
            $usersamacctname = Get-ADUser -filter {name -like $user} -Properties Samaccountname | Select-Object samaccountname -ExpandProperty samaccountname
            Write-Output "User '$userfullname' will be removed from AD"
            #Removes user account from Active Directory.
            Remove-ADUser $usersamacctname -Confirm:$false
        #else command handles errors
        else {Write-Output "User '$user' not found"}
    If ($user -eq '') {
        Write-Output "User '$Users' has been removed"
        Remove-ADUser $Users -confirm 

The more i look at this script,

the scarier it gets.


Why search on first name ?

So user “a A” is the same as “a B” ?

and why delete all?