Create Shared Folder using PowerShell

Here in this below sample script am creating multiple Shared folder which are given in a "userlist.txt" where the "userlist.txt" acts as a source file with the data which will hold the names of the folder to be created.
 
The "userlist.txt" should contain the name of the users\folders which has to be created as a Shared folder.
  1. #Provide the user list file path to the variable $UserList  
  2. $UserList = "E:\VJ\userlist.txt"  
  3. #provide the directory path where you need to create a new folders to the variable $folderpath  
  4. $folderpath = "E:\VJ\Test\"  
  5. $Users=Get-Content $UserList  
  6. foreach($user in $Users)  
  7. {   
  8. #Below command wil create new folders  
  9. New-Item -ItemType directory -Path $foldername  
  10.   
  11. #Below command will change the created folder as a Shared folder with full permission to everyone.  
  12. New-SmbShare –Name $user –Path $foldername –FullAccess Everyone  
  13. }