Skip to content

Instantly share code, notes, and snippets.

View mgreenegit's full-sized avatar

Michael Greene mgreenegit

  • Microsoft
View GitHub Profile
@mgreenegit
mgreenegit / greenenugetRepo.ps1
Last active August 29, 2015 14:17
Register MyGet Repo greenenuget
# 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
@mgreenegit
mgreenegit / Basic2012PullServerScript.ps1
Last active August 29, 2015 14:17
Very short script to initialize a Pull Server on WIndows Server 2012
# 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'
@mgreenegit
mgreenegit / WMF5Latest.ps1
Last active May 23, 2018 19:25
Get latest WMF5 and quietly install, reboot suppressed
# 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'
}
@mgreenegit
mgreenegit / HydrateAllPublicResKitodulesOnPOCPullServer.ps1
Last active August 29, 2015 14:15
This is a quick script for POC labs, to grab the DSC Resource Kit (All Modules) file and populate them in to a DSC Pull Server
$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
@mgreenegit
mgreenegit / RemoteDesktop.ps1
Last active February 19, 2016 23:35
Simple Remote Desktop DSC Config
# 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