nazir_hussain Posted June 16, 2017 Posted June 16, 2017 Need help with sorting _AD_GetGroupMembers output to simple string, From this: CN=Hostname01,OU=Floor,OU=Computers,OU=Mumbai,DC=Domain,DC=com CN=Hostname02,OU=Training Computers,OU=Floor,OU=Computers,OU=Mumbai,DC=Domain,DC=com To this: Mumbai\Computers\Floor Mumbai\Computers\Floor\Training Computers I am using code: $String = StringReplace($String, ",DC=Domain,DC=com", "") $String = StringReplace($String, "CN=" & $Computer & ",OU=", "") $String = StringReplace($String, ",OU=", "\") But output is: Floor\Computers\Mumbai Training Computers\Floor\Computers\Mumbai Need to reverse this or need simple & faster code using StringRegExpReplace or other. Thanks.
david1337 Posted June 19, 2017 Posted June 19, 2017 (edited) #include <String.au3> $FQDN1 = "CN=Hostname01,OU=Floor,OU=Computers,OU=Mumbai,DC=Domain,DC=com" $FQDN2 = "CN=Hostname02,OU=Training Computers,OU=Floor,OU=Computers,OU=Mumbai,DC=Domain,DC=com " $FQDN1_a = _StringBetween($FQDN1,"CN=Hostname01,OU=Floor,OU=Computers,OU=", ",DC=Domain,DC=com")[0] $FQDN1_b = _StringBetween($FQDN1,"CN=Hostname01,OU=Floor,OU=", ",OU=Mumbai,DC=Domain,DC=com")[0] $FQDN1_c = _StringBetween($FQDN1,"CN=Hostname01,OU=", ",OU=Computers,OU=Mumbai,DC=Domain,DC=com")[0] $FQDN2_a = _StringBetween($FQDN2,"CN=Hostname02,OU=Training Computers,OU=Floor,OU=Computers,OU=", ",DC=Domain,DC=com")[0] $FQDN2_b = _StringBetween($FQDN2,"CN=Hostname02,OU=Training Computers,OU=Floor,OU=", ",OU=Mumbai,DC=Domain,DC=com")[0] $FQDN2_c = _StringBetween($FQDN2,"CN=Hostname02,OU=Training Computers,OU=", ",OU=Computers,OU=Mumbai,DC=Domain,DC=com")[0] $FQDN2_d = _StringBetween($FQDN2,"CN=Hostname02,OU=", ",OU=Floor,OU=Computers,OU=Mumbai,DC=Domain,DC=com ")[0] MsgBox(0,"FQDN1", $FQDN1_a & "\" & $FQDN1_b & "\" & $FQDN1_c) MsgBox(0,"FQDN2", $FQDN2_a & "\" & $FQDN2_b & "\" & $FQDN2_c & "\" & $FQDN2_d) Edited June 19, 2017 by david1337
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now