Skip to content

Instantly share code, notes, and snippets.

View jwmoss's full-sized avatar
🤩
Stuck in a foreach loop

Jonathan Moss jwmoss

🤩
Stuck in a foreach loop
View GitHub Profile
@SMSAgentSoftware
SMSAgentSoftware / Get-CurrentPatchInfo.ps1
Last active February 23, 2024 20:58
Gets the current software update level of a Windows 10/11 workstation and compares with the latest available updates. Can also list all available updates for the current build.
[CmdletBinding()]
Param(
[switch]$ListAllAvailable,
[switch]$ExcludePreview,
[switch]$ExcludeOutofBand
)
$ProgressPreference = 'SilentlyContinue'
Function Get-MyWindowsVersion {
[CmdletBinding()]
[CmdletBinding()]
param(
[Parameter( Mandatory, Position = 1, ValueFromPipelineByPropertyName, ValueFromPipeline )]
[Alias( 'HostName', 'Server' )]
[string[]]
$ComputerName,
[System.DirectoryServices.ActiveDirectory.SyncFromAllServersOptions]
$SyncOptions = @( 'CrossSite', 'PushChangeOutward', 'SkipInitialCheck' ),
@JustinGrote
JustinGrote / Get-HTMLTable.ps1
Last active September 18, 2020 06:59
Get-HTMLTable Prototype
using namespace HtmlAgilityPack
function Get-HTMLTable {
[CmdletBinding()]
param(
[Parameter(Mandatory,ValueFromPipeline)][HtmlNode]$HtmlDocument
)
process {
foreach ($table in $HtmlDocument.SelectNodes('//table')) {
function Invoke-NativeCommand {
<#
.SYNOPSIS
Invoke a native command (.exe) as a new process.
.DESCRIPTION
Invoke-NativeCommand executes an arbitrary executable as a new process. Both the standard
and error output streams are redirected.
Error out is written as a single non-terminating error. ErrorAction can be used to raise

Credit: Mark Kraus
Website: https://get-powershellblog.blogspot.com

Collection Type Guidence

When to use what

  • Use Arrays if you know the element types and have a fixed length and/or known-up-front collection size that will not change.
  • Use ArrayList if you have an unkown collection size with either unknown or mixed type elements.
  • Use a Generic List when know the type of the elements but not the size of the collection.
  • Use a HashTable if you are going to do key based lookups on a collection and don't know the object type of the elements.
  • Use a Dictionary<TKey, TValue> you are going to do key based lookups on a collection and you know the type of the elements.
  • Use a HashSet when you know the type of elements and just want unique values and quick lookups and assignmnets.
@nohwnd
nohwnd / Uninstall-Pester.ps1
Last active March 14, 2024 13:57
Remove built-in version of Pester 3 (or -All) from Windows 10 Program Files and Program Files (x86).
#Requires -RunAsAdministrator
function Uninstall-Pester ([switch]$All) {
if ([IntPtr]::Size * 8 -ne 64) { throw "Run this script from 64bit PowerShell." }
#Requires -RunAsAdministrator
$pesterPaths = foreach ($programFiles in ($env:ProgramFiles, ${env:ProgramFiles(x86)})) {
$path = "$programFiles\WindowsPowerShell\Modules\Pester"
if ($null -ne $programFiles -and (Test-Path $path)) {
if ($All) {
@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
@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
@RavuAlHemio
RavuAlHemio / Restoring an utterly destroyed DFSR-replicated SYSVOL from backup.md
Last active January 29, 2024 10:24
Steps to restore an utterly destroyed DFSR-replicated SYSVOL from backup

Restoring an utterly destroyed DFSR-replicated SYSVOL from backup

Warning: this is not official Microsoft documentation and some of these steps might not actually be supported.

This guide is provided "as is", without warranty of any kind, express or implied. In no event shall the authors or copyright holders be liable for any claim, damages or other liability arising from, out of or in connection with applying the steps outlined in this guide.

When to use

@keithga
keithga / Get-LatestUpdate.ps1
Last active February 23, 2024 13:17
script to get latest build.
<#
.SYNOPSIS
Get the latest Cumulative update for Windows
.DESCRIPTION
This script will return the list of Cumulative updates for Windows 10 and Windows Server 2016 from the Microsoft Update Catalog.
.NOTES
Copyright Keith Garner (KeithGa@DeploymentLive.com), All rights reserved.