292 questions
1
vote
1
answer
94
views
Powershell copy-item replaced a directory with a file
I'm using a command similar to the one below to copy a file to a directory:
copy-item 'C:\\some\\source\\directory\filename.txt' -Destination 'T:\some\destination\dir'
C:\ is a local disk. T:\ is a ...
0
votes
1
answer
118
views
Powershell: Copy-Item fails without exceptions
I use The following powershell code to copy file from a remote machine on the same network to the actual machine where this powershell is executed. The firewall is disabled. The $UpdateSourceFolder is ...
0
votes
1
answer
70
views
PowerShell Copy-Item not copying deep folders?
I am writing a script to copy items to a drive when I connect a specific drive. The script works, but it won't copy deep subfolders
Here is a sample of my code:
$folder = @(Get-ChildItem -path "C:...
0
votes
1
answer
67
views
Foreach 'file' copy-item only copies the last results 'file' to destination but copies to all folders instead of its respective folder
I am no expert in PowerShell and apologies if my script is way off but I really could use some help on this. I appreciate any help!!
I need to copy ONLY '.bak' files from a Server with folder ...
0
votes
1
answer
92
views
PowerShell error - Copy-Item: Could not find a parameter matching the name "Stream"
I want to create a PowerShell script to copy the Templates folder from a remote computer to a local computer:
# Ask the administrator to enter the name of the remote PC
$RemotePCName = Read-Host "...
0
votes
1
answer
62
views
converting a bat script to an ps1 script
I have the following batch file.
@echo off
@echo Kopiere Autodesk-Profil ins Homeverzeichnis (H:\)...
@rmdir /s /q "H:\Downloads\Temp_Autodesk\Autodesk AutoCAD Map 3D 2021\"
@xcopy /s /y &...
0
votes
2
answers
250
views
Powershell copy with wildcard
The following works fine.
Copy-Item -Path C:\Users\Administrator\Desktop\EA\MT4\EA_bot.ex4 -Destination C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\0C2BFA140CA8FBEFEDCADDDEDD61AA24\...
0
votes
0
answers
45
views
How to use Powershell to batch copy files and output their success or failure to a log file
I want to copy a series of files from different locations/destinations and output their success and/or failure to a pipe delimited file.
For example I have tried the code below but it doesn't report ...
1
vote
2
answers
120
views
Copy-item duplicating some directories in sub directories. (Real head-scratcher)
When copying a Windows profile, I am successfully copying and excluding the voluminous "AppData" folder. But the side effect is that in the backup folder, sub-folder "Documents" ...
1
vote
1
answer
338
views
Powershell Exclude folders and files from the current directory and subdirectories from copying
$exclude = @(
"AppData",
"Application Data",
"Contacts",
"Cookies",
"IntelGraphicsProfiles",
"...
1
vote
2
answers
1k
views
Copy-Item error and how to catch access is denied
I have a script that backs up User Profiles Documents.
The code is:
$sourceFolder = "C:\Users\username\Documents"
$backupFolder = "C:\temp\Backup\profilefolders\username\Documents"
...
0
votes
1
answer
291
views
PowerShell: Copy-Item ignoring LastWriteTime on Objects
Overflow,
I have a task to copy hundreds of files, folders, and subfolders from an on-prem server to location on our shared network drive and am trying to write a Powershell script to accomplish this ...
0
votes
0
answers
72
views
Copy logs remotely
function Copy-Logs {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, HelpMessage="Specify the name(s) of the ...
0
votes
1
answer
1k
views
How to search for files and copy to new location with folder structure intact - Powershell
Using Powershell to search (Get-ChildItem) for specific files that you need to copy to a new location with the same folder structure seemed to be not trivial with Powershell. Combining Get-ChildItem ...
0
votes
1
answer
70
views
XCopy specific txt files in multiple subfolders without subfolder in path
I have a batch file to copy over files from Web folder to my local folder.
Web folder destination look like this:
G:\program files\2023\subfolder_1\1.txt
G:\program files\2023\subfolder_1\1_total.txt
...
0
votes
0
answers
19
views
Assistance with PS Script- Trying to create a folder with todays date on a networkshare and copy files to it from 2 different locations
I am trying to:
A. copy the current application event log from server A
B. copy the current IIS logs from server A
c. create a folder with todays date on the network share and copy A and B above into ...
0
votes
0
answers
39
views
Copy-Item : Cannot find path 'C:\Pumpmate Fuel Management\PB.MDB' because it does not exist
I'm trying to run a powershell command where it makes a copy of the file "PB.mdb" in a specific location, renames it with a timestamp at the end of it, and saves it in a different location.
...
1
vote
0
answers
1k
views
Display progress when copying files and folders in powershell
Sometimes I copy large numbers of files and folders, 2 or more GB. It would be helpful if I could see how far through the task the program has progressed.
I have been using Copy-Item -Path $...
0
votes
1
answer
210
views
Copying files through a vm session using copy-item shows error when destination directory has square bracket
Copying files through a vm session using copy-item shows error when destination directory has wildcard (square bracket)
#powershell ver. 5.1.19041.2364
$vm_session = new-pssession -vmname $vmname -...
0
votes
1
answer
49
views
looking for files and make backup but keep running into error
this seemed to be a good way to make a backup of my files without having to search of them manualy
I use the following command:
Get-ChildItem -Recurse -Include *.7z, *.rar, *.zip, *.db, *.sql, *.bmp, *...
0
votes
0
answers
113
views
Copy Single File to Destination Folder if Exist else Copy to Another Folder
I am trying to copy a file from one location to another. There are two possible source destinations on the computer I would like the script to check if the folder exists (i.e. -eq 'True') if doesn't ...
0
votes
1
answer
159
views
How to delete a folder in the destination folder only if it exists in the source folder
Using Powershell, How can I delete folders in the destination folder only if they exist in the source folder?
For example I have the folder structure below and want to delete Folders1 2 and 3 before I ...
0
votes
0
answers
156
views
How to copy a folder and overwrite the full contents of the destination folder with powershell?
I want to copy folder 1 from the source directory to the destination directory however folder 1 is always a randomly generated number.
Source/Folder A:
folder 1 (random number)
file1....
1
vote
1
answer
284
views
Using a powershell loop to copy files to pattern-aware directories
I have a directory A in which containing the sub directories a, b, c, d, each sub-directory contains timestamped folders, example 20230120, and files whose names end with the date and time of day ...
0
votes
1
answer
212
views
Powershell ForEach loop, to send a file to multiple locations, not working
I am attempting to send one file to multiple locations using a ForEach loop.
It gets sent to one location, but not the second. I have noticed that the second location gets output to the host, though, ...
0
votes
1
answer
1k
views
Powershell: Copy files from .txt file and keep subfolder structure the same
Let me first say I am very bad at everything that involves coding language.
So I need some help.
The goal:
I have a source with million of files but they need to be copied in a sequential order from A ...
0
votes
1
answer
496
views
Powershell Copy-Item copies the contents of a folder to an existing directory
I'm trying what I think is a simple folder copy but i'm getting stuck on this one.
I need to copy contents of a folder to an existing Sharepoint directory
Here are my tries
$SharepointDirectory = '\\...
0
votes
1
answer
2k
views
How to copy a file from within a Docker Container to the host
Problem
I am running .NET Framework SDK to run GitHub Actions to build Releases of a project.
I need to be able to copy the built project files from the Docker Container to the host and beyond to an ...
0
votes
1
answer
210
views
Is there a way to add a postfix to this script?
So I asked here before about helping with a script to copy and paste files from one folder to another.
However, after I was done, I found that some of the files went missing. I had 600,393 files but ...
0
votes
1
answer
834
views
How to copy to ProgramFiles (X86) Via Script (From SCCM/ConfigMgr)
I'm trying to copy an AdobeOverride file from a location on the C:\ to C:\Program Files (x86)\Common Files\Adobe\UpdateResource\
This works perfectly fine for the copy to the ProgramData location but ...
1
vote
2
answers
407
views
Foreach/copy-item based on name contains
I'm trying to create a list of file name criteria (MS Hotfixes) then find each file name containing that criteria in a directory and copy it to another directory. I think I'm close here but missing ...
1
vote
2
answers
997
views
PowerShell Recursive copying and pause between each file is copied
I have the following script to recursive copy data and create a log file of the destination, could any assist please, I would like to pause for 10 seconds after each file is copied so each file ...
0
votes
1
answer
310
views
Issues trying to use Copy-Item with wildcard
OK So I've got a list of files I'm trying to copy from one folder to another.
I have a CSV with a list of partial file names eg: ABCD-EFGH
The files I want copied are in the destination folder named ...
0
votes
0
answers
143
views
Script to copy files not ending
I have a script that will copy files from a set of folder(s) which match a specific string to a location. The script runs fine for the first server, but on the second it just never ends. I have a ...
0
votes
1
answer
640
views
Powershell Copy-Item Not going to destination
I'm running the below PS to move files from one directory to another. The issue I'm having is that it does not copy the items to the destination, it copies them to the directory I'm calling the script ...
3
votes
1
answer
1k
views
Issue in Copy-Item in powershell
I used the Copy-Item command to copy a set reports to a server location. It was working fine before but recently more reports have been added to the folder and now most of the times it works fine but ...
0
votes
1
answer
388
views
Powershell ps1 Get Children Copy command basic
I'm not a coder. I have a Powershell script .ps1 that goes into all subfolders of "db" and deletes the files I want to delete in all of them. It works for what I need. The following code:
...
0
votes
1
answer
88
views
Powershell - Copy folders alongside files in each sub folder
I have the following structure
- folder1
- file1
- folder2
- file2
- folder3
- file3
- file4
- file5
- folder4
- file6
- folder5
- file7
- folder5
- file8
I am trying to copy ...
0
votes
0
answers
32
views
How to properly format a Copy-Item when filenames and file paths have apostrophes and brackets? [duplicate]
I posted yesterday about a litany of MP3 files that are in a Plex playlist which I want to put on my local PC and upload to an MP3 player. While I was able to get some of the basics down, I ...
1
vote
0
answers
189
views
How can I copy specific files from a NAS to my PC with a list of their locations and directories?
I have a playlist of MP3s that live on a Synology NAS in my home. There is a playlist of about ~500 songs I wish to download to my local PC. I have a list of all of these files and their locations in ...
3
votes
2
answers
6k
views
Copy (append) multiple files into a single destination file
I'm having a weird issue with using PowerShell to merge multiple csv files into one. I've done this plenty of time in the cmd prompt on in windows 7, but here the output only contains the earliest ...
2
votes
1
answer
364
views
Copy select items from one folder to a new folder
I am getting all wav files in the past 24 hours from one folder and putting them in another folder. I swear this worked for me a bit ago and wanted to add in some more conditional statements but now ...
0
votes
1
answer
66
views
PowerShell Error Copying a folder to remote server
am trying for a long time to copy the following folder to remote server but unfortunately giving always error.
I try alot of ways :((((
I really need a help
The code:
$ServerLists = Get-Content -Path ...
0
votes
0
answers
318
views
in powershell, copy-item and test-path are both failing silently.. is it my code, or something else...?
I frequently have to copy a single file to multiple destinations, so i'm trying to write a script to make that go faster. it seems to work fine when i'm dealing with local files, but fails without any ...
0
votes
0
answers
1k
views
Copy-item Powershell not working on windows 11
I executed this copy-item command line on windows 11:
Copy-Item -Path '//c/shared/file.xml' -Destination '\\REMOTE-PC\c$\testFolder' -Force
and It gives me unauthorized access message.
My user has ...
2
votes
2
answers
1k
views
How to pipe directly to Copy-Item instead of within a ForEach-Object
Because the -Exclude parameter of Get-ChildItem is not filtering on subfolders when using the -Recurse flag, see among other unable-to-exclude-directory-using-get-childitem-exclude-parameter-in-
...
1
vote
1
answer
5k
views
How do I log the result of Copy-Item?
I have a script that copies files from one location on a local drive to another:
$Folder = 'C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\CMSLOGS'
"Test to see if folder [$Folder] ...
0
votes
1
answer
202
views
Get files from specific directories and put them in a flat structure with new file names
The task of my PowerShell script is to get files from specified language folders and put them in a flat structure in another directory, with a new suffix (.new) and with underscore followed by the ...
0
votes
1
answer
1k
views
PowerShell: Copying Items from Network Share to Remote Server while using Credentials
I have files stored on a network share \\domain.company.com\Server01\Folder1\Path that I am looking to perform a recursive copy to a remote server \\RemoteServer1\D$\Temp\Folder1.
Initially, I looked ...
-1
votes
1
answer
494
views
Powershell functions copy-item error-exception with 2 parameters [duplicate]
Here is my question;
$source = "\\Somewhere\Overtherainbow\something.exe"
$destinationSource = "C:\temp"
Function MyCopyFunction([string]$from, [string]$to)
{
$src= $source+$...