[{"data":1,"prerenderedAt":118},["ShallowReactive",2],{"post:\u002F2009\u002F07\u002F07\u002Fscript-check-for-orphaned-homedirs\u002F":3},{"post":4,"newer":66,"older":75,"related":84,"series":116},{"id":5,"title":6,"body":7,"canonical":44,"categories":45,"date":47,"description":48,"extension":49,"featured":50,"hero":51,"image":51,"meta":52,"navigation":53,"path":54,"readingTime":55,"seo":56,"series":51,"seriesOrder":51,"sites":57,"source":59,"stem":60,"tags":61,"updated":63,"url":64,"__hash__":65},"blog\u002Fblog\u002F2009\u002F07\u002F07\u002Fscript-check-for-orphaned-homedirs.md","Script: Check for Orphaned HomeDirs",{"type":8,"value":9,"toc":39},"minimark",[10,14,17,28,33],[11,12,13],"p",{},"It seems no matter how much you try you cannot ever get those damned orphaned homedirs cleaned up. Well, this helps. Our org always has additional groups in the homedir (no, we don’t just let the users have whatever they want in there, so we have to monitor). This causes a little confusion amongst most orphaned file checkers (as there is still a group in there that resolves). Read on for the code and an example.",[11,15,16],{},"What this script does is it scans a directory’s subdirectories (as with many homedirs, the subdirectories are usually the AD account name). It then tries to match the subdirectory to an AD account name. If this proves that one doesn’t exist, it prompts and spits out the ACL info and a prompt to move the files. If you say yes, it moves them to the directory you specified in arg1.",[18,19,24],"pre",{"className":20,"code":22,"language":23},[21],"language-text","'Example: cscript orphaned-files.vbs \"T:\" \"T:~archive\"  where T: is a mapped drive\nstrDomain = \"dc=yourdomain,dc=com\"\nstrFromDir = wscript.arguments(0)\nstrToDir = wscript.arguments(1)\nSet FSO = CreateObject(\"Scripting.FileSystemObject\")\nShowSubfolders FSO.GetFolder(strFromDir)\nSub ShowSubFolders(Folder)\n    For Each Subfolder in Folder.SubFolders\n        'Wscript.Echo Subfolder.Path\n  sUserName = replace(Subfolder.Path, strFromDir,\"\")\n  UserExist(sUserName)\n    Next\nEnd Sub\nSub UserExist(sUserName)\n dtStart = TimeValue(Now())\n Set objConnection = CreateObject(\"ADODB.Connection\")\n objConnection.Open \"Provider=ADsDSOObject;\"\n Set objCommand = CreateObject(\"ADODB.Command\")\n objCommand.ActiveConnection = objConnection\n objCommand.CommandText = _\n  \"&lt;LDAP:\u002F\u002F\" &amp; strDomain &amp; \"&gt;;(&amp;(objectCategory=User)\" &amp; _\n    \"(samAccountName=\" &amp; sUserName &amp; \"));samAccountName;subtree\"\n Set objRecordSet = objCommand.Execute\n If objRecordset.RecordCount = 0 Then\n  WScript.Echo \"*******************sAMAccountName: \" &amp; sUserName &amp; \" does not exist.\"\n  DisplayACLS(sUserName)\n End If\n objConnection.Close\nEnd Sub\nSub DisplayACLS(sUserName)\n Set objShell = CreateObject(\"WScript.Shell\")\n Set objWshScriptExec = objShell.Exec(\"ICACLS \" &amp; strFromDir &amp; sUserName &amp; \"\")\n Set objStdOut = objWshScriptExec.StdOut\n strLine = objStdOut.ReadAll\n Wscript.Echo strLine\n intAnswer = _\n    Msgbox(\"Do you want to move these files?\", _\n        vbYesNo, \"Move Files\")\n If intAnswer = vbYes Then\n  MoveFiles(sUserName)\n Else\n  wscript.echo \"Skipping Files\"\n  wscript.echo \"*******************\"\n End If\nEnd Sub\nSub MoveFiles(sUserName)\n wscript.echo \"Moving Files\"\n wscript.echo \"*******************\"\n Set wshShell = WScript.CreateObject (\"WScript.shell\")\n rc=wshShell.run(\"cmd \u002Fc robocopy \"\"\" &amp; strFromDir &amp; sUserName &amp; \"\"\" \"\"\" &amp; strToDir &amp; sUserName &amp; \"\"\" \u002FS \u002FE \u002FMOVE \u002FCOPY:DAT \u002FV \u002FNP \u002FNFL \u002FZB \u002FR:3 \u002FW:3 \u002FTEE\",1,False)\n Set wshShell = nothing\nEnd Sub\n","text",[25,26,22],"code",{"__ignoreMap":27},"",[29,30,32],"h3",{"id":31},"example-output","Example Output:",[18,34,37],{"className":35,"code":36,"language":23},[21],"*******************sAMAccountName: username does not exist.\nS:username BUILTINAdministrators:(OI)(CI)(F)\n         CREATOR OWNER:(OI)(CI)(IO)(F)\n         (OI)(CI)(F)\nSuccessfully processed 1 files; Failed processing 0 files\nMoving Files\n*******************\n",[25,38,36],{"__ignoreMap":27},{"title":27,"searchDepth":40,"depth":40,"links":41},2,[42],{"id":31,"depth":43,"text":32},3,"techcolumnist",[46],"scripts","2009-07-07T19:49:43Z","It seems no matter how much you try you cannot ever get those damned orphaned homedirs cleaned up. Well, this helps.","md",false,null,{},true,"\u002Fblog\u002F2009\u002F07\u002F07\u002Fscript-check-for-orphaned-homedirs",1,{"title":6,"description":48},[58,44],"lasswell","both","blog\u002F2009\u002F07\u002F07\u002Fscript-check-for-orphaned-homedirs",[62],"script","2024-02-18T16:54:57Z","\u002F2009\u002F07\u002F07\u002Fscript-check-for-orphaned-homedirs\u002F","K1CcUWHXbgv_l87rYhYWIgpAofbthYXomRxoJU9JMAQ",{"title":67,"description":68,"date":69,"url":70,"categories":71,"tags":72,"image":51,"readingTime":55,"canonical":44,"sites":74,"series":51,"seriesOrder":51},"NetApp VFM Email Alerts","I spent a few hours doddling around with how to do email alerting with the provided VFM scripts.","2009-08-03T08:52:33Z","\u002F2009\u002F08\u002F03\u002Fnetapp-vfm-email-alerts\u002F",[],[73],"netapp",[58,44],{"title":76,"description":77,"date":78,"url":79,"categories":80,"tags":81,"image":51,"readingTime":55,"canonical":44,"sites":83,"series":51,"seriesOrder":51},"New Theme","every once in a while i like to change things up a little, so i changed themes.","2009-07-07T18:28:44Z","\u002F2009\u002F07\u002F07\u002Fnew-theme\u002F",[],[82],"blog",[58,44],[85,96,106],{"title":86,"description":87,"date":88,"url":89,"categories":90,"tags":93,"image":51,"readingTime":55,"canonical":44,"sites":95,"series":51,"seriesOrder":51},"PowerShell: NetApp – Gather Volume Information","This is a simple script to gather volume information including dedupe schedule and autogrow settings.","2014-04-28T12:57:58Z","\u002F2014\u002F04\u002F28\u002Fpowershell-netapp-gather-volume-information\u002F",[91,92,46],"dotps","ps",[73,94,62],"powershell",[58,44],{"title":97,"description":98,"date":99,"url":100,"categories":101,"tags":102,"image":51,"readingTime":55,"canonical":44,"sites":105,"series":51,"seriesOrder":51},"ISY Python Script for controlling media lights via xbmc","com) to control devices that are linked. I’m designing this script to be used inside a script for xbmc. here’s the first part of it.","2010-07-16T07:55:36Z","\u002F2010\u002F07\u002F16\u002Fisy-python-script-for-controlling-media-lights-via-xbmc\u002F",[46],[103,62,104],"isy","xbmc",[58,44],{"title":107,"description":108,"date":109,"url":110,"categories":111,"tags":113,"image":51,"readingTime":55,"canonical":44,"sites":115,"series":51,"seriesOrder":51},"PowerShell: Schedule a URL into Maintenance Mode","Found a nice article about how to script a URL (or web application) into maintenance mode.","2010-07-07T14:53:54Z","\u002F2010\u002F07\u002F07\u002Fschedule-a-url-into-maintenance-mode\u002F",[112,92,46],"engineering",[114,62,94],"scom",[58,44],{"doc":51,"posts":117},[],1790223954564]