Discipulus
IS-IT--Management
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:
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: