none
PowerShell: Join-Path with a normal string in between RRS feed

  • Frage

  • Hello, I have the following problem.

    In my script I have the following line:

    $userfolder = "\\$NewServer\Users$\$($ADUser.sAMAccountname)" 
    My problem here is that I can't make two variables at that. So for an example if I write only one:

    $userfolder = "\\AD2019\Users$\$($ADUser.sAMAccountname)" 

    It works perfect. I saw that Join-Path could help, but at the middle I have "Users$" what is not a variable.

    How can I do a Join-Path with that construction?





    Dienstag, 18. Juni 2019 08:06

Alle Antworten

  • Where do you get "User$" or what should be done with this?

    You have a lot of Environmentvariables to get the current Userpath and to get an environmentcontent use simply $Env:Variablename.

    Dienstag, 18. Juni 2019 11:30
  • Moin, du hat im ersten Beispiel das erste Dollar-Zeichen mit dem Backslah escaped.

    Evgenij Smirnov

    http://evgenij.smirnov.de

    Dienstag, 18. Juni 2019 11:44
  • Einer der Gründe, das lieber so zu machen:

    $userfolder = '\\{0}\Users$\{1}' -f $NewServer, $ADUser.sAMAccountname


    Greetings/Grüße, Martin - https://mvp.microsoft.com/en-us/PublicProfile/5000017 Mal ein gutes Buch über GPOs lesen? - http://www.amazon.de/Windows-Server-2012--8-Gruppenrichtlinien/dp/3866456956 Good or bad GPOs? My blog - http://evilgpo.blogspot.com And if IT bothers me? Coke bottle design refreshment - http://sdrv.ms/14t35cq

    Dienstag, 18. Juni 2019 14:42