You are not logged in.
I have a text file filled with user data that I need pull from with data like:
dn:CN=Jacobson\, Carlton
>sn: Jacobson
>givenName: Carlton
>displayName: Jacobson, Carlton
>userAccountControl: ###
>employeeID: ###
>objectSid: ###
>sAMAccountName: ###
>mail: Carlton.Jacobson@###.com
I used the following code to get some values:
$patternName = "Jacobson, Carlton"
$userInfo = Select-String $adfindPath -pattern $patternName -context 3, 5
$userInfo = $userInfo.Context.DisplayPreContext + $userInfo.Line + $userInfo.Context.DisplayPostContext
$userID = getADFINDValue $userInfo ">sAMAccountName: "
$mail = getADFINDValue $userInfo ">mail: "
$firstname = getADFINDValue $userinfo ">givenName: "
$surname = getADFINDValue $userinfo ">sn: "
But what if there was variable amount of information and I didn't want to pull information from another person's account? The problem cannot be solved very simply because I do not know what the dn: will be, so I cannot just find that then find the next instance of mail: and get everything in between. I think you could do it using IndexOf but I'm not going to go there, yet. Also, I think my parsing into variables is a bit crude.
Offline
Including my simple function to strip out the data:
Function getADFINDValue ($ADinput, $ADvalue)
{
$output = $ADinput | select-string -Pattern $ADvalue
return $output.Line.Replace($ADvalue, "")
}
Offline