Skip to content

Instantly share code, notes, and snippets.

##############################################
############## Script Info ###################
##############################################
## Created By : Dan Cook 2017 ########
##############################################
<#
Version Info :
0.1 - 25/05/2017 - Creates a graphvis diagram and accompanying DOT code file
for an SCCM application dependency tree, by querying the
@ducke
ducke / PowerShellv4_DynamicKeyword.md
Created September 24, 2018 10:29 — forked from altrive/PowerShellv4_DynamicKeyword.md
Test code of PowerShell v4 Dynamic Keyword

Define DynamicKeyword

Define DynamicKeyword 'ExecTest'

Note: Don't copy&paste from following code. PowerShell SyntaxHighlighter remove some lines. Instead, use RAW view.

#Requires -Version 4.0
Set-StrictMode -Version Latest
@ducke
ducke / ConfigMgrTPArm.json
Created November 14, 2018 16:55
ARM Template ConfigMgr Technical Preview
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"newVMName": {
"type": "string",
"defaultValue": "ConfigMgrTP"
},
"labName": {
"type": "string",
@ducke
ducke / Invoke-SCCMRunScript.ps1
Created September 16, 2019 08:07 — forked from Robert-LTH/Invoke-SCCMRunScript.ps1
Simple script to use the new sccm feature called "Run Script". The builtin Invoke-CMScript does not accept parameters.
function Invoke-SCCMRunScript {
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$SiteServer,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$Namespace,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
@ducke
ducke / ScriptWithFunction.tests.ps1
Created January 29, 2020 12:14 — forked from LawrenceHwang/ScriptWithFunction.tests.ps1
ScriptWithFunction.tests.ps1
Describe 'Unit testing the helper functions in self contained script' {
BeforeAll {
# Using AST to parse the function definitions from the self contained script.
# Then, save the script of the Pester test drive.
$FilePath = Join-Path -Path '.' -ChildPath 'ScriptWithFunction.ps1'
$ast = [System.Management.Automation.Language.Parser]::ParseFile($FilePath, [ref]$null, [ref]$null)
$functionDefinition = $ast.FindAll( {
param([System.Management.Automation.Language.Ast] $AstInput)
$AstInput -is [System.Management.Automation.Language.FunctionDefinitionAst] -and
# Class methods have a FunctionDefinitionAst under them as well, but we don't want them.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ducke
ducke / Create-Local-AnsibleUser.ps1
Created May 26, 2023 07:19
Win Ansible Lab Setup
$username = "ansible"
$password = ConvertTo-SecureString "1234QWer" -AsPlainText -Force
try {
Get-LocalUser -Name $username -ErrorAction Stop
}
catch {
New-LocalUser -Name $username -Password $password -FullName $username -Description $username -PasswordNeverExpires
}