Corrected view of user folders RRS feed

  • Question

  • I have a server that stores user folders. For some time, I saw that some folders do not have a username but have a Documents folder.

    When I right click and select properties, there is the name of user.

    How can I give the good name on the folders? I have tried with a script

    For Example, I have a different folders :
    Documents - in properties desktop.ini the owner is DFG
    Documents - in properties desktop.ini the owner is GHJ
    Documents - in properties desktop.ini the owner is KLM

    Thanks you in advance for your answers !

    • Moved by Bill_Stewart Monday, October 2, 2017 7:03 PM Unanswerable drive-by question
    Wednesday, August 16, 2017 6:42 AM

All replies

  • Hi,

    first you should read this: This forum is for scripting questions rather than script requests.

    And then you should post your code. Probably someone is able to help you here.

    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    Wednesday, August 16, 2017 7:29 AM
  • To get the folder owner you could run (get-acl $filepath).owner and pass this into a variable and use this value to rename the folders.  You will probably have to split the value as it will be domain\username.
    Wednesday, August 16, 2017 7:51 AM
  • Thank you simbrook2. I will try to create a script with this instruction.
    Wednesday, August 16, 2017 8:18 AM
  • Just a bit more with the split

    $filepath = "C:\test\converted.xml"
    $owner = (get-acl $filepath).owner
    $result= $owner.split("\") 

    Wednesday, August 16, 2017 8:36 AM
  • I got my result with the command Get-ItemProperty instead of get-acl.

    Now, I have to rename the folders with my result.

    Thank you for your help simbrook2

    Wednesday, August 16, 2017 8:44 AM
  • User folders created  by Group Policy do not have a user name but will have a documents folder. The name in the display is generated by the profile manager in an interactive session.  The folders should not be renamed.


    Wednesday, August 16, 2017 2:03 PM
  • simbrook2 :

    I've do a script with create a desktop.ini in the users folders.

    How I can do for create the files compared to username ?

    Here my script :

    Remove-Item U:\test\test\*\desktop.ini -Force
    $file = New-Item -Path "U:\test\test\*" -Name "desktop.ini" -ItemType file -Force
    $owner = (Get-ItemProperty U:\test\test\*).Name
    foreach ($username in $owner){
    $myline = "[.ShellClassInfo]
    Add-Content $file $myline
    I don't have the good folder in my file

    Wednesday, August 16, 2017 2:35 PM
  • A file object does not have an "Owner" property.

    This will get the owner of a file:

    (get-item test.*).GetAccessControl().Owner

    It is very hard to understand what you are trying to accomplish.


    Wednesday, August 16, 2017 2:45 PM