In this post, we will share a useful PowerShell script that simplifies file and folder management tasks. This script allows you to create a folder, copy files into it, and list the contents of the folder. Using PowerShell for such tasks can enhance your productivity and automate routine operations.
powershell
$sourceFiles = "C:\SourceFolder\*"
$destinationFolder = "C:\DestinationFolder"
# Check if the destination folder exists; if not, create it
if (-Not (Test-Path $destinationFolder)) {
New-Item -ItemType Directory -Path $destinationFolder
}
# Copy files from the source directory to the destination directory
Copy-Item -Path $sourceFiles -Destination $destinationFolder -Recurse
# List the contents of the destination folder
Get-ChildItem -Path $destinationFolderRun it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
Ready when you are.
Try ServerEngine free for 7 days.