Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vbscript VBS从AD和OU Case语句检索计算机OU以执行操作_Vbscript_Location_Ou - Fatal编程技术网

Vbscript VBS从AD和OU Case语句检索计算机OU以执行操作

Vbscript VBS从AD和OU Case语句检索计算机OU以执行操作,vbscript,location,ou,Vbscript,Location,Ou,我从ScriptIT人员那里得到了这段代码 Set objSysInfo = CreateObject("ADSystemInfo") strComputer = objSysInfo.ComputerName Set objComputer = GetObject("LDAP://" & strComputer) arrOUs = Split(objComputer.Parent, ",") arrMainOU = Split(arrOUs(0), "=") wscript.echo

我从ScriptIT人员那里得到了这段代码

Set objSysInfo = CreateObject("ADSystemInfo")
strComputer = objSysInfo.ComputerName
Set objComputer = GetObject("LDAP://" & strComputer)
arrOUs = Split(objComputer.Parent, ",")
arrMainOU = Split(arrOUs(0), "=")
wscript.echo arrMainOU(1)
我遇到的问题是,arrMainOU(1)重复两次OU。我试着设置一个简单的测试,但失败了。我在这里或谷歌上都没有看到这个问题

If arrMainOU(1) = "myOU" Then
wcript.echo "true"
End If
我需要将arrMainOU(1)中的1个值与包含OU字符串的数组进行比较。我需要一个case语句,它根据是OU1还是OU2执行操作,依此类推

不过,我一直在评估阿玛努(1)。如果我将值输出到一个文件,那么它只写入一个值


任何帮助都将不胜感激-谢谢您

请尝试此代码片段以了解“拆分”函数:

Set objSysInfo = CreateObject("ADSystemInfo")
strComputer = objSysInfo.ComputerName
Set objComputer = GetObject("LDAP://" & strComputer)
arrOUs = Split(objComputer.Parent, ",")
retstring = ""
For ii = LBound( arrOUs) To UBound( arrOUs)
    arrMainOU = Split(arrOUs(ii), "=")
    For jj = LBound( arrMainOU) To UBound( arrMainOU)
        retstring = retstring & "arrOUs(" & CSTR( ii) & ") = " & arrOUs(ii) & vbTab 
        retstring = retstring & "arrMainOU(" & CSTR( jj) & ") = " & arrMainOU(jj) & vbNewLine
    Next
    retstring = retstring & vbNewLine
Next
Wscript.Echo retstring

它在两个消息框中两次回显OU,还是在一个消息框中两次回显相同的值?