Hey Everyone,
I know this will be something simple but hey it's Friday and i can't see the syntax error. Looking for a second set of eyes to help me out here.
I have a SQL Agent job that runs a simple copy command for a bunch of csv file in a folder to another folder every hour. This is the powershell command I need assistance on as it runs fine in powershell but not through the agent
$source_dir='E:\excel_files\MasterFiles'
$dest_dir='E:\excel_files\Upload'
Get-ChildItem -Path $source_dir\ | ForEach-Object {
Copy-Item -Path $_.FullName -Destination "$dest_dir\$($_.BaseName + '_' + (Get-Date).ToString("MMddyyyy_HHmmss") + $_.Extension)"
}
Thanks in advanced!