HTTP Pull Server Setup:
----
- Windows 2012 R2 VM
- IIS
- xPSDesiredStateConfiguration
- Windows 10 client machine
Copy DSCPullServer.ps1,New-PullServer.ps1 in the same folder and run New-PullServer.ps1
#DSCPullServer.ps1 param ( [Parameter(Mandatory=$false)] [String] $NodeName = 'localhost', [Parameter(Mandatory)] [String] $Key ) Configuration PullServerConfiguration { Import-DSCResource -ModuleName xPSDesiredStateConfiguration Node $NodeName { LocalConfigurationManager { ConfigurationMode = 'ApplyAndAutoCorrect' RefreshMode = 'Push' RebootNodeifNeeded = $true } WindowsFeature DSCServiceFeature { Ensure = 'Present'; Name = 'DSC-Service' } xDscWebService PullServer { Ensure = 'Present'; EndpointName = 'PullServer'; Port = 80; PhysicalPath = "$env:SystemDrive\inetpub\PullServer"; CertificateThumbPrint = 'AllowUnencryptedTraffic'; ModulePath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Modules"; ConfigurationPath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Configuration"; State = 'Started' DependsOn = '[WindowsFeature]DSCServiceFeature' UseSecurityBestPractices = $false } File RegistrationKeyFile { Ensure = 'Present' Type = 'File' DestinationPath = "$env:ProgramFiles\WindowsPowerShell\DscService\RegistrationKeys.txt" Contents = $Key } } } PullServerConfiguration
#New-PullServer.ps1 #-------------- $ErrorActionPreference = 'Stop' if((Get-ExecutionPolicy) -eq 'Restricted') { throw 'Execution policy should be set atleast to RemoteSigned..' } if(-not(Test-WSMan -ErrorAction SilentlyContinue)) { set-WSManQuickConfig -Force } if(-not(Get-Module -Name PackageManagement -ListAvailable)) { throw 'PackageManagement module should be installed to proceed' } if(-not(Get-Module -Name xPSDesiredStateConfiguration -ListAvailable)) { Install-Module -Name xPSDesiredStateConfiguration -Confirm:$false -Verbose } #Use [Guid]::NewGuid() | select -ExpandProperty Guid to generate a new key and paste the key here $registrationKey = 'c944ce11-0ffe-467b-bb22-fd1cd2fd76k7' .\DSCPullServer.ps1 -NodeName 'localhost' -Key $registrationKey Set-DscLocalConfigurationManager -Path .\PullServerConfiguration -Verbose Start-DscConfiguration .\PullServerConfiguration -Verbose -Force
Get-DscLocalConfigurationManager -->configs applied on a machine
And in the ISS, there is a PullServer website created.
Open port 80 on the VM with the firewall to access the IIS website hosted.
No comments:
Post a Comment