How to find out a user who is part of the SPGroups in a site collection using PowerShell.I want to pass the userid and get the names of groups where he is part of.Later I want to delete his id from all these SPGroups.I wrote the below code, but am not getting success.
$sitee= get-spsite "https://myDMS.mycompany.com"
$webb= $sitee.Rootweb
$inputusername ="in\userid"
$Allgroups = $webb.SiteGroups
foreach(singeGrp in $Allgroups)
{
SPUser muser = new-object SPUser
foreach(SPuser suser in singeGrp.Users)
{
if(suser.Loginname -eq muser.Loginname)
{
singeGrp.Delete();
}
}
}