Windows Vista Forums

Set home directory with Pipe
  1. #1


    Personne Guest

    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

  2. #2


    Personne Guest

    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

  3. #3


    Personne Guest

    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

  4. #4


    Alex K. Angelopoulos Guest

    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

    > 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

  5. #5


    tojo2000 Guest

    Re: Set home directory with Pipe

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

    > 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

  6. #6


    Personne Guest

    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

  7. #7


    Shay Levy [MVP] Guest

    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

  8. #8


    tojo2000 Guest

    Re: Set home directory with Pipe

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

    > 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

  9. #9


    Personne Guest

    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?

Similar Threads
Thread Thread Starter Forum Replies Last Post
home directory replacement IT STAFF PowerShell 1 19 Sep 2009
Pipe a pipe command to a file WB VB Script 2 15 Jul 2008
Vista Home in Active Directory Vista home in AD Vista General 2 11 Mar 2008
User Home Directory andyoye PowerShell 13 20 Feb 2008
How do I rename the Admin home directory? csanii Vista account administration 1 30 Jul 2007