@@ -1141,12 +1141,10 @@ def add_members(self, members: list[ADUser | ADGroup]) -> ADGroup:
11411141 :return: Self.
11421142 :rtype: ADGroup
11431143 """
1144- self .role .host .conn .run (
1145- f"""
1144+ self .role .host .conn .run (f"""
11461145 Import-Module ActiveDirectory
11471146 Add-ADGroupMember -Identity '{ self .dn } ' -Members { self .__get_members (members )}
1148- """
1149- )
1147+ """ )
11501148 return self
11511149
11521150 def remove_member (self , member : ADUser | ADGroup ) -> ADGroup :
@@ -1169,12 +1167,10 @@ def remove_members(self, members: list[ADUser | ADGroup]) -> ADGroup:
11691167 :return: Self.
11701168 :rtype: ADGroup
11711169 """
1172- self .role .host .conn .run (
1173- f"""
1170+ self .role .host .conn .run (f"""
11741171 Import-Module ActiveDirectory
11751172 Remove-ADGroupMember -Confirm:$False -Identity '{ self .dn } ' -Members { self .__get_members (members )}
1176- """
1177- )
1173+ """ )
11781174 return self
11791175
11801176 def __get_members (self , members : list [ADUser | ADGroup ]) -> str :
@@ -1835,12 +1831,10 @@ def get(self, key: str) -> str | None:
18351831 :return: Key value.
18361832 :rtype: str
18371833 """
1838- result = self .role .host .conn .run (
1839- rf"""
1834+ result = self .role .host .conn .run (rf"""
18401835 $query = "(&(ObjectClass=groupPolicyContainer)(DisplayName={ self .name } ))"
18411836 Get-ADObject -SearchBase "{ self .search_base } " -Properties "*" -LDAPFilter $query
1842- """
1843- ).stdout_lines
1837+ """ ).stdout_lines
18441838
18451839 i = 0
18461840 while i < len (result ):
@@ -1881,8 +1875,7 @@ def add(self) -> GPO:
18811875 self .cn = self .get ("CN" )
18821876 self .dn = self .get ("DistinguishedName" )
18831877
1884- self .role .host .conn .run (
1885- rf"""
1878+ self .role .host .conn .run (rf"""
18861879 Import-Module GroupPolicy, PSIni
18871880 $path = "C:\\Windows\\SYSVOL\\domain\\Policies\\{ self .cn } \\Machine\\Microsoft\\Windows NT\\SecEdit"
18881881 $file = Join-Path $path GptTmpl.inf
@@ -1892,8 +1885,7 @@ def add(self) -> GPO:
18921885 Out-IniFile -InputObject $content -FilePath $file
18931886 Test-Path -Path "$path"
18941887 Exit 0
1895- """
1896- )
1888+ """ )
18971889 return self
18981890
18991891 def link (
@@ -1970,8 +1962,7 @@ def permissions(self, target: str, permission_level: str, target_type: str | Non
19701962 :rtype: GPO
19711963 """
19721964 if permission_level == "None" and target == "Authenticated Users" :
1973- self .role .host .conn .run (
1974- rf"""
1965+ self .role .host .conn .run (rf"""
19751966 # Some test scenarios require making the GPO unreadable. Changing the 'Authenticated Users',
19761967 # 'S-1-5-11' SID permissions to 'None' accomplishes that. The confirm prompt cannot be skipped
19771968 # using Set-GPPermissions, for more information. https://support.microsoft.com/kb/3163622
@@ -1990,8 +1981,7 @@ def permissions(self, target: str, permission_level: str, target_type: str | Non
19901981 $authenticated_users, "ReadProperty", "Deny")
19911982 $gpo_adsi.psbase.get_objectSecurity().AddAccessRule($ace)
19921983 $gpo_adsi.psbase.CommitChanges()
1993- """
1994- )
1984+ """ )
19951985 else :
19961986 self .role .host .conn .run (
19971987 f'Set-GPPermission -Guid "{ self .cn } " '
@@ -2056,37 +2046,31 @@ def policy(self, logon_rights: dict[str, list[ADObject]], cfg: dict[str, Any] |
20562046
20572047 ps_logon_rights = attrs_to_hash (_logon_rights )
20582048
2059- self .host .conn .run (
2060- rf"""
2049+ self .host .conn .run (rf"""
20612050 Import-Module PSIni
20622051 $path = "C:\\Windows\\SYSVOL\\domain\\Policies\\{ self .cn } \\Machine\\Microsoft\\Windows NT\\SecEdit"
20632052 $file = Join-Path $path GptTmpl.inf
20642053 $policy = @{{"Privilege Rights"={ ps_logon_rights } }}
20652054 Out-IniFile -InputObject $policy -FilePath "$file"
20662055 Exit 0
2067- """
2068- )
2056+ """ )
20692057
20702058 if cfg is not None :
20712059 ps_cfg = attrs_to_hash (cfg )
2072- self .host .conn .run (
2073- rf"""
2060+ self .host .conn .run (rf"""
20742061 Import-Module PSIni
20752062 $path = "C:\\Windows\\SYSVOL\\domain\\Policies\\{ self .cn } \\Machine\\Microsoft\\Windows NT\\SecEdit"
20762063 $file = Join-Path $path GptTmpl.inf
20772064 $policy = { ps_cfg }
20782065 Out-IniFile -InputObject $policy -FilePath "$file"
20792066 Exit 0
2080- """
2081- )
2067+ """ )
20822068
2083- self .host .conn .run (
2084- rf"""
2069+ self .host .conn .run (rf"""
20852070 $gpc = "[{{827D319E-6EAC-11D2-A4EA-00C04F79F83A}}{{803E14A0-B4FB-11D0-A0D0-00A0C90F574B}}]"
20862071 Set-ADObject -Identity "{ self .dn } " -Replace @{{gPCMachineExtensionNames=$gpc}}
20872072 Exit 0
2088- """
2089- )
2073+ """ )
20902074
20912075 return self
20922076
0 commit comments