Skip to content

Instantly share code, notes, and snippets.

View FriedrichWeinmann's full-sized avatar

Friedrich Weinmann FriedrichWeinmann

View GitHub Profile
@FriedrichWeinmann
FriedrichWeinmann / FredsIronScripter2018.psproj.xml
Created January 28, 2018 12:01
C# Project configuration - do not append target framework to path
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>..\..\..\FredsIronScripter2018\bin</OutputPath>
<DocumentationFile>..\..\..\FredsIronScripter2018\bin\FredsIronScripter2018.xml</DocumentationFile>
@FriedrichWeinmann
FriedrichWeinmann / DiskInfo.cs
Created January 28, 2018 12:05
Iron Scripter 2018 Prequel 2 classes
using System;
namespace Fred.IronScripter2018
{
/// <summary>
/// Class containing information on a disk
/// </summary>
[Serializable]
public class DiskInfo
{
@FriedrichWeinmann
FriedrichWeinmann / Get-FISSystemInformation.ps1
Created January 28, 2018 12:08
Iron Scripter 2018 - Get-FISSystemInformation
function Get-FISSystemInformation
{
<#
.SYNOPSIS
Gathers information on the target's system.
.DESCRIPTION
This function uses CIM to gather information about the target computer(s)'s system.
.PARAMETER ComputerName
@FriedrichWeinmann
FriedrichWeinmann / FredsIronScripter2018.types.ps1xml
Created January 28, 2018 12:25
Type extension for serialization
<?xml version="1.0" encoding="utf-8"?>
<Types>
<!-- Fred.IronScripter2018.DiskInfo -->
<Type>
<Name>Deserialized.Fred.IronScripter2018.DiskInfo</Name>
<Members>
<MemberSet>
<Name>PSStandardMembers</Name>
<Members>
<NoteProperty>
Write-Host "Didn't really expect me to do a thing, did you?"
# Dummy script file for a tutorial
@FriedrichWeinmann
FriedrichWeinmann / badFunction.ps1
Created November 26, 2018 07:46
As bad as it gets
#----------------------------------------------------------------------------#
# Parameters #
#----------------------------------------------------------------------------#
# Path to a file with server names
$servers = 'DC', 'AdminHost'
# Whether errors should be ignored
$ignoreErrors = $true
$scriptBlock = {
Connect-Lab
$id = "<id>"
$labname = "wsFund$($id)"
$domainName = "lab$($id).contoso.com"
$labSources = 'C:\LabSources'
$image = 'Windows Server 2016 Datacenter Evaluation (Desktop Experience)'
New-LabDefinition -Name $labname -DefaultVirtualizationEngine HyperV
function Get-ShellBuffer
{
[CmdletBinding()]
param ()
try
{
# Define limits
$rec = New-Object System.Management.Automation.Host.Rectangle
$rec.Left = 0
@FriedrichWeinmann
FriedrichWeinmann / poc-moduleScopeHierarchy.ps1
Last active May 30, 2019 20:31
Demonstrates the scope pyramid for functions in Modules
New-Module -Name Test -ScriptBlock {
function Get-Test1
{
[CmdletBinding()]
param ()
$var = 24
$depth = 0
try
{
@FriedrichWeinmann
FriedrichWeinmann / Out-Default.ps1
Last active June 11, 2019 04:30
Adds caching to Out-Default
function Out-Default
{
<#
.SYNOPSIS
A wrapper for Out-Default, adding automatic caching to all output sent to screen.
.DESCRIPTION
A wrapper for Out-Default, adding automatic caching to all output sent to screen.
Maximum capacity can be configured by setting $global:OutputCacheSize