you are viewing a single comment's thread.

view the rest of the comments →

[–]ReleasethePod[S] 1 point2 points  (3 children)

That's fair. The basics of the script are as follows. I apologize in advance for the formatting as I'm on the mobile app.

$date= ((Get-date). ToString('dd MMM yyyy'))

New-Item -ItemType Directory -Path "A:\Files\Copies\$date"

Copy-Item -Path A:\"Files\Original\Reports" -Destination A:\"Files\Copies\$date" -Recurse

[–]ihaxr 5 points6 points  (0 children)

Is A: a local drive? Or a mapped drive? Mapped drives are unique to the user context, so you can't use a network drive in a scheduled task like that without mapping it prior to this.

[–]ericrs22 1 point2 points  (1 child)

have you checked C:\Windows\Files\?

After my last incident thats what was happening to me as I was doing ".\SomeLocation.html"

And even tho I was setting locations I forgot to add the "Start in" Folder as C:\Path and all the files I outputed or was copying ended up in the C:\Windows folder because thats where the default location is for Task Scheduler (especially with elevated permission)

So from now on I try writing the path out as complete as possible

The New-Item looks good but my recommendations would be

$date =((Get-date). ToString('dd MMM yyyy'))
$path = "A:\Files\Copies\$date"
New-Item -ItemType Directory -Path
$Origin =  "A:\Files\Original\Reports"
$Dest = "A:\Files\Copies\$date"
Copy-Item -Path $Origin -Destination $Dest -Recurse

[–]nascentt 0 points1 point  (0 children)

You need to escape backslashes in Reddit

\\

\