I have followed this steps: https://blogs.technet.microsoft.com/hey ... ll-script/
and use the following Argument:
-ExecutionPolicy Bypass "C:\Scripts\Backup Report PRDBKP01-VM (Daily).PS1"
Set the Scheduled Task as Run with Highest privileges.
Grant the Service account as Local Administrators of the server where it is running.
Script Source: https://gist.githubusercontent.com/smas ... Report.ps1
The Scheduled Task does not return any error (last code was 0x1).
I have already tried that to encode the large 1000 lines+ script as .BAT script as follows:
Code: Select all
@echo off echo Executing Backup Summary Report call :callPS PSScript1 exit /b :callPS label powerShell.exe -ExecutionPolicy RemoteSigned -Command "$script = Get-Content '%~f0'; Invoke-Expression -Command ($script[(($script | select-string '::%1::').LineNumber)..(($script | select-string '::%1End::').LineNumber-2)] -join [environment]::NewLine)" exit /b ::PSScript1:: Add-PSSnapin "VeeamPSSnapIn" -ErrorAction SilentlyContinue # the rest of the PowerShell script goes here.... ::PSScript1End::
It only works when I execute it under PowerShell ISE Run as Administrator.
Can anyone here please help?