Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Windows Server 2016 Automation with PowerShell Cookbook

You're reading from   Windows Server 2016 Automation with PowerShell Cookbook Powerful ways to automate and manage Windows administrative tasks

Arrow left icon
Product type Paperback
Published in Sep 2017
Publisher
ISBN-13 9781787122048
Length 660 pages
Edition 2nd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Thomas Lee Thomas Lee
Author Profile Icon Thomas Lee
Thomas Lee
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. What's New in PowerShell and Windows Server 2. Implementing Nano Server FREE CHAPTER 3. Managing Windows Updates 4. Managing Printers 5. Managing Server Backup 6. Managing Performance 7. Troubleshooting Windows Server 2016 8. Managing Windows Networking Services 9. Managing Network Shares 10. Managing Internet Information Server 11. Managing Hyper-V 12. Managing Azure 13. Using Desired State Configuration

Creating an internal PowerShell repository

It is useful to create your own PowerShell repository for personal or corporate use. The tools to enable you to build your own repository are not included in PowerShell. There are three main approaches available that enable you to build a repository:

  • Using Visual Studio's NuGet package manager to download and install the Nuget.Server package into a new web project, and deploy to your own IIS Server. This option is free. However, you need to use Visual Studio 2015 (Either the full version or the free community edition) to create your own web project, download the Nuget server software, and deploy it into your environment. More information is available at https://www.nuget.org/packages/NuGet.Server.
  • Using a third-party NuGet host's SAAS platform. This is the simplest solution, but software licensing fees may apply, and some organizations might have reservations about keeping the code on external servers. Choices for this approach include Visual Studio Team Services, http://myget.org/, and ProGet.
  • Installing a 3rd-party NuGet software repository on your server. This simplifies the setup process for hosting your own software repository, but software licensing fees may apply.
More information is available on hosting from the NuGet site at https://docs.nuget.org/ndocs/hosting-packages/overview.

The simplest approach to setting up your own software repository is to install and configure the free or trial version of ProGet. Do so via a GUI installation—the steps are described at https://inedo.com/support/documentation/proget/installation/installation-guide.

You have the choice of using an existing SQL Server instance or installing SQL Express as part of the installation. SQL is used to hold the repository's data. You may also choose to install your repository to an existing IIS Server or install ProGet with its own internal web server.

Inedo also provides a PowerShell script to perform the installation, which you may customize. For the script based installation, you need to register for a free license key at https://my.inedo.com.

You can find more information on using ProGet from the Inedo web site at
https://inedo.com/support/kb/1088/using-powershell-to-install-and-configure-proget.

How to do it...

  1. Once you have installed ProGet using either the GUI or PowerShell script approach, log in to the ProGet application home page using the default admin account until you create a username and password:
  1. From Feeds page, click Create New Feed:
  1. A list of supported feed types is displayed. Choose PowerShell:
  1. Enter a feed name of your choice: (for example, MyPowerShellPackages) and click the Create New PowerShell Feed button:
  1. Review the properties of your new feed:
  1. Open the PowerShell ISE or console, and register your new repository:
      $RepositoryURL = `
"http://localhost:81/nuget/MyPowerShellPackages/"
Register-PSRepository -Name MyPowerShellPackages `
-SourceLocation $RepositoryURL`
-PublishLocation $RepositoryURL `
-InstallationPolicy Trusted
  1. Publish a module you already have installed (Pester, for example):
      Publish-Module -Name Pester -Repository MyPowerShellPackages `
-NuGetApiKey "Admin:Admin"
  1. Download a module from PSGallery, save it to the C:\Foo folder, and publish to your new repository (for example, Carbon):
      Find-Module -Name Carbon -Repository PSGallery 
New-Item -ItemType Directory -Path 'C:\Foo'
Save-Module -Name Carbon -Path C:\foo
Publish-Module -Path C:\Foo\Carbon `
-Repository MyPowerShellPackages `
-NuGetApiKey "Admin:Admin"
  1. Find all the modules available in your newly created and updated repository:
      Find-Module -Repository MyPowerShellPackages

How it works...

There are various options for setting up a NuGet-based repository for PowerShell. ProGet is a universal package manager from Inedo (See https://inedo.com/proget for more information on ProGet). ProGet is a very simple choice as it is easy to get started and offers the ability to scale to enterprize level. ProGet has both a free and a paid subscription version available. The ProGet installer creates a NuGet web server backed by a SQL Express database.

In step 1, you visit the server web administration page and optionally review the functionality available.

In steps 2-5, you use ProGet to create a new repository for your PowerShell modules. As you see, you use the ProGet GUI to create this new repository.

In step 6, you register your new repository in your PowerShell session. You need to know the repository URL and have a NuGet API key, using the default username/password of Admin /Admin.

In step 7, you publish a module to the repository—you are using a module that is installed in your PowerShell session, Pester.

In step 8, you locate and download an additional module from the PSGallery, and publish this module to your local repository.

In step 9, you see the modules available from your local repository:

There's more...

ProGet is a rich product. It provides both automatic failover and scalability which are needed features for PowerShell repositories in large organization's repository. ProGet is one option you have for creating your own organization specific repository. To learn more about ProGet, visit http://inedo.com/support/documentation/proget.

NuGet is a free, open source package management system provided by the Microsoft ASP.NET development platform and is provided as a Visual Studio extension. To learn more about NuGet, visit https://docs.nuget.org/ndocs/api/nuget-api-v3.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image