none
How to grab %userprofile% path after placing query on location of a file set with Get-ChildItem RRS feed

  • Question

  • Hello Everyone,


    I'm currently working on a project in which I'm doing a mass data copy and I need to auto create a folder structure based on the user profile that the file was originally under when copying the data to the new location. 


    Which would end up having the folder structure end up looking like this at the end:


    rootdir\(MachineName)\(UserProfileName)\File.etxention


    Is there a way through powershell to grab the user profile location that the file exists under and put it into a .csv file using the export-csv command? This is for a mass data pull of a number of .pst files from under the different user profiles on the network into a singular location.

    The current script I've used is able to grab the file paths, machine names, owners and file size of the found .pst files but currently the missing piece is being able to parse out the user profile name for the file which it exists under in order to finish up the script I'm creating to auto-create a folder structure in which to pull the data into from across the network.

    Any thoughts or possibilities would be appreciated, been bashing my head against this problem for 4 days now. 

    • Moved by Bill_Stewart Tuesday, December 11, 2018 9:25 PM Unanswerable drive-by question
    Thursday, July 26, 2018 7:08 PM

All replies

  • $env:USERPROFILE

    \_(ツ)_/

    Thursday, July 26, 2018 7:24 PM
  • Wouldn't this pull from the local environment? This is for a remote machine file pull in which I need the user profile which the remote file is stored under on the remote machine. 

    Would this system variable function if the command Set-Location is used and the location is set to the remote machines C:\ drive?
    Thursday, July 26, 2018 11:30 PM
  • The user profile is local.  It is never remote.

    Your overall question is quite ambiguous. 


    \_(ツ)_/

    Friday, July 27, 2018 12:44 AM