Invoke-CommandAs icon indicating copy to clipboard operation
Invoke-CommandAs copied to clipboard

Invoke-CommandAs -AsSystem broke on 2012 R2 ENG

Open PierreGUILBAUD opened this issue 4 years ago • 0 comments

Hello,

I have a issue on 2012 R2 ENG :

PS C:\Users\Administrator> Invoke-CommandAs -ScriptBlock { Get-Process } -AsSystem New-ScheduledTaskAction : Invalid class At C:\Program Files\WindowsPowerShell\Modules\Invoke-CommandAs\3.1.6\private\Invoke-ScheduledTask.ps1:89 char:49

  • ... 'Action'] = New-ScheduledTaskAction -Execute $ScheduledJob.PSExecutio ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : MetadataError: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [New-ScheduledTaskAc tion], CimException
    • FullyQualifiedErrorId : HRESULT 0x80041010,New-ScheduledTaskAction

New-ScheduledTaskPrincipal : Invalid class At C:\Program Files\WindowsPowerShell\Modules\Invoke-CommandAs\3.1.6\private\Invoke-ScheduledTask.ps1:91 char:56

  • ... incipal'] = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM" ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : MetadataError: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [New-ScheduledTaskPr incipal], CimException
    • FullyQualifiedErrorId : HRESULT 0x80041010,New-ScheduledTaskPrincipal

Invoke-ScheduledTask : Cannot validate argument on parameter 'Principal'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At C:\Program Files\WindowsPowerShell\Modules\Invoke-CommandAs\3.1.6\public\Invoke-CommandAs.ps1:399 char:17

  •             Invoke-ScheduledTask @Parameters
    
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-ScheduledTask

The version of powershell is 5.1

Thank for your help.

PierreGUILBAUD avatar May 21 '21 13:05 PierreGUILBAUD