'SQL job cannot delete snapshot

I have an issue with deleting snapshot job. The SQL Server job history shows:

Message Executed as user: NT Service\SQLSERVERAGENT. The step did not generate any output. Process Exit Code 255. The step failed.

NT Service\SQLSERVERAGENT account has "full control" permissions to whole snapshot path.

My job has one step:

Get-ChildItem -Path G:\Data\snapshot\unc\SNAPSHOT_PUBLICATION -Include *.* -Recurse | foreach { $_.Delete()}
get-Date >> g:\data\snapshot\unc\snapshot-cleaner.log

Any ideas why this action fails every time?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source