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

powershell query OU and check folder existence

$
0
0

I want to run a process that will create server folders for all of my users.  I know i can user get-adusers to pull the samaccoutnname to pull the name i want to create for each folder but i want to pipe that name straight into creating the folder.

So if i run this:

get-aduser -filter * -Searchbase  "ou=Computer Users,dc=mydomain,dc=com"|select-object samaccountname

Can i just pipe that into a if statement that uses test-path to check if the folder exists then if it doesn't create the folder or do i need to do as i used to in a regular programming language and feed each item one at a time?  thanks.  


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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