当我执行以下powershell脚本时,
Site_ForList
它将返回
Import-Module activedirectory
Get-ADPrincipalGroupMembership someuser | select Name
如何返回附加“ _1234”的结果,如:
Name
----
Domain Users
答案 0 :(得分:2)
您可以使用计算所得的属性。
from collections import defaultdict
recs = defaultdict(list)
for item in test:
name = os.path.basename(item)
no_ext = name.split('.')[0]
recs[no_ext].append(name)
to_delete = [val for v in recs.values() for val in v if len(v) >= 2 and val.endswith('.txt')]
for item in to_delete:
os.remove(os.path.join(pathforRemove, item))