Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find a folder via Samname, put that path in HomeDirve

Status
Not open for further replies.

Discipulus

IS-IT--Management
Jul 17, 2009
1
US
I need to search a share and find a folder by an AD user samname; then take the full path of that folder and modify that same user'(s') Home Drive.

This makes txt files that contain list of samacocunt names and folder listing of share(s), respectably (I only need the first level of the share as there are not users in a user's folders):
$Users = Get-QADUser -Enabled -MemberOf GroupName
$users | Select-object samaccountname | out-file c:\samssf.txt
example output:
ADoe
JaneD
JSmith

$dirs = Get-ChildItem -path "\\servername\sharename","\\servername\differnetshare\thislevel" | Where-Object {$_.psIsContainer -eq $true}
$dirs | Select-Object fullname | Out-File c:\sfl.txt
example output:
\\servername\sharename\JaneD
\\servername\differnetshare\thislevel\unimportantfolder
\\servername\differnetshare\thislevel\JSmith

I have been trying to use a foreach-object cmdlet but I don't think its the right way. This works with select-string, but getting it to look-up a name in samssf.txt is not going well. I know would have to replace the select-string with something else and use a variable, but it just feels like I'm on a dead end street.
Get-Content c:\sfl.txt | ForEach-Object -Process {$_|select-string "JandD"}
example output:
\\servername\sharename\JaneD

I think Set-QADuser with -homedrive would be part of the next step

Latest stable build of powershell, and useing the PowerGUI Script Editor for some help.
I am using Quest's "ActiveRoles Management Shell for Active Directory".

code cited:
 
Sorry I can't offer any assistance via PowerShell for this since I run a vanilla instalaltiona nd don't use the Quest extensions. I can offer assistance with it in VBScript. I have to ask though, WHY would you want to do this? The property you are looking to set is a legacy setting for backward compatibility stretching all the way back to NT4. Why not simply map a drive via login script that uses the username as a variable?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top