I have a function that works great from powershell to remove users. I can type remove-user and am prompted for system name, and then username. so it works great, and removes the user. I'd like to be able to use another script to use the function to remove several accounts from many servers. So I wrote this:
$computer = get-content servers.txt
$user = get-content users.txt
Remove-LocalUser $computer $user
When I run it (from the same powershell session that works just fine 'manually'.
When I use the above script, It posts "user not found".
If I check the system the user is there, and if I then use the function manually, it deletes the account.
I am sure I need to add more to my script, what do I need?