Nexus
(Fresh Scripter)
2006-09-13 08:26 PM
How remove old Serverprofiles

Hi

How can remove old Serverprofiles.

read in the ADS all user and compare with serverprofiles. If serverprofile (Folder) not equal with username remove this serverprofile.


Mart
(KiX Supporter)
2006-09-13 09:02 PM
Re: How remove old Serverprofiles

Do you mean user profiles that are created when a users logs onto the server for example on a terminal server or do you mean the roaming profiles folders?

Nexus
(Fresh Scripter)
2006-09-14 04:56 PM
Re: How remove old Serverprofiles

Hi

I mean roaming profiles folders.

Nexus


Witto
(MM club member)
2006-09-14 05:03 PM
Re: How remove old Serverprofiles

I think I read something about this on the microsoft web pages
Group Policy Recommendations for Roaming User Profiles
Is this helpfull to you?


therob
(Starting to like KiXtart)
2006-09-15 05:30 PM
Re: How remove old Serverprofiles

Yes, GPOs are the best way to go.
If you can't/won't use GPOs, there a tool that can delete profiles:
DelProf

But if i understand it right, you have a bunch of old profiles on your profile-share, and the useraccounts which they belonged to are already gone?
Mhm, that would be not an fast and easy task, but depends on how many profiles you got, if its faster to do it manually. For the future i would implement somthing that deletes them automatically if a user gets deleted.

If it has to be scripted, you would need to read all users from AD, read all the folder names and compare them to each other. At least for the first two tasks (if not for all) you find UDFs here in the forum, for the third i could help you.


Nexus
(Fresh Scripter)
2006-09-26 08:46 AM
Re: How remove old Serverprofiles

No, I meant the user profiles on the server are filed.

For example:

\\server\Profiles$\username

Check in the Active Directory the users and compare the userprofile on the server, if not the same delete userprofile.


Witto
(MM club member)
2006-09-26 09:06 AM
Re: How remove old Serverprofiles

I think you want to list all your existing domain users and check for every directory in \\server\Profiles$\ if it is in this list. If it is not, do something to delete it.

Nexus
(Fresh Scripter)
2006-09-26 11:04 AM
Re: How remove old Serverprofiles

yes, that is what i mean

therob
(Starting to like KiXtart)
2006-09-26 01:59 PM
Re: How remove old Serverprofiles

isnt that what i said?

Anyway, for reading all the foldernames into a file, you can use this: DirPlus ()

