Problem
The offline installer (.exe) will extract and try to use WUSA to install .Net Framework. This will fail and if you check the installation log you will see an access denied message.
This is because Wusa.exe is not allowed to run remote as described in http://www.owl-it.nl/uncategorized/powershell-remote-wusa-exe-not-working-access-denied/
This article provides a work around using wusa to extract (which is allowed) and using dism to install the cab files.
Now if you want to install .Net Framework remote using PowerShell using the offline installer you run into the same problems.
The offline installer (.exe) will extract and try to use WUSA to install .Net Framework. This will fail and if you check the installation log you will see an access denied message.
Solution
The solution installing .Net Framework remote using PowerShell is to create a scheduled task to start the offline installer (.exe).
Although this sounds easy there are some things to take into consideration.
You will get the below error message when you want to create the task and set to delete afterwards all in one go.
register-ScheduledTask : The task XML is missing a required element or
attribute. (49,4):EndBoundary:
At E:\ARUN\TestScript\AutomateScheduledTask.ps1:33 char:4
+ Register-ScheduledTask -Action $action -Trigger $trigger -TaskPath ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [Register-ScheduledTask], CimException
+ FullyQualifiedErrorId : HRESULT 0x80041319,Register-ScheduledTask
This is a bug :
https://stackoverflow.com/questions/50974448/error-creating-scheduled-task
Work Around
The idea is to schedule the task 10 seconds from now, run the task and once finished delete it again.
First create the task :
$exe = "C:\temp\NDP452-KB2901907-x86-x64-AllOS-ENU.exe"
$action = New-ScheduledTaskAction -Execute $exe -Argument "/q /Norestart"
$trigger = New-ScheduledTaskTrigger -Once -At (get-date).AddSeconds(10)
$settings = New-ScheduledTaskSettingsSet -Compatibility Win8
Register-ScheduledTask -TaskName ".Net Framework Installation Task" -Force -User System -Action $Action -Trigger $Trigger -Settings $Settings
After the task creation we need to edit the task again, this is because the bug.
$task = (Get-ScheduledTask -TaskName "Install452")
$task.triggers[0].EndBoundary = (get-date).AddSeconds(60).ToString('s')
$task.Settings.DeleteExpiredTaskAfter = "PT0S"
Set-ScheduledTask -InputObject $task