Skip to content

Instantly share code, notes, and snippets.

Using namespace System.Windows.Forms
( $Form = [Form]@{
Text = 'Data Entry Form'
Size = '1200,800'
StartPosition = 'CenterScreen' }
).Controls.AddRange((
(
[Label]@{
Location = '10,20'
@TimCurwick
TimCurwick / Publish-MadUDDashboard
Created February 19, 2020 23:27
Publish-MadUDDashboard - Enhanced and tweaked version of Publish-UDDashboard
function Publish-SSAUDDashboard
{
<#
.SYNOPSIS
Publish Universal Dashboard dashboard as a service.
Enhanced version of UD module command Publish-UDDashboard
.PARAMETER DisplayName
Display name of the service.
Required
@TimCurwick
TimCurwick / Import-PSCmdlet.ps1
Created July 5, 2019 20:05
One-liner version of Chris Dent's Import-PSCmdlet
using namespace System.Management.Automation.Runspaces
using namespace System.Reflection
function Import-PSCmdlet
{
param (
[String]$Name,
[Type]$Type )
[PowerShell].Assembly.
$Session:Loading = $True
New-UDElement -Id Loading -Tag div -Endpoint {
If ( $Session:Loading )
{
New-UDCard -Content {
New-UDHeading -Text 'Loading data...'
New-UDPreloader -Size Small }
}
}
@TimCurwick
TimCurwick / Create a maze.ps1
Created November 7, 2018 16:47
Create a maze
# Maze size, zero-based, not including thickness of walls
$XSize = 40
$YSize = 10
# Random location of start and end doors on left and right borders
$Start = Get-Random ( $YSize + 1 )
$End = Get-Random ( $YSize + 1 )
# Create maze object, array of cells, X, Y, P
# X, Y - coordinates of cell
@TimCurwick
TimCurwick / CoolAF.ps1
Last active November 1, 2018 23:16
Function for creating useless classes that let's you do things like: 'Tim' -is [cool]'AF'
function New-UselessType
{
<#
.SYNOPSIS
Create a new class of a given name for doing stupid tricks
.DESCRIPTION
Creates a new class derived from System.Type that allows you to cast
anything as type [System.String]. (It does NOT cast to a string, but
rather to the Type that describes a string type.)
@TimCurwick
TimCurwick / Expandable variables in json sample.ps1
Last active October 30, 2018 21:11
Expandable variables in json sample
@'
{
"variables": [ "tenantName", "environmentType" ],
"type": "Vsts",
"name": "${tenantName}_$environmentType",
"description": "Variable Group for $tenantName"
}
'@ | Set-Content C:\temp\temp2.json
@TimCurwick
TimCurwick / End block blocking example
Created October 2, 2018 22:44
End block blocking example.ps1
function test
{
[cmdletbinding()]
Param (
[parameter( ValueFromPipeline = $True )]
$X )
begin
{
Write-Host "Begin test"
@TimCurwick
TimCurwick / ConcurrentDictionary for communication with thread
Last active August 23, 2018 21:04
ConcurrentDictionary for communication with thread
# Excerpt from The PowerShell Conference Book
# https://LeanPub.com/Powershell-Conference-Book
## ConcurrentDictionary for communication with thread
# Define concurrent variables
$SharedValues = [System.Collections.Concurrent.ConcurrentDictionary[string,psobject]]@{}
$SharedValues['Input'] = 2
# Define thread script
@TimCurwick
TimCurwick / Parsing PHP config file.ps1
Created August 7, 2018 15:57
Snippets for parsing PHP config file
<#
Givin PHP file as follows
<?php
/* CONFIG START. DO NOT CHANGE ANYTHING IN OR AFTER THIS LINE. */
// $Id: 83b45ef5b7d38e12be4e65351c4c6e504a931ecf $
$conf['user']['autocreate_special'] = false;
$conf['user']['allow_folders'] = true;
$conf['user']['allow_view_source'] = true;
$conf['server']['server_list'] = 'shown';