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 !
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 !
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\
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"}
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 !
>
>
On May 15, 12:28*pm, Personne <cpdiv...@xxxxxx> wrote:When accessing a property of an object within a string, you need to
> 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"}
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.
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
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>
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.
Is there a powershell command, to change the way the line are break in
google newsgroup ? :-)
| 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 |