PowerShell – Copy Files from Source to Destination

As strange as it sounds, I was the sole admin responsible for ConfigMgr yet didn’t have access to the Primary site server. I asked for permission but it was denied.

Whatever the case was, I still needed to get my hands on the ConfigMgr log files so I went looking for a script that would copy the Logs folder (SOURCE) from C:\Program Files\Microsoft Configuration Manager\Logs\ to a network share I created \\FileServer\ConfigMgr\Logs\ (TARGET).

Here are 5 lines of PowerShell that will get the job done for you, which I found here:

$TimeStamp = get-date -f yyyyMMddhhmm
$Destination = "\\FileServer\ConfigMgr\Logs\" + $TimeStamp
$Source = "C:\Program Files\Microsoft Configuration Manager\Logs"
New-Item -ItemType directory -Path $Destination -Force
Copy-Item -Path $Source*.* -Destination $Destination -Force

Leave a Reply

Your email address will not be published. Required fields are marked *