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

Issue with Windows 7 machines

dfranciscus opened this issue · comments

When I run the command below against Windows 7 machines I am getting this error. I believe this used to happen in an earlier version.

C:\Scripts\PowerShell> invoke-commandas -ComputerName hslllp2 -ScriptBlock {choco list -lo} -AsSystem
The term 'Get-ScheduledTask' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-ScheduledTask
+ PSComputerName : hslllp2

I'll need a test VM to play with, but try and comment out line:
https://github.com/mkellerman/Invoke-CommandAs/blob/master/Invoke-CommandAs/Private/Invoke-ScheduledTask.ps1#L136

See if it works, and at the same time, make sure that the ScheduledTask get's removed correctly please.

Created a W2008R2 vm to test with. i think there might be an issue with more lines than just L136, i'll investigate.

I got a W2008R2 and a W2012R2 machine for testing.

At the moment, W2008R2 with PSv2.0 fails horribly. I just had to test it.. 🤣
I'm upgrading the VM to run with PSv3.0 now, and will be able to test more in the morning.

I did tones of rework to the script, and did some major stability improvements on W2012R2.

I'm wondering what is the lowest version of PS I'm trying to support at this point.
What version are you running in your environment?

Got it to work on Windows Server 2008 R2 + PS3.0

It should work fine on Windows 7, but will need you to test!

Version 3.1.0 published to PSGallery
Fixed #18