January 5, 2018 at 12:45 pm
Hi All
I can run this from the command prompt
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File C:\DailyEtlData\EtlScripts\Powershell\MoveFileDirtoDir.ps1 -SourceServer C:\inetpub\ftproot\ -DestinationServer C:\DailyEtlData\Connect\PreLoadFilesFromFtp\ -Filename 20171202.dump.gz
if I try to run it from SQL
execute xp_cmdshell N'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File C:\DailyEtlData\EtlScripts\Powershell\MoveFileDirtoDir.ps1 -SourceServer C:\inetpub\ftproot\ -DestinationServer C:\DailyEtlData\Connect\PreLoadFilesFromFtp\ -Filename 20171202.dump.gz'
I get this error
Copy-Item : Cannot find path 'C:\inetpub\ftproot\20171202.dump.gz' because it does not exist.
At C:\DailyEtlData\EtlScripts\Powershell\MoveFileDirtoDir.ps1:9 char:1
+ Copy-Item -Path $Source -Destination $Destination;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\inetpub\ftproot\20171202.dump.gz:String) [Copy-Item], ItemNotFoundEx
ception
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
any help would be good thanks and Happy New Year
January 5, 2018 at 12:55 pm
When you run from command shell, I think it assumes the account used by SQL Server, which may not have permission to access the source directory if it is using local system account.
January 5, 2018 at 1:17 pm
RandomStream - Friday, January 5, 2018 12:55 PMWhen you run from command shell, I think it assumes the account used by SQL Server, which may not have permission to access the source directory if it is using local system account.
Thanks Random
I will take a look on Monday when I'm back online Many thanks
January 9, 2018 at 3:55 am
Thanks all that did the trick
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy