Skip to content

Instantly share code, notes, and snippets.

View Dan1el42's full-sized avatar

Daniel Krebs Dan1el42

View GitHub Profile
@Dan1el42
Dan1el42 / Invoke-DscPullAndApplyOnNode.ps1
Last active April 3, 2017 10:55
Trigger node to get latest configuration from pull server and apply immediately. #PowerShell #DSC
Param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String[]]$ComputerName
)
# Gets latest configuration from pull server and apply immediately
$InvokeMethodSplat = @{
ComputerName = $ComputerName
@Dan1el42
Dan1el42 / Set-DNSSuffixSearchOrder.ps1
Last active August 29, 2015 14:01
Set the DNS suffix search list via CIM (remote or local) without group policy. Most relevant for Win2008 R2 and earlier. Win2012 and later comes with cmdlets.
$WsmanSession = New-CimSession -ComputerName 'Win2008R2Server', 'Win2012Server', 'Win2012R2Server'
$DcomSession = New-CimSession -ComputerName 'WinXP', 'Win2003Server' -SessionOption (New-CimSessionOption -Protocol Dcom)
$InvokeSplat = @{
CimSession = $WsmanSession, $DcomSession
ClassName = 'Win32_NetworkAdapterConfiguration'
MethodName = 'SetDNSSuffixSearchOrder'
Arguments = @{DNSDomainSuffixSearchOrder=@('contoso.lab','viamonstra.lab')}
}
Invoke-CimMethod @InvokeSplat
@Dan1el42
Dan1el42 / DesiredStateConfiguration-SCCMDistributionPoint.ps1
Last active December 31, 2016 18:27
Prepare Windows Server 2012 machine via #PowerShell #DSC to host System Center Configuration Manager 2012 (SCCM) distribution point
Configuration SCCMDistributionPoint
{
# Create NO_SMS_ON_DRIVE.SMS file on C:\ drive
File NoSmsOnDrive
{
DestinationPath = "C:\NO_SMS_ON_DRIVE.SMS"
Contents = [System.String]::Empty
Type = "File"
Ensure = "Present"
}
@Dan1el42
Dan1el42 / VMware links
Last active August 29, 2015 14:01
Collection of links to VMware components
Script WindowsDeploymentServicesInitializeServer
{
TestScript = {
$WdsServer = (New-Object -ComObject WdsMgmt.WdsManager).GetWdsServer("localhost")
return ($WdsServer.SetupManager.InitialSetupComplete)
}
SetScript = {
Start-Process -Wait -FilePath "C:\Windows\System32\wdsutil.exe" -ArgumentList "/Initialize-Server", "/REMINST:D:\Deployment"
}
@Dan1el42
Dan1el42 / Get-HelpFromScript.ps1
Last active August 29, 2015 14:03
Extract help from script. Posted by Michael West on Google+.
$text = @"
<#
.SYNOPSIS
Sample comment
.DESCRIPTION
Other comment
#>
"@
Param
(
[String]$SerialNumber = 'HU265BM18V',
[String]$ProductNumber = 'H1P31AA'
)
$fields = @(
'tmp_weCountry=us',
"tmp_weSerial=$SerialNumber",
"tmp_weProduct=$ProductNumber",
@Dan1el42
Dan1el42 / Convert-MacAddressFunction.ps1
Last active August 29, 2015 14:07
Convert-MacAddress advanced function
function Convert-MacAddress
{
<#
.SYNOPSIS
Converts a MAC address from any valid format to another.
.DESCRIPTION
The Convert-MacAddress function takes any valid MAC address and converts it to another valid format.
Valid formats are:
- Six groups of two hex digits separated by hyphens (-), like 01-23-45-ab-cd-ef
@Dan1el42
Dan1el42 / Import-DataFile.ps1
Created October 14, 2014 12:42
Import-DataFile
function Import-DataFile
{
<#
Posted by Dave Wyatt at http://powershell.org/wp/forums/topic/how-to-store-hashtable-in-configuration-file/
#>
param (
[Parameter(Mandatory)]
[string] $Path
)
@Dan1el42
Dan1el42 / Copy-ActiveSMSEncryptionCertificate.ps1
Last active August 29, 2015 14:07
Copy the active SMS encryption certificate to the My store to enable access to the private key for the DSC Local Configuration Manager to decrypt credentials
<#
.SYNOPSIS
Copy the active SMS encryption certificate to the My store
.DESCRIPTION
Copy the active SMS encryption certificate to the My store to enable access to the private key for the DSC Local Configuration Manager to decrypt credentials
#>
Param
(
[String] $SMSCertificateFriendlyName = 'SMS Encryption Certificate'
)