How to use GroupPolicy in PowerShell

Deok Jong Moon 125 Reputation points
2023-03-07T01:58:59.2433333+00:00

Hi there,

Basically, I'm trying to develop a programme that uses GroupPolicy in PowerShell, to manage application installation, uninstallation, and block some applications etc., on multiple Windows devices(I think the usage is correct here).

However, there seem to be multiple issues on it, and because there is not a complete guide to tackle it, I'm having a great difficulty here. Let me describe what issues I've got at the moment, and just to remind the readers of this post, what I'm trying is developing a programme using GroupPolicy, if it is a valid way.

The problems.

  • "Get-GPO" and "New-GPO" do not work, saying "Current security context is not associated with an Active Directory domain or forest"
  • Or when having tried to open Active Directory Administrative Center, it says "Your account or computer is not joined to any domain. Join to a domain and try again."
  • So I tried to join my local account to a domain in Settings -> Access Work or School and Control Panel -> System and Security -> System, but it kept saying "DNS does not exist" or "That domain couldn't be found. Check the domain name and try again"
  • As for the domain name, or DNS, the device I'm using is connected to a wifi and seems like I figured out the DNS of the wifi, written "xxx.iptime.org", and I tried to type almost every possible keywords I got from there, including IPs the wifi was using.
  • And thought 'Is it because Domain Controller is missing?' or 'because AD DS is not installed?'. But couldn't manage to find a way for them.

As a beginner in .NET and PowerShell development, I think I'm lost now :(

Someone's help would be appreciated a lot(especially if there is any complete guide for people like me)

Thanks in advance.

Windows for business Windows Client for IT Pros Directory services Active Directory
Windows for business Windows Server User experience PowerShell
Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,751 Reputation points
    2023-03-07T15:30:06.1+00:00

    Hello there,

    To use the Group Policy PowerShell cmdlets, you must have GPMC installed on the device where you will run the cmdlets. To check if the Group Policy PowerShell module is installed on a device, run the command below, which will display all the available Group Policy cmdlets available if the module is installed.

    Get-Command -Module GroupPolicy

    Maybe this module might be helpful for you in understanding the process of GPO.

    This topic contains brief descriptions of the Windows PowerShell cmdlets that are for use in administering Group Policy in Windows Server and Windows client with Remote Server Administration Tools (RSAT) installed. (RSAT includes the GPMC and the Group Policy cmdlets.) https://learn.microsoft.com/en-us/powershell/module/grouppolicy/?view=windowsserver2022-ps

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.