Copy user's items in my documents

Welcome Forums General PowerShell Q&A Copy user's items in my documents

This topic contains 4 replies, has 2 voices, and was last updated by

 
Participant
10 months, 1 week ago.

  • Author
    Posts
  • #90877

    Participant
    Points: 0
    Rank: Member

    Hi, I'm looking for the best way to copy over the contents of a users my documents folder from one remote computer to another with the possibility of being able to display with a gridview or output to a csv the files that were copied over. Thanks for any help in advance.

  • #90878

    Keymaster
    Points: 1,625
    Helping HandTeam Member
    Rank: Community Hero

    Happy to try and help, but I think you'll find a greater response rate if you're asking a concrete technical question. Is there some particular part of the overall task you're stuck on, for example?

  • #90887

    Participant
    Points: 0
    Rank: Member

    Here is a function I created. How can I get a listing of the files that were copied over so I can display them in a gridview or export to a csv? Thanks for any help.

    Function MYDOCS
    {
    $computernameS = '6yypqg23'
    	$computernameCT = '6WGPQG23'
    	$userid = 'x8921'
    				
    		$source = "\\$computernameS\c$\Users\$userid\documents\*"
    		
    		$destination = "\\$computernameCT\c$\Users\$userid\documents\"
    Copy-Item -Recurse -path $source -destination $destination -Force -Exclude @("my*") | Out-GridView –Title "SOFTWARE INSTALLED CHECK FOR  "
    }
  • #90893

    Keymaster
    Points: 1,625
    Helping HandTeam Member
    Rank: Community Hero

    Copy-Item doesn't normally produce output, which is why your Grid gets nothing. Add the -PassThru parameter so it'll output file objects for each file it acted on.

  • #90944

    Participant
    Points: 0
    Rank: Member

    Thanks for your help Don.

The topic ‘Copy user's items in my documents’ is closed to new replies.