Skip to content

Instantly share code, notes, and snippets.

# Define proxy settings per machine and configure it to access directly Internet
Configuration NoProxy {
Registry ProxyPerMachinePolicy
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings'
ValueName = 'ProxySettingsPerUser'
Ensure = 'Present'
ValueData = '0'
ValueType = 'Dword'
Force = $true
# Define proxy settings per machine and let autodetect enabled (~default user config per machine)
Configuration AutodetectProxy {
Registry ProxyPerMachinePolicy
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings'
ValueName = 'ProxySettingsPerUser'
Ensure = 'Present'
ValueData = '0'
ValueType = 'Dword'
Force = $true
# Define a proxy URL for a configuration script
Configuration ProxyURL {
Registry ProxyPerMachinePolicy
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings'
ValueName = 'ProxySettingsPerUser'
Ensure = 'Present'
ValueData = '0'
ValueType = 'Dword'
Force = $true
$MetaData = New-Object System.Management.Automation.CommandMetaData (Get-Command Get-Culture -CommandType Cmdlet)
$functionContent = ([System.Management.Automation.ProxyCommand]::Create($MetaData))
$newcode = @'
if ($PSBoundParameters['All']) {
$scriptCmd = { & { [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]::AllCultures) }}
} else {
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Get-Culture', [System.Management.Automation.CommandTypes]::Cmdlet)
$scriptCmd = {& $wrappedCmd @PSBoundParameters }
}
#Requires -Version 4.0
#Requires -RunAsAdministrator
Configuration DeployEMET52 {
Param
(
[string[]]$NodeName = 'localhost'
)
Node $NodeName
{
#Requires -Version 3
Function Get-PSH2013Learder {
<#
.SYNOPSIS
Get the Scripting Games 2013 leaderboard of a given category
.DESCRIPTION
Just for fun.
.PARAMETER Category
#Requires -Version 3.0
Function Get-LatestWMF5 {
[CmdletBinding()]
Param(
[parameter(Mandatory)]
[system.string]$TargetFolder
)
Begin {
$HT = @{
#Requires -Version 3.0
#Requires -Module DnsClient,ActiveDirectory
<#
.SYNOPSIS
Practice Event of Powershell Winter Scripting 2014
.DESCRIPTION
Practice Event of Powershell Winter Scripting 2014
if (-not(Get-VMSwitch -SwitchType Internal -ErrorAction SilentlyContinue| Where Name -eq 'Internal-Test' )) {
# Create an internal switch on Hyper-V
($VMswitch = New-VMSwitch -Name "Internal-Test" -SwitchType Internal)
# Set a static IP address on Hyper-V switch
Get-NetAdapter |
Where Name -eq "vEthernet ($($VMswitch.Name))" |
Where InterfaceDescription -match "Hyper-V\sVirtual\sEthernet Adapter" |
New-NetIPAddress -IPAddress 10.0.0.1 -PrefixLength 24
#Requires -Version 4.0
#Requires -RunAsAdministrator
configuration RemoveEMET52 {
param
(
[string[]]$NodeName = 'localhost'
)
Node $NodeName
{