Then, the easiest way would be to check for every User/Foldername in the AD (depends on how many users you've got, if its a too heavy load for your DC) For this you could e.g. use that simple UDF:

Code:

Function userexist ($adloginname)

$userpath = "LDAP://cn="+$adloginname+",ou=OrganisationUnit,dc=subdomain,dc=domain,dc=com"
$UserObj = GetObject($userpath)

If @ERROR
$accountexist = 0
Else
$accountexist = 1
EndIf

EndFunction




But there are multiple ways, depending on your needs. You can also read all memebers of a certain group (AllUSERS) to a file and compare them to the folderfile, or just check for groupmembership with INGROUP (). And so on...


NTDOCAdministrator
(KiX Master)
2006-09-26 09:10 PM
Re: How remove old Serverprofiles

Or just quit using ROAMING profiles period.

I know a lot of places use them, just glad I don't work at any of those locations.

SLOW SLOW SLOW PITA


therob
(Starting to like KiXtart)
2006-09-26 10:16 PM
Re: How remove old Serverprofiles

right, but i guess thats not an option here. But, sometimes RP are the only way to go, e.g. in a terminalserver environment.

Witto
(MM club member)
2006-09-26 10:21 PM
Re: How remove old Serverprofiles

Doc,
What if you have some (citrix) terminal servers (in a farm) hosting the same soft? Isn't it preferable getting the same environment back as you left it?


therob
(Starting to like KiXtart)
2006-09-26 10:24 PM
Re: How remove old Serverprofiles

You don't believe me very easily, witto, do you?

Witto
(MM club member)
2006-09-26 10:27 PM
Re: How remove old Serverprofiles

Sorry, was a bit too long on this page and had not seen your answer yet.
I think I just had the same thought.


NTDOCAdministrator
(KiX Master)
2006-09-26 10:52 PM
Re: How remove old Serverprofiles

Terminal Server is not the same as Roaming Profiles (imho, though MS may beg to differ, I see it as a LOCAL profile on a TS)

I mean there are shops that use Roaming Profiles on their local Workstations with no TS involved.
To me that is a real Roaming Profile - and I personally don't care for them myself.


therob
(Starting to like KiXtart)
2006-09-26 11:16 PM
Re: How remove old Serverprofiles

Quote:

Terminal Server is not the same as Roaming Profiles (imho, though MS may beg to differ, I see it as a LOCAL profile on a TS)




mhm i'm not sure i got ya. For the terminalserver profiles, its quite the same, as the TS emulates your local PC (if you using a published app or even a desktop). You can store the profiles on the TS (thats the default, without roaming), but then you would have a profile on every TS (assuming you have usually more than one). So you would have the same problems as if you would using a different workstation every day.
So the only difference is, TS-roamingprofiles are loading usually much faster, because the fileserver where the profiles are located is usually (or at least, should be) connected with the TS through a fast backend.


NTDOCAdministrator
(KiX Master)
2006-09-27 12:02 AM
Re: How remove old Serverprofiles

Well not trying to explain TS and pros/cons of profiles.

Take TS out of the mix and not a question to me. If I'm running the system I'm not going to use RP.

Thats all


Nexus
(Fresh Scripter)
2006-10-04 08:50 PM
Re: How remove old Serverprofiles

Hi

I would like with UDF "dirplus" and "GroupMembers" erased my users folders.

Script:

Code:

call "D:\KIX\GroupMembers.udf"
call "D:\KIX\DirPlus.udf"

$members = groupmembers(@Domain,"Domain Users")

for each $member in $members
? $member

next

$folders = dirplus("D:\Clients\Profiles", "/ad /s")


for each $folder in $folders
? $folder.name
? $folder.path

if $folder.name = "$member"

else
$folder.delete
endif
next



but it become erased all folders.


Witto
(MM club member)
2006-10-04 10:47 PM
Re: How remove old Serverprofiles

I think you should AScan the $members array for the existance of $Folder.Name .
If it is not in the Array, you want to delete it.
I presume this code will work better...
Maybe you can test it on your folder with test directories
Code:

If AScan($Members, $folder.name) = -1
$folder.delete
EndIf



therob
(Starting to like KiXtart)
2006-10-04 11:27 PM
Re: How remove old Serverprofiles

Quote:



but it become erased all folders.




if so, your problem is gone, isn't it?
*scnr*


Arend_
(MM club member)
2006-10-05 08:45 AM
Re: How remove old Serverprofiles

If your not using Roaming profiles, you probably use a GPO redirect for the "My Documents" and the "Application Data" folders don't you ?

Witto
(MM club member)
2006-10-05 08:59 AM
Re: How remove old Serverprofiles

A.
It is about the place where the Roaming Profiles are stored
Quote:


\\server\Profiles$\username





Arend_
(MM club member)
2006-10-05 10:58 AM
Re: How remove old Serverprofiles

I know Witto, I was referring to NTDOC's statement about "Roaming profiles are bad for you"
Anyway, it is simple, enumerate all users in AD compare the users to the folders using simple Dir() and if the user does not exists remove dir.

An example code to list the users:
Code:

Function ListADUsers
Dim $User, $Users
$Users = GetObject("WinNT://@ldomain")
$Users.filter = "User",""
For Each $User In $Users
? $User.Name
Next
EndFunction



NTDOCAdministrator
(KiX Master)
2006-10-05 12:55 PM
Re: How remove old Serverprofiles

No I don't use one but mainly due to the fact that the old data structure is still in place and I still need to move all the user data to a new location with real security settings. Right now everyone group has mod rights in most places.

I've started moving data but so many things going on I don't have time to dedicate yet to moving all the user data.

Very few people save to the My Documents they've been told many times not to save locally, so most don't now days.


therob
(Starting to like KiXtart)
2006-10-05 01:14 PM
Re: How remove old Serverprofiles

Quote:

If your not using Roaming profiles, you probably use a GPO redirect for the "My Documents" and the "Application Data" folders don't you ?




Imho, its best to use both.


NTDOCAdministrator
(KiX Master)
2006-10-05 09:17 PM
Re: How remove old Serverprofiles

Okay so as not to continue to go off on our own agenda / soapboxes.


Back On Topic

Nexus - are you set? Do you have enough information to complete the requested task or do you need any more specific information to assist you.


Nexus
(Fresh Scripter)
2006-10-05 10:50 PM
Re: How remove old Serverprofiles

Hi

my script, delete still all folders.

Code:
  

call "D:\KIX\GroupMembers.udf"
call "D:\KIX\DirPlus.udf"

$members = groupmembers(@Domain,"Domain Users")

for each $member in $members
? $member

next

$folders = dirplus("D:\00", "/ad /s")


for each $folder in $folders
? $folder.name
? $folder.path

If AScan($Members, $folder.name) = -1
$folder.delete
EndIf
next



I have change in the script "$members" at name.

Code:

call "D:\KIX\GroupMembers.udf"
call "D:\KIX\DirPlus.udf"

$members = groupmembers(@Domain,"Domain Users")

for each $member in $members
? $member

next

$folders = dirplus("D:\00", "/ad /s")


for each $folder in $folders
? $folder.name
? $folder.path

If AScan(Test, $folder.name) = -1
$folder.delete
EndIf
next



Dirplus output:
Test
d:\00\test
test2
d:\00\test2

all subfolder are delete (test, test2) and he had to be delete only test2

can you check my script ?

Good Night


LonkeroAdministrator
(KiX Master Guru)
2006-10-05 11:28 PM
Re: How remove old Serverprofiles

well, your script won't work as "Test" is no array, thus your ascan() test returns always with the delete result.
put the array back.

then, change the ascan if to this:
Code:

If AScan($Members, $folder.name) = -1
? $folder.name " " $folder.delete
EndIf



compare this output with the members output before and you will what you have wrong in the script.