Skip to content

Instantly share code, notes, and snippets.

@manelrodero
manelrodero / PSADT-Cheatsheet.ps1
Created November 12, 2024 18:31 — forked from leeramsay/PSADT-Cheatsheet.ps1
PSADT snippits/cheatsheet
## Commonly used PSADT env variables
$envCommonDesktop # C:\Users\Public\Desktop
$envCommonStartMenuPrograms # C:\ProgramData\Microsoft\Windows\Start Menu\Programs
$envProgramFiles # C:\Program Files
$envProgramFilesX86 # C:\Program Files (x86)
$envProgramData # c:\ProgramData
$envUserDesktop # c:\Users\{user currently logged in}\Desktop
$envUserStartMenuPrograms # c:\Users\{user currently logged in}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
$envSystemDrive # c:
$envWinDir # c:\windows
@manelrodero
manelrodero / Purge-PSModules.ps1
Created March 18, 2024 08:14
Borra las versiones antiguas de los módulos PowerShell instalados (dejando únicamente una)
# Obtén la lista de todos los módulos instalados
$installedModules = Get-Module -ListAvailable
# Filtra los módulos que tienen más de una versión instalada
$modulesWithMultipleVersions = $installedModules | Group-Object Name | Where-Object { $_.Count -gt 1 }
# Itera a través de los módulos con múltiples versiones
foreach ($module in $modulesWithMultipleVersions) {
$moduleName = $module.Name
$moduleVersions = $module.Group | Sort-Object Version
@manelrodero
manelrodero / GetVBScriptFOD.ps1
Created October 2, 2023 12:00
Watch for CAB files of VBScript FOD
# Directorios de origen y destino
$sourceDirectory = 'C:\Windows\SoftwareDistribution\Download'
$global:destinationDirectory = 'C:\FixVbScript'
# Crear el directorio de destino si no existe
if (!(Test-Path -Path $global:destinationDirectory)) {
New-Item -ItemType Directory -Path $global:destinationDirectory
}
# Crear un objeto FileSystemWatcher
@manelrodero
manelrodero / cloudflare-ddns.py
Created January 3, 2023 14:53
Update CloudFlare A record (Dynamic DNS)
#!/usr/bin/env python
# cloudflare-ddns.py
# Summary: Access your home network remotely via a custom domain name without a static IP!
# Description: Access your home network remotely via a custom domain
# Access your home network remotely via a custom domain
# A small, 🕵️ privacy centric, and ⚡
# lightning fast multi-architecture Docker image for self hosting projects.
# Código original:
# https://github.com/timothymiller/cloudflare-ddns
@manelrodero
manelrodero / Repair-DNSSuffix.ps1
Created November 7, 2022 09:40
DNS Suffix usando PowerShell
Function Repair-DNSSuffix {
if ((Get-WmiObject Win32_ComputerSystem).PartOfDomain -eq $true) {
if (Test-ComputerSecureChannel -Repair) {
Get-NetConnectionProfile | Where-Object { $_.NetworkCategory -eq "Public" } | ForEach-Object {
if ($_.InterfaceAlias) {
Set-DnsClient $_.InterfaceAlias -ConnectionSpecificSuffix $env:USERDNSDOMAIN -UseSuffixWhenRegistering $TRUE -ErrorAction SilentlyContinue
}
ipconfig.exe /registerdns
}
}
@manelrodero
manelrodero / Install-Winget.ps1
Created November 4, 2022 12:54
Instalar Winget (y sus pre-requisitos)
<#PSScriptInfo
.VERSION 1.0.2
.GUID d860203a-bf1c-4477-aa2d-945981b9834e
.AUTHOR shfritz@microsoft.com
.COMPANYNAME Microsoft
@manelrodero
manelrodero / Borrar_Acrobat_All.bat
Last active July 3, 2024 22:58
Desinstalar Adobe Acrobat Reader y Pro + Borrar restos + Configuración de usuario
@echo off
echo Matando procesos...
taskkill.exe /f /im "AcroRd32.exe" 2>nul
taskkill.exe /f /im "Acrobat.exe" 2>nul
taskkill.exe /f /im "acrodist.exe" 2>nul
echo Desinstalando programas...
FOR /F "tokens=1 delims=:" %%i IN ('UninstallW.exe /a ^| FIND /I "Adobe Acrobat Reader"') DO UninstallW.exe /q /w "%%i"
FOR /F "tokens=1 delims=:" %%i IN ('UninstallW.exe /a ^| FIND /I "Adobe Acrobat"') DO UninstallW.exe /q /w "%%i"
@manelrodero
manelrodero / Borrar_Adobe_HKCU.ps1
Created October 27, 2022 20:21
Adaptación para actuar sobre el registro de todos los usuarios (y borrar configuración Adobe)
# Writing Current User registry keys in SCCM as System
# https://tdemeul.bunnybesties.org/2022/04/writing-current-user-registry-keys-in.html
# Modificado 27/06/2022 para UPC (Entorno GET)
# Modificado 27/10/2022 para "atacar" únicamente a todos los usuarios (Borrar Adobe)
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidatePattern('\.reg$')]
@manelrodero
manelrodero / nxlog.conf
Created October 23, 2022 11:35
NxLog sample configuration
Panic Soft
#NoFreeOnExit TRUE
define ROOT C:\Program Files\nxlog
define CERTDIR %ROOT%\cert
define CONFDIR %ROOT%\conf
define LOGDIR %ROOT%\data
define LOGFILE %LOGDIR%\nxlog.log
LogFile %LOGFILE%
@manelrodero
manelrodero / WSL-WSL2-Uninstall.ps1
Created October 23, 2022 11:32
Uninstall WSL/WSL2 (Windows 10 2004+)
msiexec.exe /x "wsl_update_x64.msi" /q
dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /remove /norestart
dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /remove /norestart