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 : https://technet.microsoft.com/en-us/library/jj635722(v=wps.630).aspx 

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

Aman Dhally - Manya Kaur

Regards.
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”.

Friday, June 26, 2015

Managing Windows Server 2012 R2 Using PowerShell : Part-9 : Installing Windows Features.

 

  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..

6-24-2015 12-42-00 PM

Part - 9 : Installing Windows Features.

In the previous post we see the magic of Windows PowerShell PSRemoting. We have learned how to use it.

In this blog post, we are going to add a new windows feature by doing a PSRemoting to our remote server, or you can say that, by sitting on our own laptop, listening to the music, and we are going to configure our server remotely.

Cool ! No?

To  see the list of all available feature and roles available , which  we can deploy on our server we uses the Get-WindowsFeature cmdlet.

In the below screenshot, you can see, that I have PSRemoted to our Windows 2012 R2 Server. When we run the Get-WindowsFeature cmdlet, it has returned the list of all windows features.

1

So, how do you know, which feature is install or not?

We can check it by :

  • If the feature is already installed, then it's "Install State" is Installed, otherwise it's "Install State" is Available.
  • You can see a cross [X] in the front of installed features. and empty [  ] in the front of the feature/role which is available to install but not installed yet.

Picture1

If you want to know about any specific feature thatif it is installed or not, then user Get-WindowsFeature  and then provide the name of the feature in -Name parameter.

For example ,after run the below command you can see  that 'Management Tools' are not installed on this server.

Get-WindowsFeature -Name 'Web-Mgmt-Tools'

6

To install any feature or role, we use the Install-WindowsFeature cmdlet.

The usage of cmdlet is very simple. Type cmdlet and then provide the name of feature to install.

Let's try installing XPS Viewer. The below command is very simple and not need to

 

Install-WindowsFeature XPS-Viewer

3

In the below screenshot, we can see, that our feature install successfully.

5

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

Aman Dhally, Manya Kaur

Regards.
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”.