This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run each commented section individually | |
# Download new modules from the DSC Resource Kit | |
Install-Module xRemoteDesktopAdmin, xNetworking | |
# Generate a Configuration MOF file | |
Configuration RemoteDesktop | |
{ | |
Import-DscResource -ModuleName xRemoteDesktopAdmin, xNetworking | |
Node localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$AllModules = 'https://gallery.technet.microsoft.com/scriptcenter/DSC-Resource-Kit-All-c449312d/file/131371/1/DSC%20Resource%20Kit%20Wave%209%2012172014.zip' | |
$Folder = 'C:\AllModules' | |
$PullServerModules = 'C:\Program Files\WindowsPowerShell\DscService\Modules\' | |
if (!(Test-Path "$Folder\Archives")) {mkdir "$Folder\Archives" | out-null} | |
Invoke-WebRequest -Uri $AllModules -OutFile "$Folder\AllModules.zip" | |
Expand-Archive -Path "$Folder\AllModules.zip" -DestinationPath "$Folder\Extract" -Force | |
foreach ($ResourceFolder in (Get-ChildItem "$Folder\Extract\All Resources")) { | |
$ModuleData = Test-ModuleManifest "$($ResourceFolder.FullName)\$($ResourceFolder.Name).PSD1" | |
$File = "$($ModuleData.Name)_$($ModuleData.Version).zip" | |
Compress-Archive -Path $($ResourceFolder.FullName) -DestinationPath "$Folder\Archives\$File" -Force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use shortcode to find latest TechNet download site | |
$confirmationPage = 'http://www.microsoft.com/en-us/download/' + $((invoke-webrequest 'http://aka.ms/wmf5latest' -UseBasicParsing).links | ? Class -eq 'mscom-link download-button dl' | % href) | |
# Parse confirmation page and look for URL to file | |
$directURL = (invoke-webrequest $confirmationPage -UseBasicParsing).Links | ? Class -eq 'mscom-link' | ? href -match 'Win8.1AndW2K12R2-KB3134758-x64.msu' | % href | select -first 1 | |
# Download file to local | |
$download = invoke-webrequest $directURL -OutFile $env:Temp\wmf5latest.msu | |
# Install quietly with no reboot | |
if (test-path $env:Temp\wmf5latest.msu) { | |
start -wait $env:Temp\wmf5latest.msu -argumentlist '/quiet /norestart' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a very basic Configuration to deploy a pull server instance in a lab environment on Windows Server 2012. | |
Configuration PullServer { | |
Import-DscResource -ModuleName xPSDesiredStateConfiguration | |
# Load the Windows Server DSC Service feature | |
WindowsFeature DSCServiceFeature | |
{ | |
Ensure = 'Present' | |
Name = 'DSC-Service' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Command to register MyGet Repo | |
Register-PSRepository -Name GreeneNuGet -SourceLocation https://www.myget.org/F/greenenuget/api/v2/ -PublishLocation https://www.myget.org/F/greenenuget/api/v2/package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Connect { | |
param ( | |
[parameter (mandatory = $true)] | |
[system.string]$vm, | |
[parameter (mandatory = $true)] | |
[system.string]$service, | |
[parameter (mandatory = $true, valuefrompipeline = $true)] | |
[pscredential]$cred | |
) | |
$Services = Get-AzureService | % ServiceName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an advanced Configuration example for Pull Server production deployments on Windows Server 2012 R2. | |
# Many of the features demonstrated are optional and provided to demonstrate how to adapt the Configuration for multiple scenarios | |
# Select the needed resources based on the requirements for each environment. | |
# Optional scenarios include: | |
# * Reduce footprint to Server Core | |
# * Rename server and join domain | |
# * Switch from SSL to TLS for HTTPS | |
# * Automatically load certificate from Certificate Authority | |
# * Locate Modules and Configuration data on remote SMB share | |
# * Manage state of default websites in IIS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configuration CA | |
{ | |
param ( | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullorEmpty()] | |
[PsCredential] $credential | |
) | |
Import-DSCResource -module xAdcsDeployment | |
Node 'localhost' | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$modules = 'C:\Program Files\WindowsPowerShell\Modules\' | |
$modulename = 'xName' | |
$Description = 'Some Text' | |
if (!(test-path (join-path $modules $modulename))) { | |
$modulefolder = mkdir (join-path $modules $modulename) | |
New-ModuleManifest -Path (join-path $modulefolder "$modulename.psd1") -Guid $([system.guid]::newguid().guid) -Author 'Author' -CompanyName 'Company Name' -Copyright '2015' -ModuleVersion '0.1.0.0' -Description $Description -PowerShellVersion '4.0' | |
$standard = @{ModuleName = $modulename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Run { | |
param ( | |
[parameter (mandatory = $true, valuefrompipeline = $true)] | |
[system.string]$Runbook, | |
[system.string]$AutomationAccount | |
) | |
if (!(Get-Module Azure)) {ipmo 'C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1'} | |
if (!$AutomationAccount) {$AutomationAccount = Get-AzureAutomationAccount | % AutomationAccountName} | |
Start-AzureAutomationRunbook -Name $Runbook -AutomationAccountName $AutomationAccount | |
} |
OlderNewer