Skip to content

Instantly share code, notes, and snippets.

View indented-automation's full-sized avatar

Chris Dent indented-automation

View GitHub Profile
function New-ConsoleMenu {
param (
[ScriptBlock]$ScriptBlock,
[String]$Title,
[String]$Prompt,
[Object]$Default,
@indented-automation
indented-automation / Import-PSCmdlet.ps1
Created August 25, 2017 13:23
Cmdlets without a DLL
using namespace System.Management.Automation.Runspaces
using namespace System.Reflection
function Import-PSCmdlet {
param (
[String]$Name,
[Type]$Type
)
@indented-automation
indented-automation / Compress-Item.ps1
Last active October 4, 2021 18:19
PowerShell: .NET 4.0 zip file handling
function Compress-Item {
<#
.SYNOPSIS
Compress a file or directory.
.DESCRIPTION
Create a zip file from a collection of files.
.INPUTS
System.IO.FileInfo
.EXAMPLE
Compress-Item .SomeFile.txt
@indented-automation
indented-automation / New-DynamicParameter.ps1
Last active August 11, 2023 22:46
New-DynamicParameter
function New-DynamicParameter {
<#
.SYNOPSIS
Create a new dynamic parameter object for use with a dynamicparam block.
.DESCRIPTION
New-DynamicParameter allows simplified creation of runtime (dynamic) parameters.
.EXAMPLE
New-DynamicParameter Name -DefaultValue "Test" -ParameterType "String" -Mandatory -ValidateSet "Test", "Live"
.EXAMPLE
New-DynamicParameter Name -ValueFromPipelineByPropertyName
@indented-automation
indented-automation / Find-String.ps1
Last active October 4, 2021 18:18
Binary searcher
function Find-String {
<#
.SYNOPSIS
Find a matching string from an alphabetically sorted file.
.DESCRIPTION
Find-String is a specialised binary (half interval) searcher designed to find matches in sorted ASCII encoded text files.
.NOTES
Change log:
11/08/2014 - Chris Dent - First release.
#>
@indented-automation
indented-automation / Get-InstalledSoftware.ps1
Last active August 11, 2023 22:35
Get-InstalledSoftware
function Get-InstalledSoftware {
<#
.SYNOPSIS
Get all installed from the Uninstall keys in the registry.
.DESCRIPTION
Read a list of installed software from each Uninstall key.
This function provides an alternative to using Win32_Product.
.EXAMPLE
Get-InstalledSoftware
@indented-automation
indented-automation / ActiveDirectory.md
Last active February 7, 2024 16:59
Active Directory

A small collection specialised scripts for Active Directory.

Includes:

  • Compare-ADMemberOf
  • Get-ADSystemInfo
  • Get-GroupMemberTree
  • Get-LdapObject
  • Get-MemberOfTree
  • Test-LdapSslConnection
Option Explicit
' ContactImport.vbs
'
' Contact Import / Maintenance Script
'
' Subroutines
'
<#
Module file content:
CmdLet Name Category Access modifier Updated
----------- -------- --------------- -------
Set-SessionKey Passphrase management Public 02/10/2012
Get-Key Keyring management Public 02/10/2012
Import-Key Keyring management Public 02/10/2012
Export-Key Keyring management Public 02/10/2012
Remove-Key Keyring management Public 02/10/2012
@indented-automation
indented-automation / Get-LdapAcl.ps1
Last active January 4, 2024 16:15
Get LDAP ACL
using assembly System.DirectoryServices.Protocols
using namespace System.DirectoryServices.Protocols; using namespace System.Collections.Generic
function Get-LdapObject {
<#
.SYNOPSIS
Get objects from an LDAP directory.
.DESCRIPTION
Get objects from an LDAP directory.
.EXAMPLE