Book Image

Windows Server 2016 Automation with PowerShell Cookbook - Second Edition

By : Thomas Lee, Ed Goad
Book Image

Windows Server 2016 Automation with PowerShell Cookbook - Second Edition

By: Thomas Lee, Ed Goad

Overview of this book

This book showcases several ways that Windows administrators can use to automate and streamline their job. You'll start with the PowerShell and Windows Server fundamentals, where you'll become well versed with PowerShell and Windows Server features. In the next module, Core Windows Server 2016, you'll implement Nano Server, manage Windows updates, and implement troubleshooting and server inventories. You'll then move on to the Networking module, where you'll manage Windows network services and network shares. The last module covers Azure and DSC, where you will use Azure on PowerShell and DSC to easily maintain Windows servers.
Table of Contents (21 chapters)
Title Page
Credits
About the Author
Acknowledgment
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Creating and securing SMB shares


For generations, administrators have used the net.exe command to set up shared folders and a lot more. These continue to work but you may find the new cmdlets easier to use, particularly if you are automating large-scale SMB server deployments.

This recipe looks at creating and securing shares on a Server 2016 platform using the PowerShell SMBServer module.

Getting ready

For this recipe, you use the file server (FS1) that you hardened in the recipe Securing your SMB server. On this server, you share out folders on the file server. Later, in the recipe Accessing SMB shares, you access the shared folders. Ensure you have created the C:\Foo folder on FS1. This recipe uses a security group, IT Management which you create in the Reskit.Org AD (or use a different group).

How to do it...

  1. Discover the existing shares and access rights:
Get-SmbShare -Name * |      Get-SmbShareAccess |
            Sort-Object -Property Name |           Format-Table -GroupBy Name
  1. Share a folder...