We have a field in AD that was generated for usage by a login script. I am trying to extract a portion of that field for another use, and can not figure out how to process the data and add it to the array...
$get = get-aduser -Filter {EmailAddress -ne 0 -and enabled -eq "True"} -Properties DisplayName, samaccountname, HomeDirectory | Select-Object DisplayName, samaccountname, HomeDirectory
My output will be this;
DisplayName samaccountname HomeDirectory
----------- -------------- -------------
My Name login
L:\Server2\vol_1\DIR
I am trying to use the $_Split function to get an additional Column of "Server" which should be built from >
HomeDirectory.split("\")[1]
But I can not figure out how to get what I want...
Obviously I am trying to get this for all my AD users, but that line is an example...
How can I get my output array to look like this?
DisplayName samaccountname HomeDirectory Server
----------- -------------- ------------- ----------
My Name login
L:\Server2\vol_1\DIR Server2