Skip to content

Instantly share code, notes, and snippets.

View SamErde's full-sized avatar
:octocat:
PowerShell

Sam Erde SamErde

:octocat:
PowerShell
View GitHub Profile
@SamErde
SamErde / Add-DevToMyWinServer.ps1
Created October 23, 2024 03:35 — forked from bentman/Add-DevToMyWinServer.ps1
Install Dev Tools on Win Server 2022
<#
.SYNOPSIS
Script to install Dev Tools on Windows Server (tested on 2022)
.DESCRIPTION
Installs the following from multiple resources:
Microsoft.VCLibs v14.00 (github)
Microsoft.UI v2.8.6 (github)
winget-cli (dynamic version retrieval from api.github.com)
Microsoft.WindowsTerminal (dynamic version retrieval from api.github.com)
Microsoft pwsh.exe vCurrent (winget)
@SamErde
SamErde / poco.psm1
Created October 15, 2024 21:50 — forked from yumura/poco.psm1
powershell peco
# Load
Split-Path $MyInvocation.MyCommand.Path -Parent | Push-Location
Get-ChildItem poco_*.ps1 | %{. $_}
Pop-Location
function Select-Poco
{
Param
(
[Object[]]$Property = $null,
@SamErde
SamErde / MathFun.ps1
Last active September 4, 2024 15:30
A little PowerShell "math" challenge to display rows of numbers that perform sequential addition
<#
Description: Start with a row of numbers from 0-10. In 10 successive rows, automatically generate the following:
- Skip the first index, having one fewer number than the previous row
- Add together the [i] and [i-1] numbers from the previous row to get the value of [i] in the current row
The final output should look like this:
0 1 2 3 4 5 6 7 8 9 10
1 3 5 7 9 11 13 15 17 19
4 8 12 16 20 24 28 32 36
@SamErde
SamErde / Get-AadJoinInformation.ps1
Created August 17, 2023 19:40 — forked from awakecoding/Get-AadJoinInformation.ps1
Get Azure AD (Entra ID) Join Information without dsregcmd
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
public enum DSREG_JOIN_TYPE {
DSREG_UNKNOWN_JOIN = 0,
DSREG_DEVICE_JOIN = 1,
DSREG_WORKPLACE_JOIN = 2
}
@SamErde
SamErde / Create-DomainControllersRolesReport.ps1
Created July 3, 2023 18:37 — forked from OmerMicrosoft/Create-DomainControllersRolesReport.ps1
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)}
#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"}
@SamErde
SamErde / Get-GPMissingPermissionsGPOs.ps1
Created July 3, 2023 18:23 — forked from OmerMicrosoft/Get-GPMissingPermissionsGPOs.ps1
Find Group Policies with Missing Permissions
#Find Group Policies with Missing Permissions
Function Get-GPMissingPermissionsGPOs
{
$MissingPermissionsGPOArray = New-Object System.Collections.ArrayList
$GPOs = Get-GPO -all
foreach ($GPO in $GPOs) {
If ($GPO.User.Enabled) {
$GPOPermissionForAuthUsers = Get-GPPermission -Guid $GPO.Id -All | select -ExpandProperty Trustee | ? {$_.Name -eq "Authenticated Users"}
$GPOPermissionForDomainComputers = Get-GPPermission -Guid $GPO.Id -All | select -ExpandProperty Trustee | ? {$_.Name -eq "Domain Computers"}
If (!$GPOPermissionForAuthUsers -and !$GPOPermissionForDomainComputers) {

Keybase proof

I hereby claim:

  • I am samerde on github.
  • I am samerde (https://keybase.io/samerde) on keybase.
  • I have a public key ASBP8NkV_nrcIsBjMKXrqNT0sgGzv49uTpqFZkP3RtUANQo

To claim this, I am signing this object:

@SamErde
SamErde / Install-WinGet.ps1
Created August 11, 2022 20:55 — forked from jedieaston/Install-WinGet.ps1
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") {