Even if you tell the installer not to do so, the installer for XenApp 6.5 
creates 15 anonymous accounts. A customer wants those accounts deleted. I found 
this article 
https://mcpmag.com/articles/2015/05/07/local-user-accounts-with-powershell.aspx 
and based the script on their snippet:

Deleting an Account
Deleting a user account can be accomplished in a similar manner that we took to 
create an account. By using the ADSI WinNT provider we will connect to the 
system and then instead of using Create() to build an account, we will make use 
of Delete() instead.
The Delete method takes arguments similar to what Create took. We supply the 
schema type of User and the username of the account.
$Computername = $env:COMPUTERNAME

  $ADSIComp = [adsi]"WinNT://$Computername"

$ADSIComp.Delete('User','TestProx')

The main part of my script is:

add-pssnapin Citrix.XenApp.Commands

$Servers = Get-XAServer -ea 0 | Select ServerName | Sort ServerName

If($? -and $Null -ne $Servers)
{

$AnonAccounts = {"Anon000","Anon001","Anon002","Anon003","Anon004",
"Anon005","Anon006","Anon007","Anon008","Anon009",
"Anon010","Anon011","Anon012","Anon013","Anon014"}

ForEach($Server in $Servers)
{
                                Write-Host "Processing server 
$($Server.ServerName)"
                                $ADSIComp = [adsi]"WinNT://$Server"
                                ForEach($AnonAccount in $AnonAccounts)
                                {
                                                
$ADSIComp.Delete('User',"$($AnonAccount)")
                                }
}
}

Does that look like it will delete those accounts on the remote servers?

Thanks


Webster



Reply via email to