Skip to content

Instantly share code, notes, and snippets.

View jamesallen-cm's full-sized avatar

jamesallen-cm

View GitHub Profile
# Get a list of trusted hosts
Get-Item WSMan:\localhost\Client\TrustedHosts
# Note that these commands don't create a list of trusted hosts, it simply replaces the trusted host with what you set via the command. If you need to add multiple hosts, they need to be comma seperated
# Trust all computers in a domain
Set-Item WSMan:\localhost\Client\TrustedHosts *.contoso.com
# Turst a single machine
Set-Item WSMan:\localhost\Client\TrustedHosts -Value myserver
@jamesallen-cm
jamesallen-cm / CreateSelfSignedCert.ps1
Created June 7, 2015 17:08
Create a Self Signed Certificate
# Goto the OpenSSL bin directory
pushd $env:ProgramFiles\OpenSSL\bin
# Create a self-signed SSL certificate. Be sure to update your paths if required.
openssl req -newkey rsa:4096 -nodes -sha256 -keyout C:\temp\myAwesomeServer.key -x509 -days 365 -out C:\temp\myAwesomeServer.crt -config $env:ProgramFiles\OpenSSL\bin\openssl.cfg
@jamesallen-cm
jamesallen-cm / DSCNodeBootstrap.txt
Last active August 29, 2015 14:23
Run this on a Pull Client to install WMF 5.0
$Boxstarter.RebootOk=$true
# enable psremoting
Write-Output "Enabling PSRemoting"
Enable-PSRemoting -Force
if($PSVersionTable.PSVersion -lt (New-Object 'Version' 5,0,10105,0))
{
# install WMF5.0 February and April
cinst powershell -version 5.0.10018-February2015Preview -pre -y
# Write-Output "Installing the April 2015 Powershell DSC preview"
@jamesallen-cm
jamesallen-cm / HTTPDSCServerBootstrap
Last active August 29, 2015 14:23
Run this on your DSC server to setup and config a http server. It will install WMF 5.0, download the latest DSC packages, zip them up, and create the checksums.
$Boxstarter.RebootOk=$true
# enable psremoting
Write-Output "Enabling PSRemoting"
Enable-PSRemoting -Force
if($PSVersionTable.PSVersion -lt (New-Object 'Version' 5,0,10018,0))
{
# install WMF5.0 February and April
cinst powershell -version 5.0.10018-February2015Preview -pre -y
# Write-Output "Installing the April 2015 Powershell DSC preview"
@jamesallen-cm
jamesallen-cm / DSCBoxstarter
Last active August 17, 2016 18:53
DSC Boxstarter Links
Open a Powershell prompt and paste one of the following commands.
SERVER:
START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/jamesallen-cm/2d08e881944da3cbcca6/raw/99c57af98e8966ff9b04dde7ba68fefd9681e647/DSCPullServerBootstrap-February
NODE:
START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/jamesallen-cm/627f076abeea333f520b/raw/63e15135a68129d3216910400b236b2cdc0b29e0/DSCNodeBootstrap-February
@jamesallen-cm
jamesallen-cm / DSC_LCM_HTTPConfig
Created June 17, 2015 14:00
This is the DSC Config file used to configure a server as a DSC Pull Client
[DSCLocalConfigurationManager()]
Configuration LCM_HTTPPULL
{
param
(
[Parameter(Mandatory=$true)]
[string[]]$ComputerName,
[Parameter(Mandatory=$true)]
[string]$ServerURL,
@jamesallen-cm
jamesallen-cm / DSC_HTTPPullServer
Created June 17, 2015 14:01
This is the DSC Config file used to configure a server as a DSC http Pull Server
configuration HTTPPullServer
{
param
(
[Parameter(Mandatory=$true)]
[string[]]$ComputerName
)
# Modules must exist on target pull server
@jamesallen-cm
jamesallen-cm / DSC_ServerSetup
Last active August 29, 2015 14:23
Applies the HTTPPullServer Configuration to a server
# Be sure to change the computer name to your server
$node = "WIN-C6U0AQ5K17N"
$cred = Get-Credential administrator
# Deploy HTTP Pull Server
Start-DscConfiguration -Force -Path C:\DSC\HTTP -Credential $cred -ComputerName $node -Verbose -Wait
# Test the pull server
Start-Process -FilePath iexplore.exe "http://$($node):8080/PSDSCPullServer.svc"
@jamesallen-cm
jamesallen-cm / DSC_ConfigureLCMNode
Last active August 29, 2015 14:23
Applies the LCMNode Configuration and walks through mof creation using guid identifiers
# Computer list - Be sure to change the computer name to your server
$ComputerName='WIN-UO9GH1EJ9J7'
$cred = Get-Credential "$ComputerName\administrator"
$cimsession = New-CimSession -Credential $cred -ComputerName $ComputerName
# Send to computers LCM
Set-DSCLocalConfigurationManager -ComputerName $ComputerName -Credential $cred -Path c:\DSC\HTTP –Verbose
Get-DSCLocalConfigurationManager -CimSession $cimsession
@jamesallen-cm
jamesallen-cm / DSC_SMTPConfig
Last active August 29, 2015 14:23
Creates a config for SMTP. This will be applied to all computers that have the associated application guid
configuration SMTP {
Import-DscResource -ModuleName @{ModuleName="PSDesiredStateConfiguration";ModuleVersion="1.1"}
Node HTTPComputers {
WindowsFeature SMTP{
Name = 'SMTP-Server'
Ensure = 'Present'
}
}
}