Skip to content

Instantly share code, notes, and snippets.

View jeffpatton1971's full-sized avatar
😄
Writing code 25 hours a day, 8 days a week!

Jeff Patton jeffpatton1971

😄
Writing code 25 hours a day, 8 days a week!
View GitHub Profile
@jeffpatton1971
jeffpatton1971 / BasicWebServer.ps1
Last active January 1, 2016 18:29
Desired State Configuration for a basic web server
Configuration BasicWebServer
{
param
(
[string]$ComputerName
)
Node $ComputerName
{
WindowsFeature WebServerRole
@jeffpatton1971
jeffpatton1971 / SetupDSCClient.ps1
Last active January 1, 2016 18:59
A simple DSC Client Setup Configuration
Configuration SetupDSCClient
{
param
(
[string]$NodeId,
[string]$PullServer
)
LocalConfigurationManager
{
@jeffpatton1971
jeffpatton1971 / AddDSCService.ps1
Created December 30, 2013 20:38
This adds the DCS-Service as a configuration
Configuration DSCPullServer
{
param
(
[string]$ComputerName
)
Node $ComputerName
{
WindowsFeature DSCService
$SourcePath = "$($pshome)\modules\psdesiredstateconfiguration\pullserver"
$DestinationPath = "C:\inetpub\wwwroot\PSDSCPullServer"
$AppPool = "DSCAppPool"
New-Item C:\inetpub\wwwroot\PSDSCPullServer\bin -ItemType directory -Force
Copy-Item "$($SourcePath)\psdscpullserver.*" $DestinationPath
Copy-Item "$($SourcePath)\Global.asax" $DestinationPath
Copy-Item "$($SourcePath)\Microsoft.Powershell.DesiredStateConfiguration.Service.dll" "$($DestinationPath)\bin"
Rename-Item "$($DestinationPath)\psdscpullserver.config" "$($DestinationPath)\web.config"
Copy-Item "$($SourcePath)\Devices.mdb" "$($env:programfiles)\WindowsPowerShell\DscService"
@jeffpatton1971
jeffpatton1971 / WebServer.ps1
Last active April 16, 2019 17:47
This DSC Configuration shows off several features available via DSC. It installs the Web-Server feature, and several additional web features that each depend on Web-Server being installed. It uses the Package reference to install the WebDeploy MSI, based on that path passed in the param, which also depends on Web-Server. It uses a Script referen…
Configuration BasicWebServer
{
param
(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$ComputerName,
[string]$Source = $null,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
@jeffpatton1971
jeffpatton1971 / Defaults2012R2.ps1
Created December 31, 2013 17:47
Windows Server 2012 R2 Default installed features
Configuration Defaults2012R2
{
param
(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$ComputerName
)
Node $ComputerName
{
@jeffpatton1971
jeffpatton1971 / New-DscFile.ps1
Last active October 12, 2016 14:43
Detect installed and not installed features to output a DSC file
<#
.SYNOPSIS
Detect installed and not installed features to output a DSC file
.DESCRIPTION
This script will return a list of features that are installed and not installed
for the server you run it on. This can be viewed as a basic starting point in
getting DSC up and running for a given server. Once you have this information
you can use it to simply make sure this server always has these settings, or
add to it with more DSC Resources.
.EXAMPLE
@jeffpatton1971
jeffpatton1971 / New-RulesFromNetstat.ps1
Created January 15, 2014 17:11
A script to create firewall rules based on netstat output
<#
Create FW rules for TCP and UDP Listening Ports
netstat -an -p tcp |Select-String "Listening"
netstat -an -p udp |Select-String "Listening"
for each entry in netstat create firewall rule
name = -p tcp|udp port port #
description = automatic allow rule generated by powershell on get-date
@jeffpatton1971
jeffpatton1971 / json.cs
Created February 5, 2014 13:39
Edmunds json code
public static T GetEdmundsContent<T>(string url) where T : new()
{
using (var client = new WebClient())
{
var jsonData = string.Empty;
try
{
Sleep(1000);
jsonData = client.DownloadString(url);
}
@jeffpatton1971
jeffpatton1971 / Copy-OuDelegation.ps1
Created March 25, 2014 19:19
Copy security between Ou's
<#
.SYNOPSIS
Template script
.DESCRIPTION
This script sets up the basic framework that I use for all my scripts.
.PARAMETER
.EXAMPLE
.NOTES
ScriptName : Copy-Delegations.ps1
Created By : jspatton