Monday, July 13, 2015

Managing Windows Server 2012 R2 Using PowerShell : Part-10 : Creating New File Shares.

  1. Part 1 : Windows Server 2012 R2 Installation.
  2. Part 2 : Exploring PowerShell Default Settings.
  3. Part 3 : Getting and setting server name.
  4. Part 4 : Getting IP Address of the server.
  5. Part 5 : Setting IP Address of the server.
  6. Part 6 : Checking if Server is member of domain.
  7. Part 7 : Joining Server to the domain.
  8. Part 8 : Magic of PowerShell PSRemoting..
  9. Part 9 : Installing Windows Features and Roles

6-24-2015 12-42-00 PM

Part - 10 : Creating new File Shares.

There is one particular task which every I.T. Admin does on their server. Guess what it is?

It's creating network shares on server. Creating new network shares in Server2012R2 are very easy. We simple need to use the cmdlet  New-SmbShare .

Let's create  a network share folder using PowerShell. Before setup sharing, we need to create a folder first.

In the below command, we are creating a new folder using  New-Item cmdlet, we are creating a folder name ''MarketingImages" , and creating it in the 'C:\' drive root.

New-Item -Path 'C:\' -Name 'MarketingImages' -Type Directory

Aman Dhally - Manya Kaur

Aman Dhally - Manya Kaur

In the above screenshot, you can see that our folder have created successfully.

Now, we need to share it, we do use the New-SmbShare cmdlet for sharing the folder. In the below command,  in -Name we have provide the sharing name , which is "Makrting Images" ,-Path in we have give the physical path of the folder which is C:\MarketingImages, We are giving the  read only access to everyone, so we used  -ReadAccess "Everyone", I am using the AccessBased in -FolderEnumeration Mode, and in -Description, I have provided a description about the folder.

New-SmbShare -Name "Makrting Images" -Path C:\MarketingImages -ReadAccess "Everyone" -FolderEnumerationMode AccessBased -Description "This contains the royalty free images"


Aman Dhally - Manya Kaur


Our above command has run successfully, lets see if the folder is shared and accessible..



Aman Dhally - Manya Kaur


Aman Dhally - Manya Kaur

Yayy!!! it's done! Cool!

To know more about New-SmbShare visit this link : 

That's all for today, see you in next blog post.

Aman Dhally - Manya Kaur

Aman Dhally
If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube channel for PowerShell video tutorials. You can download all of my scripts from “Microsoft TechNet Gallery”.