好的,这是甜蜜而简单的。我需要验证是否在新版本中添加了一个组列表到本地管理组(以及其他内容),因此我可以将服务器提升为prod ...
到目前为止,我可以获取组,并将布尔输出到远程服务器上的文件,获取该内容(我想我应该管它但不知道如何)。我想做的是返回一组带有组名的变量,以及它是否存在于本地管理组中。但是......那不是发生的事情......
抱歉基本的ifElse条款,我的谦逊技巧不是最简单的......这是我一直在使用的代码 - 提前谢谢!:
df_over <- over(quilpue_prj, pointsCoords)
plot(quilpue)
plot(pointsCoords, add = TRUE)
答案 0 :(得分:0)
好的,经过多次讨论,我放弃了上面的代码,转而采用这种更简单的方法。稍微不那么健壮,但很简单并完成工作......当然,如果你有更多的组要验证,那么只需添加更多if语句和相应的变量。
享受:
$group =[ADSI]"WinNT://./Administrators,group"
$members = @($group.psbase.Invoke("Members"))
$VerAdminGrp01 = ($members | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}) -contains "Domain Admins"
if($VerAdminGrp01){$ResDomAdmin = "Validation Passed: Domain Admins is a member of the local admin group."}
Else {$ResDomAdmin = "VALIDATION FAILED: Domain Admins is not a member of the local admin group."}
$VerAdminGrp02 = ($members | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}) -contains "Enterprise Backup Admins"
if($VerAdminGrp02){$ResEntBakAdmin = "Validation Passed: Enterprise Backup Admins is a member of the local admin group."}
Else {$ResEntBakAdmin = "VALIDATION FAILED: Enterprise Backup Admins is not a member of the local admin group."}
答案 1 :(得分:0)
您可以通过创建要检查的项目数组并循环遍历该数组来清理一下。
$group =[ADSI]"WinNT://./Administrators,group"
$members = @($group.psbase.Invoke("Members")) | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
$List = "Domain Admins","Enterprise Backup Admins"
foreach ($item in $list) {
if ($members -contains $item) {
"Validation Passed: $item is a member of the local admin group."
} else {
"VALIDATION FAILED: $item is not a member of the local admin group."
}
}