The term 'Set-ExecutionPolicy' is not recognized as the name of a cmdlet

Hello everyone, I Am trying to invoke the set-executionpolicy cmdlet on my test computer but for some reason its returning an error station that the cmdlet is not recognized as the name of a cmdlet. My test computer hostname is WS1095 and this is the command that I am using;

Invoke-Command -ComputerName WS1095 -ScriptBlock {Set-ExecutionPolicy remotesigned -Force}

Please any tips or advice will be greatly appreciated.

I’d normally troubleshoot by first attempting to run the command locally on that computer. Can you try that?

Oh lord the MAN that I learned powershell FROM!
Its an Honor to have you respond to my post!!

Yes sir, I have tried to run the command locally and I am able to set the execution policy with no problem. =/

Then it’s probably something locked down in the tempting endpoint on that machine. That’s not deeply unusual.

Try going into the remote computer using Enter-PSSession and run a Get-Command -Verb Set and see what comes up.

Setting execution policy remotely is a bit of an edge case. You’d not ordinarily do that.

This is a little bizarre but trying Enter-pssession returns this:

PS C:\WINDOWS\system32> Enter-PSSession -ComputerName ws1095 -Credential $creds
Enter-PSSession : The term ‘Measure-Object’ 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.
At line:1 char:1

  • Enter-PSSession -ComputerName ws1095 -Credential $creds
  •   + CategoryInfo          : ObjectNotFound: (Measure-Object:String) [Enter-PSSession], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

Not sure where its picking up measure-object from. It was working fine till recently. I am able to remote to other clients with no issues without getting the same error that this one is producing. Also when I run get-command -verb, the set-executionpolicy exist as well as the Enter-pssession cmdlet.

Thank you so much for taking your time and helping me.

Not odd - that’s a locked-down endpoint. Run Get-PSSessionConfiguration on the box and see what’s what. I’m guessing either the default endpoint was changed, or a new locked down endpoint was made the default. You may have to create a wide open endpoint and connect to it by name.

ran it on the machine and this is what it returned.

PS H:> Get-PSSessionConfiguration

Name : microsoft.powershell
PSVersion : 5.1
StartupScript :
RunAsUser :
Permission : BUILTIN\Administrators AccessAllowed

Name : microsoft.powershell.workflow
PSVersion : 5.1
StartupScript :
RunAsUser :
Permission : BUILTIN\Administrators AccessAllowed

Name : microsoft.powershell32
PSVersion : 5.1
StartupScript :
RunAsUser :
Permission : BUILTIN\Administrators AccessAllowed

aaaahhh I see now. After staring hard at it I get whats going on. I was able to run the command using local admin creds. Not sure how this ended up being changed but like you stated, it was indeed locked down to only the local admin!

Even after those long 90 LONG videos on CBT nuggets you continue to be one of the most amazing help out there.
Thank you for taking your time to help me figure this issue out!!

Now I just need to figure out how to change this to the correct permissions =D lol