You could put it in a foreach command in a script, that way you can see the 
output of the command. But I would filter out the other criteria that you do 
not need with something like this Get-ADUser -Filter * | select 
UserPrincipalName that will return only 
[email protected]<mailto:[email protected]>. Or what I have 
outlined below works better (in my opinion).

A foreach command would look something like this. There's no error checking and 
you may have to tweak it because I didn't test it but the idea should work;

$Users = Get-ADUser -Filter *
$PrincipalName = $Users.UserPrincipalName

foreach ($a in $PrincipalName)
{
$UserPath = "C:\Root_Path\$a"
New-Item -Type Directory -Path $UserPath
}

If you want just the username such as user123 and not 
[email protected]<mailto:[email protected]> change this part.

$PrincipalName = $Users.Name
Or
$PrincipalName = $Users.SamAccountName

Both of those will return just user123 without the @somedomain.com.

Thanks,

Uriah Patton
Systems Administrator

"It gives patience, to listen to error without anger." -Gandalf

From: [email protected] [mailto:[email protected]] On 
Behalf Of Gavin Wilby
Sent: Monday, February 22, 2016 4:51 AM
To: '[email protected]' <[email protected]>
Subject: [NTSysADM] Powershell help

Hi,

I have a new server that I want to populate a drive with folders for each user.

I can do a Get-ADUser -Filter * | fl UserPrincipalName which gives me the 
names, but I'm unsure of how to pipe the next part to create the folders.

So ideally, I'd like the folder called the username, so for me rather that it 
being [email protected]<mailto:[email protected]>, it's just gavinw.

Permissions Ill worry about later. The drive/ partition for the directories 
already exists.

Gavin Wilby
IT Support Engineer

SMP Partners Ltd
Clinch's House, Lord Street,
Douglas, Isle of Man IM99 1RZ
Tel +44 1624 682214
Mob +44 7624 480575
[email protected]<mailto:[email protected]> 
www.smppartners.com<http://www.smppartners.com/>

A member of the SMP Partners Group of Companies

SMP Partners Limited, SMP Trustees Limited and SMP Fund Services Limited are 
licensed by the Isle of Man Financial Services Authority. SMP Accounting & Tax 
Limited is a member of the ICAEW Practice Assurance Scheme.
SMP Partners Limited registered in the Isle of Man, Company Registration No: 
000908V
Directors: M.W. Denton, M.J. Derbyshire, S.E McGowan, O. Peck, J.J. Scott, S.J. 
Turner
SMP Trustees Limited registered in the Isle of Man, Company Registration No: 
068396C
Directors: A.C. Baggesen, J.M. Cubbon, M.W. Denton, K.M. Goldie, O Peck, J. 
Watterson
SMP Fund Services Limited registered in the Isle of Man, Company Registration 
No: 120288C
Directors: V. Campbell, R.K. Corkill, M.W. Denton, D.A. Manser, S.E McGowan, 
J.J. Scott
SMP Accounting & Tax Limited registered in the Isle of Man, Company 
Registration No: 001316V
Directors: I.F. Begley,  A.J. Dowling, P. Duchars, J.J. Scott, S.J. Turner
SMP Capital Markets Limited registered in the Isle of Man, Company Registration 
No: 002438V
Directors: M.W. Denton, M.J. Derbyshire, D.F Hudson, S.E McGowan, O. Peck, S. 
J. Turner
SMP Partners Limited, SMP Trustees Limited, SMP Fund Services Limited, SMP 
Accounting & Tax Limited and SMP Capital Markets Limited are members of the SMP 
Partners Group of Companies.

This email is confidential and is subject to disclaimers. Details can be found 
at: http://www.smppartners.com/disclaimer.html
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

Reply via email to