Skip to content

Instantly share code, notes, and snippets.

View hansgafriedzal's full-sized avatar

Hans hansgafriedzal

View GitHub Profile
function Get-Csr
{
[CmdletBinding()]
param
(
[Parameter(ValueFromPipeline, Mandatory)]
[string] $Path = '.',
[ValidateSet('CertUtil, OpenSSL')]
[string] $Format = 'CertUtil'
function New-Csr
{
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipeline)]
[string] $CN,
[Parameter(Mandatory, ValueFromPipeline)]
[string[]] $SAN,
function New-Csr {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[string]$DomainName
)
begin {
# --- 0. Check for Administrator privileges ---
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
# https://superuser.com/a/1199773
$path = gps OUTLOOK | % path | split-path
if (!$path) {
Write-Host -f Red "Outlook is not running. Please start Outlook and try again."
}
"[Description]
MessageClass=IPM.Note
CLSID={00020D31-0000-0000-C000-000000000046}
@(
'CVE-2025-24065'
'CVE-2025-24068'
'CVE-2025-24069'
'CVE-2025-29828'
'CVE-2025-3052'
'CVE-2025-32710'
'CVE-2025-32712'
'CVE-2025-32713'
'CVE-2025-32714'
$h = 'C:\windows\system32\drivers\etc\hosts'
@(
"127.0.0.1 `t dev.localdev.info"
) | % {
(cat $h) + $_ | Out-File $h -Encoding ascii
}
# yyyyMMdd_HHmmsszzz | % Replace ':'
dir -File | % {
$d = $_.BaseName.Substring(0,8)
md $d -ea 0
move $_.FullName $d
}
$dir = dir -Directory
@hansgafriedzal
hansgafriedzal / Get-PathCollapsed.ps1
Last active November 27, 2024 16:36
Given a list of paths, remove all paths whose parent is already in the list.
<#
.SYNOPSIS
Given a list of paths, remove all paths whose parent is already in the list.
#>
function Get-PathCollapsed
{
param (
[string[]] $Paths
)
dir | % {
$exif = exiftool -G2 -json $_.FullName | ConvertFrom-Json
$exif.'Camera:Model'
}
$site = Get-SPSite http://site.local/
$query = New-Object -TypeName Microsoft.SharePoint.SPAuditQuery($site)
$query.RowLimit = 10
$query.SetRangeStart((Get-Date).Date)
$query.AddEventRestriction([Microsoft.SharePoint.SPAuditEventType]::ChildMove)
$site.Audit.GetEntries($query) | Out-GridView