# Copy Files Form Remote

**URL:** <https://forums.powershell.org/t/copy-files-form-remote/17381>\
**Category:** PowerShell Help\
**Created:** [August 23, 2021, 4:09am UTC](https://forums.powershell.org/t/copy-files-form-remote/17381 "2021-08-23T04:09:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ml1010](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@ml1010](https://forums.powershell.org/u/ml1010)\
**Post date:** [August 23, 2021, 4:09am UTC](https://forums.powershell.org/t/copy-files-form-remote/17381/1 "2021-08-23T04:09:47Z")

</div>

Hi, i would like to know how to create a powershell script that can copy files from remote PC to local pc. i got few things need to include into the script. Is there any script i can do

1. Run admin credentials from non admin PC
2. Copy 3 files from remote c C:\XX\XX to local pc
3. detect username with $env:UserName, but don’t detect my admin account name when i run as my admin account
4. Type in hostname and copy

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [August 23, 2021, 5:30am UTC](https://forums.powershell.org/t/copy-files-form-remote/17381/2 "2021-08-23T05:30:17Z")

</div>

LM,  
Weclome to the forum. 👋🏽

Your explanation is a bit vague and confusing at the same time.

1 Yes. You can run a script with elevated rights. The used account has to have access rights to the files / folders you want to reach on the remote computer.  
2 The easiest way would be to use a UNC path like `\\RemotePC\c$\xx\xx`  
3 I don’t know how that is related to the copy job  
4 If I got it right you could use` Read-Host` to ask for user input.

Here are some basic help topics to get you started:

> **[Read-Host (Microsoft.PowerShell.Utility) - PowerShell](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/read-host?view=powershell-7.2&viewFallbackFrom=powershell-7.1)**
>
> The Read-Host cmdlet reads a line of input from the console (stdin). You can use it to prompt a user for input. Because you can save the input as a secure string, you can use this cmdlet to prompt users for secure data, such as passwords. Note...

> **[Copy-Item (Microsoft.PowerShell.Management) - PowerShell](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7.2&viewFallbackFrom=powershell-7.1)**
>
> The Copy-Item cmdlet copies an item from one location to another location in the same namespace. For instance, it can copy a file to a folder, but it can't copy a file to a certificate drive. This cmdlet doesn't cut or delete the items being copied....

I’d recommend to read the help for the cmdlets completely including the examples to learn how to use them.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:21pm UTC](https://forums.powershell.org/t/copy-files-form-remote/17381/3 "2024-05-16T20:21:44Z")

</div>


