| « Template script to use arguments from the command line [updated 24-12-2009] | Started this Blogsite because... » |
This is my first script and I want to publish it to the world!!! Look at the Help file.
Everybody knows this problem. Especially in a large environment. You have a share with roaming or hybrid profiles. This share seems to grow exponentially. The thing that happens is the users are deleted/disabled because users are no longer working at the company or are no longer using the environment. So the profile is obsolete.
This script will move all the folders of disabled/deleted users into a subfolder _deleted or _disabled. This way you don't delete folder automated, because that's scary. But you have a single folder which you can backup and clean very easily.
DESCRIPTION:
This script will get the subdirs of -RootDir and gets the username out of the
folder name. That username will be checked against the Active Directory.
It will move the profile dir of deleted and `"longer then a month disabled`" users
to the _Deleted or _Disabled folder.
The script will log the actions or reports in a Comma Seperated Value file .\<date>-<scriptname>.csv
Script created by Mike Bijl (Login Consultants)
Script version 2.0"
DEPENDANCY:
- Quest AD CmdLets from http://www.quest.com/powershell/activeroles-server.aspx
- This must be started from a domainmember
EXAMPLE:
.\Clean-ProfileSharev2.ps1 -RootDir \\domain.local\profileshare$ -SizeReport Full -Action ReportOnly
Creates only a report about your share and don't change anything.
.\Clean-ProfileSharev2.ps1 -RootDir \\domain.local\profileshare$ -Action Move
Moves all the obsolete directories in the profile share. (You don't delete anything!!!)
SYNTAX:"
.\Clean-ProfileSharev2.ps1 -RootDir <ProfileShare> [-SizeReport <Full|Normal|None>] [-Action <ReportOnly|MoveDeletedOnly|Move>]
-RootDir <ProfileShare>
This is a required argument and points to the share where the profiles are located. For example: \\domain.local\profileshare$
-SizeReport <Full|Normal|None>
This is an optional argument that defines the way the foldersize is reported. Default = Normal
Full: The size of all the subfolders of Rootdir will be reported. (Slow)
Normal: Only the size of the moved or `"should be moved`" (deleted/disabled profile) folders are reported. (Somewhat Slow)
None: None of the foldersizes are reported. (Fastest)
-Action <ReportOnly|MoveDeletedOnly|Move>
This is an optional argument that defines the action to be taken when a user is deleted or disabled. Default = ReportOnly
ReportOnly: None of the folders are moved. The log file tells which folders could be moved.
MoveDeletedOnly: Moves only the profile folder which foldername doesn't corresponds to a AD user account.
Move: Moves the profile folder which foldername doesn't corresponds to a AD user account and moves the folder which foldername corresponds to a AD user account that is disabled for more than a month.
Attachments:
Clean-ProfileSharev2.ps1 (9.4 KB)
1 comment
-
§ Myriam Bertalan said on : 3030-03-2010 @ 23:13
this is one of the nicest sites I have seen in a while, thanks for not wasting my time with pointless drible that I find on a lot of other sites. Good work.