# -*- coding: utf-8 -*-

name = 'create-gpo'
description = 'Create a new GPO in AD'
args = {
	'name': dict(help='Name of the new GPO', required=True),
	'comment': dict(help='Comment for new GPO', required=True),
}

ps = '''

# another way
#$gpm = New-Object -ComObject GPMgmt.GPM
#$constants = $gpm.GetConstants()
#$GPODomain = $gpm.GetDomain("%(domain)s",$null,$contants.UsePDC)
#$GPOs = $GPODomain.SearchGPOs($gpm.CreateSearchCriteria())
#$GPOs
#$GPOs | Foreach-Object{
#	$gpmSearchCriteria = $gpm.CreateSearchCriteria()
#	$gpmSearchCriteria.Add($constants.SearchPropertySomLinks,$constants.SearchOpContains,$_)
#	$somList = $GPODomain.SearchSoms($gpmSearchCriteria)
#	if($somList.Count -gt 0) {$somList.DisplayName}
#}

$check = get-windowsfeature -name gpmc
if ($check.Installed -ne "True") {
	Add-WindowsFeature gpmc
}
Import-Module grouppolicy
$ErrorActionPreference = "Stop"
New-GPO -Name "%(name)s" -comment "%(comment)s"
'''
