none
Set Profile Path from a GPO to OUs

    Question

  • Hello 

    I  have a requirement  to  set  bunch  of users  profile path. Users are in different OU. Is there any script i can use to set profile path in a GPO &  apply depending on the OU the user belongs to.

    • Moved by Bill_Stewart Tuesday, June 16, 2015 2:05 PM Move to more appropriate forum
    Tuesday, June 16, 2015 2:29 AM

Answers

  • Hi Vikash,

    As per the below article you can't have a GPO to customize per user basis the option available is to configure the computer settings only.

    Set Profile  Path from a  GPO

    See if this GPO article helps Specify the Location of Folders in a User Profile.

    Otherwise only option left is configuring users in a regular basis using a script or cmdlet.

    NOTE:- New users created or moved between OUs would not be affected automatically by this, until you run the script again.

    List users by OU:

    Get-ADUser -SearchBase "OU=Home,DC=contoso,DC=com" -SearchScope SubTree | select-object SamAccountName,Department,TelephoneNumber,ProfilePath,Enabled,LastLogonDate
    

    List all users current profilepath to be changed:

    Get-ADUser -Filter * -SearchBase "OU=Home,DC=contoso,DC=com" -Properties profilepath

    Set all users from Get-ADUser:

    Get-ADUser -SearchBase "OU=Home,DC=contoso,DC=com" -SearchScope SubTree | Set-ADUser -ProfilePath '\\fabrikam-srv1\profiles\%username%'
    


    The following example demonstrates how to set the profile attributes of the user SaraDavis:

    Set-ADUser SaraDavis -ProfilePath '\\fabrikam-srv1\profiles\%username%' -ScriptPath 'logon.vbs' -HomeDrive 'Z' -HomeDirectory '\\fabrikam-srv1\saradavis'

    The complete script is shown here:

     
    Import-Module ActiveDirectory
     
    $ou = "OU=Testou,Dc=Iammred,Dc=Net"
     
    $properties = "ProfilePath","ScriptPath", "l"
     
    Get-ADUser -Filter * -SearchBase $ou -Properties $properties |
     
    ForEach-Object {
     
     $ProfilePath = "{0}\storage1\profiles\{1}" -f $_.l, $_.SamAccountName
     
     $ScriptPath = "{0}\storage1\scripts\{0}_logonScript.ps1" -f $_.l
     
     Set-ADUser $_.samaccountname -ProfilePath $ProfilePath -ScriptPath $ScriptPath
     
    }
    
    You can save the OUs in an array and add another forloop to work it for multiple OUs as well easily

    References:

    ProfilePath filtering and Get-ADUser

    https://social.technet.microsoft.com/Forums/windowsserver/en-US/a9ca6904-f17f-4fd6-9bcd-55be5e9f1ae3/profilepath-filtering-and-getaduser

    Setting a User's Profile Attributes

    https://technet.microsoft.com/en-us/library/dd378875(v=ws.10).aspx

    Use PowerShell to Change Sign-in Script and Profile Path

    http://blogs.technet.com/b/heyscriptingguy/archive/2013/08/14/use-powershell-to-change-sign-in-script-and-profile-path.aspx

    Modifying an Attribute for Several Users at Once

    https://technet.microsoft.com/en-us/library/dd391846(v=ws.10).aspx


    Regards,

    Satyajit

    Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    • Proposed as answer by AlexAdkin Tuesday, June 16, 2015 7:35 PM
    • Marked as answer by Vikash Nath Wednesday, June 17, 2015 2:17 AM
    Tuesday, June 16, 2015 12:48 PM

All replies

  • You need to post in the GP forum.  You cannot do this with a script.  It is set in AD and is enforced.  In GP you can move the documents out of the profile for improved performance etc.

    Post question in GP forum.


    \_(ツ)_/

    Tuesday, June 16, 2015 4:34 AM
  • Hi Vikash,

    As per the below article you can't have a GPO to customize per user basis the option available is to configure the computer settings only.

    Set Profile  Path from a  GPO

    See if this GPO article helps Specify the Location of Folders in a User Profile.

    Otherwise only option left is configuring users in a regular basis using a script or cmdlet.

    NOTE:- New users created or moved between OUs would not be affected automatically by this, until you run the script again.

    List users by OU:

    Get-ADUser -SearchBase "OU=Home,DC=contoso,DC=com" -SearchScope SubTree | select-object SamAccountName,Department,TelephoneNumber,ProfilePath,Enabled,LastLogonDate
    

    List all users current profilepath to be changed:

    Get-ADUser -Filter * -SearchBase "OU=Home,DC=contoso,DC=com" -Properties profilepath

    Set all users from Get-ADUser:

    Get-ADUser -SearchBase "OU=Home,DC=contoso,DC=com" -SearchScope SubTree | Set-ADUser -ProfilePath '\\fabrikam-srv1\profiles\%username%'
    


    The following example demonstrates how to set the profile attributes of the user SaraDavis:

    Set-ADUser SaraDavis -ProfilePath '\\fabrikam-srv1\profiles\%username%' -ScriptPath 'logon.vbs' -HomeDrive 'Z' -HomeDirectory '\\fabrikam-srv1\saradavis'

    The complete script is shown here:

     
    Import-Module ActiveDirectory
     
    $ou = "OU=Testou,Dc=Iammred,Dc=Net"
     
    $properties = "ProfilePath","ScriptPath", "l"
     
    Get-ADUser -Filter * -SearchBase $ou -Properties $properties |
     
    ForEach-Object {
     
     $ProfilePath = "{0}\storage1\profiles\{1}" -f $_.l, $_.SamAccountName
     
     $ScriptPath = "{0}\storage1\scripts\{0}_logonScript.ps1" -f $_.l
     
     Set-ADUser $_.samaccountname -ProfilePath $ProfilePath -ScriptPath $ScriptPath
     
    }
    
    You can save the OUs in an array and add another forloop to work it for multiple OUs as well easily

    References:

    ProfilePath filtering and Get-ADUser

    https://social.technet.microsoft.com/Forums/windowsserver/en-US/a9ca6904-f17f-4fd6-9bcd-55be5e9f1ae3/profilepath-filtering-and-getaduser

    Setting a User's Profile Attributes

    https://technet.microsoft.com/en-us/library/dd378875(v=ws.10).aspx

    Use PowerShell to Change Sign-in Script and Profile Path

    http://blogs.technet.com/b/heyscriptingguy/archive/2013/08/14/use-powershell-to-change-sign-in-script-and-profile-path.aspx

    Modifying an Attribute for Several Users at Once

    https://technet.microsoft.com/en-us/library/dd391846(v=ws.10).aspx


    Regards,

    Satyajit

    Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    • Proposed as answer by AlexAdkin Tuesday, June 16, 2015 7:35 PM
    • Marked as answer by Vikash Nath Wednesday, June 17, 2015 2:17 AM
    Tuesday, June 16, 2015 12:48 PM
  • Hi Satyajit

    Thanks for your suggestion, this is something I was looking for. This will work in my situation

    Thanks

    Wednesday, June 17, 2015 2:16 AM