Update Windows security remotely using powershell scheduled task

I am trying to Install windows security patches on a remote machine using powershell remoting.

When i run the script on a local host, the script is successful in installing windows security patches.I have setup both the loaclhost and remote machine for remoting and able to execute other scripts remotely.

Using Scheduled Task: I am using the following script to start a scheduled task:

 

param(
   [parameter(Mandatory = $true)]
   [string]$IPaddress
)
$PSModulePath = $env:PSModulePath
$SplittedModulePath = $PSModulePath.Split(";")
$ModulePath = $SplittedModulePath[0]
$secpasswd = ConvertTo-SecureString "Pass@12345678" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ("Admin02", $secpasswd)
#Create a Session. Replace host name with the host name of the remote machine.
$Session = New-PSSession -ComputerName $IPaddress -Credential $cred
$User= "Admin02"
$Action= New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "$env:ALLUSERSPROFILE\Install-WindowsUpdate.ps1"
$Trigger= New-ScheduledTaskTrigger -At 5:05am -Once
Invoke-Command -Session $Session -ScriptBlock { Register-ScheduledTask -TaskName "Install-Updates" -User $Using:User -Action $Using:Action -Trigger $Using:Trigger -RunLevel Highest Force }

I have copied the below script on the target machine at the path $env:ALLUSERSPROFILE

 

Install-Module -Name PSWindowsUpdate -RequiredVersion 2.1.0.1 -Force
Import-Module PSWindowsUpdate -Force
Get-WindowsUpdate -install -acceptall

After i schedule the task nothing is happening.What i am doing wrong?

Install-Module should run with the elevated permissions, not sure the run account for the job is having the elevated rights on the remote host. Please check.