- Part 1 : Windows Server 2012 R2 Installation.
- Part 2 : Exploring PowerShell Default Settings.
- Part 3 : Getting and setting server name.
- Part 4 : Getting IP Address of the server.
- Part 5 : Setting IP Address of the server.
- Part 6 : Checking if Server is member of domain.
- Part 7 : Joining Server to the domain.
- Part 8 : Magic of PowerShell PSRemoting..
- Part 9 : Installing Windows Features and Roles
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
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"
Our above command has run successfully, lets see if the folder is shared and accessible..
Yayy!!! it's done! Cool!
To know more about New-SmbShare visit this link : https://technet.microsoft.com/en-us/library/jj635722(v=wps.630).aspx
That's all for today, see you in next blog post.
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”.