CopyLogs with slight of hand

Copy logs form a Client to Server its pretty easy, and you can get it very shiny with a easy solution.
This solution is with username and computername, because we want to copy something in the users profile.

Here is the bundle with .csv file, and the powershell script:

First you  need a .CSV file in the same folder as the script is, below i have it in C:\CopyLogs\computernames.csv, and it should look like this:

Second look at the script, you dont need to change anything
The code looks like this


This script copy logs from client to server, with a csv file that contains usernames and computernames.

Created: 2020-04-02
Version: 1.0

Author : Pontus Wendt
Twitter: @pontuswendt
Blog :

Disclaimer: This script is provided "AS IS" with no warranties, confers no rights and
is not supported by the author.

#Gather computernames
$ComputerNamePath = "C:\CopyLogs\computernames.csv"

$ComputerNames = Import-csv -path $ComputernamePath
$date = Get-date -format yyyy/MM/dd
$Computernames | ForEach-Object {

Copy-item -path "\\$($_.Computername)\C$\$($_.Username)\appdata\local\temp\asdf.log" -Destination "C:\Copylogs\$($_.Username)+$($_.Computername)+$date+asdf.log"

If you run the script right now, it will copy files from the client to the server, and place it in C:\CopyLogs and will have the name like this:

Let say you want it to run every day at 4 PM its the best thing to do a normal Schedule task

Go to Task Scheduler
Click Create task

Do like settings below, make sure the tickbox its “hidden”

On Triggers, Click New, Then make like the settings below

On Actions, Click New,
Then Choose action Start a Program
Then make sure to write this in Program/Script box

mshta vbscript:Execute(“CreateObject(“”Wscript.Shell””).Run “”powershell -NoLogo -Command “”””& ‘C:\CopyLogs\Copylogs.ps1′””””””, 0 : window.close”)

Then OK and close.

Now you have a Schedule task that copy logs from the client to the server.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s