PowerShell repository

Creating your own PowerShell repository is, fortunately, not that hard. In order to create a simple testing environment with an Active Directory domain, a public key infrastructure, a SQL server and a web server, we are using the AutomatedLab lab framework and a machine running Hyper-V. The framework can also use Azure or VMware. This environment more closely resembles an actual enterprise infrastructure.

For a local testing guide without any infrastructure, see: https://github.com/NuGet/NuGetGallery. The readme.md on the main page explains the basic steps.

While setting up the gallery this way requires the Windows operating system and the full .NET Framework, other NuGet Galleries might have different prerequisites.

In order to build a lab environment to test in, the following script can be used. It will require the Windows Server 2016 ISO as well as SQL Server 2017 as an ISO file:

$labName = 'NugetLab'

# Create a new lab definition - use your favorite hypervisor
New-LabDefinition -Name $labName -DefaultVirtualizationEngine HyperV

# Create a ADDS environment
Add-LabDomainDefinition -Name contoso.com -AdminUser Install -AdminPassword Somepass1
Set-LabInstallationCredential -User Install -Password Somepass1

# Routed lab environment with internet access
Add-LabVirtualNetworkDefinition -Name $labname -AddressSpace 192.168.22.0/24
Add-LabVirtualNetworkDefinition -Name External -HyperVProperties @{ SwitchType = 'External'; AdapterName = 'Ethernet' }

# Add the installation sources for SQL Server
Add-LabIsoImageDefinition -Name SQLServer2017 -Path $labsourcesISOsen_sql_server_2017_enterprise_x64_dvd_11293666.iso

$PSDefaultParameterValues = @{
'Add-LabMachineDefinition:DomainName' = 'contoso.com'
'Add-LabMachineDefinition:OperatingSystem' = 'Windows Server 2016 Datacenter (Desktop Experience)'
'Add-LabMachineDefinition:Memory' = 2GB
'Add-LabMachineDefinition:DnsServer1' = '192.168.22.10'
'Add-LabMachineDefinition:Gateway'= '192.168.22.99'
'Add-LabMachineDefinition:Network' = $labName
}

# Domain Controller and CA with included router
Add-LabMachineDefinition -Name NUGDC01 -Roles RootDC -IpAddress 192.168.22.10

$netAdapter = @()
$netAdapter += New-LabNetworkAdapterDefinition -VirtualSwitch $labName -Ipv4Address 192.168.22.99
$netAdapter += New-LabNetworkAdapterDefinition -VirtualSwitch External -UseDhcp
Add-LabMachineDefinition -Name NUGCA01 -Roles CARoot,Routing -NetworkAdapter $netAdapter

# Database and Web Server
Add-LabMachineDefinition -Name NUGDB01 -Roles SQLServer2017 -IpAddress 192.168.22.11
Add-LabMachineDefinition -Name NUGSV01 -Roles WebServer -IpAddress 192.168.22.12

# The actual lab installation takes around 35-50 minutes
Install-Lab
Enable-LabCertificateAutoenrollment -Computer -User

# Create a checkpoint before all modifications occur
Checkpoint-LabVm -All -SnapshotName LabDeployed
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset