When you run it manually, it runs as your account which has administrator access to server01. The most likely problem is that the account that you configured to run the task as does not have admin access. Also "System" will not work.
Add a transcript to the script so that you can see what it does.
Start-Transcript C:\YourLogFolder\MyTask.log
$remoteComputer = 'server01'
$session = New-PSSession -ComputerName $remoteComputer
Invoke-Command -Session $session -ScriptBlock {
$status = Get-MpComputerStatus
...
Stop-Transcript