Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Split a specific property from the output of get-aduser

$
0
0

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

 


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>