如果没有编写补救脚本来添加它们,请检查组是否是本地管理员组的成员 [英] Check if group is member of local administrator group if not write remediation script to add them
问题描述
我正在创建SCCM中的CI,以发现某个组是否是本地管理员组的成员。然后向CI添加修复脚本,以将用户添加到本地管理员组。 我相信我的问题是脚本部分。 我是否正在朝着正确的方向前进?
I'm working to create a CI in SCCM to discover if a group is a member of the local administrators group. Then add a remediation script to the CI to add the user to the local administrators group. I believe my issue is the script portion. Am I going in the right direction?
发现脚本
$ group = [ ADSI ] " WinNT://./Administrators,group&q uot;
$group=[ADSI]"WinNT://./Administrators,group"
$ members = @( $ group 。 psbase 。 调用( "会员"
$members=@($group.psbase.Invoke("Members"))
(
$ members | foreach { $ _ 。 GetType() 。 InvokeMember( " Name" , 'GetProperty' < span style ="color:#a9a9a9; font-size:x-small">, $ null , $ _ , $ null )})
- 包含 " GROUPNAME"
$members|foreach{$_.GetType().InvokeMember("Name",'GetProperty',$null,$_,$null)})
-contains"GROUPNAME"
如果
( < span style ="color:#ff4500; font-size:x-small"> $ members - eq True )
($members-eqTrue)
{
{
写入输出 '符合'
{
写入输出跨度> '不符合'
}
修复脚本
net localgroup 管理员 ACCOUNTS\GROUPNAME / add
netlocalgroupadministratorsACCOUNTS\GROUPNAME/add
推荐答案
<请不要发布彩色脚本。使用代码发布工具。 彩色代码是不可交易的,通常无法正确复制。
Please don't post colorized scripts. Use the code posting tool. Colorized code is untradeable and cannot usually be copied correctly.
这篇关于如果没有编写补救脚本来添加它们,请检查组是否是本地管理员组的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!