Author Posts

September 25, 2017 at 3:26 pm

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.

September 25, 2017 at 3:29 pm

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

September 25, 2017 at 3:34 pm

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. =/

September 25, 2017 at 3:46 pm

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

September 25, 2017 at 3:53 pm

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.

September 25, 2017 at 4:16 pm

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.

September 25, 2017 at 4:24 pm

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.

September 25, 2017 at 5:27 pm

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

September 25, 2017 at 5:35 pm

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