Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: Script To Delete Home Drives, Profile and Terminal Services profil

HTVi
TV Discussion Newsgroups

Script To Delete Home Drives, Profile and Terminal Services profil
gbrown135 6/14/2007 9:50:01 AM
Is there any script that would allow to prompt for the netbios name of a user
and then read Active directory and then go to the Servers of the profiles and
completely remove the user's Home drive, Profile and Terminal Services
Profile. I have had a look but there is nothing at all I can find.

Any help would be appreciated

Gary
Re: Script To Delete Home Drives, Profile and Terminal Services profil
"Al Dunbar" <AlanDrub[ at ]hotmail.com.nospaam> 6/15/2007 5:10:22 AM

"gbrown135" <gbrown135[ at ]discussions.microsoft.com> wrote in message
news:4ECA1AC7-7716-43DE-8DC3-F4DBF7415BF7[ at ]microsoft.com...
[Quoted Text]
> Is there any script that would allow to prompt for the netbios name of a
> user
> and then read Active directory and then go to the Servers of the profiles
> and
> completely remove the user's Home drive, Profile and Terminal Services
> Profile. I have had a look but there is nothing at all I can find.
>
> Any help would be appreciated

By netbios name, do you perhaps mean the sAMAccountName attribute in active
directory? If so, that can be converted to the distinguished name using
nametranslate:

http://www.rlmueller.net/NameTranslateFAQ.htm

Once you have that, you would bind to the user object, and get the home
folder, profile and terminal services profile attributes. I forget details
such as exact names of attributes, so I'd use csvde or ldifde to extract all
attributes and see what they are called.

The home folder should be in a sharename or UNC form. If a UNC, you could
use the file system object delete folder method:

http://ns7.webmasters.com/caspdoc/html/vbscript_filesystemobject_object_deletefolder_method.htm
http://www.microsoft.com/technet/scriptcenter/guide/sas_wsh_qlcc.mspx?mfr=true

If the home folder is a sharename, you will need to query the server to
determine the path to the folder that is shared, unshare it, then delete it.

Profile and TS profile would likely be handled in a similar manner.

/Al





Re: Script To Delete Home Drives, Profile and Terminal Services pr
gbrown135 6/15/2007 9:44:01 AM
Hi

I can convert the sAMAccountName to the distinguished name fine with

Const ForReading = 1
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

strUser = InputBox("Enter User Name")

strDomain = "Globalinfra"

Set objTrans = CreateObject("NameTranslate")

objTrans.Init ADS_NAME_INITTYPE_GC, ""

objTrans.Set ADS_NAME_TYPE_NT4, strDomain & "\" & strUser

strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)

Set objUser = GetObject("LDAP://" & strUserDN)

I know the attributes are profilePath, homeDirectory and terminalServer. All
these are in sharename form. I would not know where to start to query the
server then to delete the actual file.
Could you help at all?

GB

"Al Dunbar" wrote:

[Quoted Text]
>
> "gbrown135" <gbrown135[ at ]discussions.microsoft.com> wrote in message
> news:4ECA1AC7-7716-43DE-8DC3-F4DBF7415BF7[ at ]microsoft.com...
> > Is there any script that would allow to prompt for the netbios name of a
> > user
> > and then read Active directory and then go to the Servers of the profiles
> > and
> > completely remove the user's Home drive, Profile and Terminal Services
> > Profile. I have had a look but there is nothing at all I can find.
> >
> > Any help would be appreciated
>
> By netbios name, do you perhaps mean the sAMAccountName attribute in active
> directory? If so, that can be converted to the distinguished name using
> nametranslate:
>
> http://www.rlmueller.net/NameTranslateFAQ.htm
>
> Once you have that, you would bind to the user object, and get the home
> folder, profile and terminal services profile attributes. I forget details
> such as exact names of attributes, so I'd use csvde or ldifde to extract all
> attributes and see what they are called.
>
> The home folder should be in a sharename or UNC form. If a UNC, you could
> use the file system object delete folder method:
>
> http://ns7.webmasters.com/caspdoc/html/vbscript_filesystemobject_object_deletefolder_method.htm
> http://www.microsoft.com/technet/scriptcenter/guide/sas_wsh_qlcc.mspx?mfr=true
>
> If the home folder is a sharename, you will need to query the server to
> determine the path to the folder that is shared, unshare it, then delete it.
>
> Profile and TS profile would likely be handled in a similar manner.
>
> /Al
>
>
>
>
>
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen