Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 help and support Forum Windows 8 Forum Vista Tutorials

Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Vista Newsgroup Archive > Misc Newsgroups > PowerShell

Vista - Set home directory with Pipe


 
 
05-15-2009   #1 (permalink)
Personne


 

Set home directory with Pipe

I'm ashamed to post a question like this, but I may be very tired !!

Get-qaduser UserName | Set-QADUser -HomeDirectory "\\SBS02\Userdata\
$_.logonname" -HomeDrive "H"

$_.logonname is not replaced with what it should be !




My System SpecsSystem Spec
05-15-2009   #2 (permalink)
Personne


 

Re: Set home directory with Pipe

I've tried this too

get-qaduser Username| Set-QADUser -HomeDirectory "\\SBS02\Userdata\$
($_.logonname)" -HomeDrive "H"

but it set the value only with \\SBS02\Userdata\

My System SpecsSystem Spec
05-15-2009   #3 (permalink)
Personne


 

Re: Set home directory with Pipe

This is my solution bu I think is is ugly

get-qaduser | ? {$_.dn -match "lauder" -and !$_.homedirectory} |
foreach {$d="\\SBS02\Userdata\"+$_.logonname ; Set-QADUser $_.dn -
HomeDirectory $d -HomeDrive "H"}
My System SpecsSystem Spec
05-15-2009   #4 (permalink)
Alex K. Angelopoulos


 

Re: Set home directory with Pipe

If Set-QADUser can handle input selection like that, your only problem is
that $_.logonname needs evaluation since it is in quotes:

Get-qaduser UserName | Set-QADUser -HomeDirectory
"\\SBS02\Userdata\$($_.logonname)" -HomeDrive "H"

If it doesn't, you'll need to do this instead:

Get-qaduser UserName | %{ Set-QADUser -HomeDirectory
"\\SBS02\Userdata\$($_.logonname)" -HomeDrive "H"}


"Personne" <cpdivers@xxxxxx> wrote in message
news:5f6f5bf8-ea1d-4a0f-be5f-d320dbe14672@xxxxxx
Quote:

> I'm ashamed to post a question like this, but I may be very tired !!
>
> Get-qaduser UserName | Set-QADUser -HomeDirectory "\\SBS02\Userdata\
> $_.logonname" -HomeDrive "H"
>
> $_.logonname is not replaced with what it should be !
>
>
My System SpecsSystem Spec
05-15-2009   #5 (permalink)
tojo2000


 

Re: Set home directory with Pipe

On May 15, 12:28*pm, Personne <cpdiv...@xxxxxx> wrote:
Quote:

> This is my solution bu I think is is ugly
>
> get-qaduser | ? {$_.dn -match "lauder" -and !$_.homedirectory} |
> foreach {$d="\\SBS02\Userdata\"+$_.logonname ; Set-QADUser $_.dn -
> HomeDirectory $d -HomeDrive "H"}
When accessing a property of an object within a string, you need to
use this notation:

Get-qaduser UserName |
Set-QADUser -HomeDirectory "\\SBS02\Userdata\$($_.logonname)" -
HomeDrive "H"

This lets PowerShell know that you want to evaluate the value inside
the parentheses and then interpolate it into the string.
My System SpecsSystem Spec
05-15-2009   #6 (permalink)
Personne


 

Re: Set home directory with Pipe

As I've said in my 12:15 message

Get-qaduser UserName | Set-QADUser -HomeDirectory "\\SBS02\Userdata\$
($_.logonname)" -HomeDrive "H"

This one doesn't work
My System SpecsSystem Spec
05-15-2009   #7 (permalink)
Shay Levy [MVP]


 

Re: Set home directory with Pipe


Try this:

Get-QADUser userName | foreach { Set-QADUser $_ -HomeDirectory "\\SBS02\Userdata\$($_.logonname)"
-HomeDrive "L" }




---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar



P> As I've said in my 12:15 message
P>
P> Get-qaduser UserName | Set-QADUser -HomeDirectory
P> "\\SBS02\Userdata\$ ($_.logonname)" -HomeDrive "H"
P>
P> This one doesn't work
P>


My System SpecsSystem Spec
05-15-2009   #8 (permalink)
tojo2000


 

Re: Set home directory with Pipe

On May 15, 1:11*pm, Personne <cpdiv...@xxxxxx> wrote:
Quote:

> As I've said in my 12:15 message
>
> Get-qaduser UserName | *Set-QADUser -HomeDirectory "\\SBS02\Userdata\$
> ($_.logonname)" -HomeDrive "H"
>
> This one doesn't work

Sorry, the way the line broke I didn't notice the first $. Shay's
answer is what I would recommend.
My System SpecsSystem Spec
05-16-2009   #9 (permalink)
Personne


 

Re: Set home directory with Pipe

Is there a powershell command, to change the way the line are break in
google newsgroup ? :-)
My System SpecsSystem Spec
 

Set home directory with Pipe problems?



Thread Tools


Similar topics to: Set home directory with Pipe
Thread Forum
home directory replacement PowerShell
Pipe a pipe command to a file VB Script
Vista Home in Active Directory Vista General
User Home Directory PowerShell
How do I rename the Admin home directory? Vista account administration


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50