This PS script works in the PS window on my SQL server 2012, but does not work as a SQL Job step. The SQL job step errors with "error information returned by PowerShell is: 'Cannot call method. The provider does not support the use of filters. '. Process Exit Code -1. The step failed." Is it possible for the version of PS and the version pf PS used by SQL to be different? Suggestions for a fix? Basically need to copy the latest version of a file to a different location with different name.
$filterNTC="*_filename.csv" $dir = "\\networkloc\folder\folder\folder\folder\folder\" $latestNTC = Get-ChildItem -Path $dir -Filter $filterNTC | Sort-Object LastAccessTime -Descending | Select-Object -First 1 $sourcefile = "\\networkloc\folder\folder\folder\folder\folder\" + $latestNTC.name Copy-Item -Path $sourcefile -Destination D:\folder\folder\folder\folder\filename.csv