mkellerman / Invoke-CommandAs

Invoke Command As System/Interactive/GMSA/User on Local/Remote machine & returns PSObjects.

Home Page:https://www.powershellgallery.com/packages/Invoke-CommandAs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invoke-CommandAs -AsSystem broke on 2012 R2 ENG

PierreGUILBAUD opened this issue · 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.