Skip to content

Instantly share code, notes, and snippets.

View SamErde's full-sized avatar

Sam Erde SamErde

View GitHub Profile
@OmerMicrosoft
OmerMicrosoft / Create-DomainControllersRolesReport.ps1
Last active July 3, 2023 18:37
Get Installed Windows Roles on each Domain Controller
#Get Installed Roles on each Domain Controller
$DCsInForest = (Get-ADForest).Domains | % {Get-ADDomainController -Filter * -Server $_}
$DCsRolesArray = @()
foreach ($DC in $DCsInForest) {
$DCRoles=""
$Roles = Get-WindowsFeature -ComputerName $DC.HostName | Where-Object {$_.Installed -like "True" -and $_.FeatureType -like "Role"} | Select DisplayName
foreach ($Role in $Roles) {
$DCRoles += $Role.DisplayName +","
}
try {$DCRoles = $DCRoles.Substring(0,$DCRoles.Length-1)}
@OmerMicrosoft
OmerMicrosoft / Create-ClientsWithNoAssociatedSiteReport.ps1
Last active July 3, 2023 18:37
Create Clients With No Associated Site Report
#Get Domain Controllers for current domain
$DCs = Get-ADGroupMember "Domain Controllers"
#Initiate the clients array
$Clients = @()
Foreach ($DC in $DCs) {
#Define the netlogon.log path
$NetLogonFilePath = "\\" + $DC.Name + "\C$\Windows\debug\netlogon.log"
#Reading the content of the netlogon.log file
try {$NetLogonFile = Get-Content -Path $NetLogonFilePath -ErrorAction Stop}
catch {"Error reading $NetLogonFilePath"}
@SteveL-MSFT
SteveL-MSFT / profile.ps1
Last active May 27, 2024 14:02
PowerShell Prompt
#Requires -Version 7
# Version 1.2.13
# check if newer version
$gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e"
$latestVersionFile = [System.IO.Path]::Combine("$HOME",'.latest_profile_version')
$versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)"
if ([System.IO.File]::Exists($latestVersionFile)) {

How to get @DevBlackOps Terminal-Icons module working in PowerShell on Windows

Note: since version 0.1.1 of the module this now works in Windows PowerShell or PowerShell Core.

  1. Download and install this version of Literation Mono Nerd Font which has been specifically fixed to be recognised as monospace on Windows:

https://github.com/haasosaurus/nerd-fonts/blob/regen-mono-font-fix/patched-fonts/LiberationMono/complete/Literation%20Mono%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible.ttf

(see this issue for more info: ryanoasis/nerd-fonts#269)

@potatoqualitee
potatoqualitee / Save-KBFile.ps1
Last active June 7, 2024 17:48
Download Windows patch files / KB (patchid like KBxxxxx) and save them to disk using PowerShell
function Save-KBFile {
<#
.SYNOPSIS
Downloads patches from Microsoft
.DESCRIPTION
Downloads patches from Microsoft
.PARAMETER Name
The KB name or number. For example, KB4057119 or 4057119.
@kilasuit
kilasuit / RY-BasicBootstrap.ps1
Last active January 4, 2024 19:09
Simple BootStrap for new machines
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force -Scope LocalMachine
function Enable-PSTranscription {
$basePath = "HKLM:\Software\Policies\Microsoft\Windows\PowerShell\Transcription"
if (-not (Test-Path $basePath)) { $null = New-Item $basePath –Force }
Set-ItemProperty $basePath -Name EnableTranscripting -Value 1
Set-ItemProperty $basePath -Name OutputDirectory -Value "$env:USERPROFILE\OneDrive\PSTranscripts\$env:COMPUTERNAME\"
Set-ItemProperty $basePath -Name EnableInvocationHeader -Value 1
$basePath = "HKLM:\Software\Policies\Microsoft\PowerShellCore\Transcription"
@davidjenni
davidjenni / cidrToIpRange.ps1
Created January 7, 2020 18:08
CIDR to IP range conversion using PowerShell
# calculate IP address range from CIDR notation
# https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
function cidrToIpRange {
param (
[string] $cidrNotation
)
$addr, $maskLength = $cidrNotation -split '/'
[int]$maskLen = 0
@JustinGrote
JustinGrote / Test-DNSName.ps1
Last active July 30, 2021 03:05
High Performance DNS Resolver in Powershell
using namespace System.Net
using namespace System.Threading.Tasks
using namespace System.Management.Automation
using namespace System.Collections.Generic
function Test-DNSName ([String[]]$hostnames, [int]$Timeout = 3000) {
<#
.SYNOPSIS
Given a list of DNS names, returns the ones that actually resolve to an actual name
#>
@tig
tig / F7History.ps1
Last active April 16, 2024 16:07
Use F7 as "Show Command History" in Powershell
# See https://github.com/gui-cs/F7Hisoty which replaces this
@jedieaston
jedieaston / Install-WinGet.ps1
Last active July 25, 2023 22:08
Install WinGet (.ps1)! (on x64 systems)
$ErrorActionPreference = "Stop"
$apiLatestUrl = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
$tempFolder = $env:TEMP
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$WebClient = New-Object System.Net.WebClient
function Update-EnvironmentVariables {
foreach($level in "Machine","User") {