problem with GPOs in powershell studio

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Post Reply
martial.berda@groupe-lacour.fr
Posts: 2
Joined: Thu Mar 28, 2019 4:10 pm

problem with GPOs in powershell studio

Post by martial.berda@groupe-lacour.fr » Mon Sep 16, 2019 2:25 am

Hello,
here is my script:
import-Module GroupPolicy
Get-GPO -all -Domain mydomain.com -server myserver

I execute this script on a 2008 R2 (ps v5) server joined to the domain:
it works in ISE, but with powershell studio, I have this message:

the 'Get-GPO' command was found in the 'GroupPolicy' module,
but the module could not be loaded. For more information,
run 'Import-module GroupPolicy'

Can you help me, please

User avatar
Alexander Riedel
Posts: 7049
Joined: Tue May 29, 2007 4:43 pm

Re: problem with GPOs in powershell studio

Post by Alexander Riedel » Mon Sep 16, 2019 9:06 am

If it works with the ISE it works in PowerShell Studio, it is the same PowerShell.
Usually this happens because a different platform, version or bitness is selected in PowerShell Studio. Maybe you run the ISE elvated?
Try to turn STA on if you not have yet. Try to use "Run in console" in PowerShell Studio, maybe you have a dependency on something in your profile.
If all fails, the actual output, maybe as a screenshot, is usually helpful.
Alexander Riedel
SAPIEN Technologies, Inc.

martial.berda@groupe-lacour.fr
Posts: 2
Joined: Thu Mar 28, 2019 4:10 pm

Re: problem with GPOs in powershell studio

Post by martial.berda@groupe-lacour.fr » Tue Sep 17, 2019 12:16 am

Thank you for your reply

The sta mode is activated.
I do not think that is an elvated problem.

I installed the program powershell studio on another server joined to the domain and it works.
The servers are identical, I would like to know why does it work on one server and not the other.

User avatar
Alexander Riedel
Posts: 7049
Joined: Tue May 29, 2007 4:43 pm

Re: problem with GPOs in powershell studio

Post by Alexander Riedel » Tue Sep 17, 2019 8:44 am

Hard to tell without any information or actual access to compare things.
I mean is you would try the console suggestion and post the actual powershell error message in full, maybe we would see something.
[Edit: Apologies, it already was in the PowerShell section]
Alexander Riedel
SAPIEN Technologies, Inc.

Post Reply