Skip to content

Instantly share code, notes, and snippets.

@everydayintech
everydayintech / Pause-WindowsUpdates.ps1
Created January 5, 2023 12:36
Pause Windows 10 Updates for N Days
[string]$nowDate = [DateTime]::Now.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'")
[string]$UpdatePauseEndDate = [DateTime]::Now.AddDays(7).ToString("yyyy-MM-dd'T'HH:mm:ss'Z'")
[string]$RegNode = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings'
Set-ItemProperty -Path $RegNode -Name 'PauseFeatureUpdatesStartTime' -Value $nowDate
Set-ItemProperty -Path $RegNode -Name 'PauseQualityUpdatesStartTime' -Value $nowDate
Set-ItemProperty -Path $RegNode -Name 'PauseUpdatesExpiryTime' -Value $UpdatePauseEndDate
Set-ItemProperty -Path $RegNode -Name 'PauseFeatureUpdatesEndTime' -Value $UpdatePauseEndDate
Set-ItemProperty -Path $RegNode -Name 'PauseQualityUpdatesEndTime' -Value $UpdatePauseEndDate
@everydayintech
everydayintech / logoff.ps1
Created January 25, 2023 17:00
logout as if you have never been there
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI' -Name 'LastLoggedOnUser' -Value '' -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI' -Name 'LastLoggedOnUserSID' -Value '' -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI' -Name 'LastLoggedOnSAMUser' -Value '' -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI' -Name 'SelectedUserSID' -Value '' -PropertyType String -Force -ea SilentlyContinue;
logoff.exe
@everydayintech
everydayintech / PSAppwiz.ps1
Created January 28, 2023 17:57
get combined x86 and x64 uninstall key entries
# 2>NUL & @CLS & PUSHD "%~dp0" & "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -nol -nop -ep bypass "[IO.File]::ReadAllText('%~f0')|iex" & POPD & EXIT /B
$x86 = Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
$x64 = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*
$res = $x86 + $x64
$res | ? {$_.DisplayName -notlike ""} | Sort DisplayName | `
Select-Object DisplayName, Publisher, DisplayVersion, InstallDate, InstallLocation, InstallSource, ModifyPath, UninstallString | `
Out-GridView -Wait
$win32PointingDevices = Get-CimInstance win32_POINTINGDEVICE
$availablePointingDevices = @()
foreach($item in $win32PointingDevices)
{
try
{
$ffw = Get-ItemProperty "Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\$($item.PNPDeviceID)\Device Parameters" -Name 'FlipFlopWheel' -ErrorAction Stop
$availablePointingDevices += [PSCustomObject]@{
$CurrentDir = if($null -eq $MyInvocation.MyCommand.Path){Get-Location | Select-Object -ExpandProperty Path} else{Split-Path -Parent -Path $MyInvocation.MyCommand.Path}
$Filename = Read-Host -Prompt "Enter Filename"
$SecretFile = (Join-Path $CurrentDir $Filename)
Read-Host -AsSecureString -Prompt "Enter Secret" | ConvertFrom-SecureString | Out-File $SecretFile
@everydayintech
everydayintech / autounattend.xml
Last active June 5, 2023 11:45
autounattend.xml sample for zero touch Windows installation from USB or ISO
<?xml version="1.0" encoding="UTF-8"?>
<!--
autounattend.xml sample for silent Windows installation (intended for LAB USE only)
- Mofify Image index as needed, index 5 is Windows 11 Pro (most of the time)
- Modify Administrator password, default is: changeMePlease
- Modify language and keyboard as needed, assumes en-us image with swiss german keyboard layout
- Tested with Windows 11 22H2
-> put this file in root directory of a Windows installation media or
copy content of downloaded ISO (C:\ISOFILES) from Microsoft and generate custom ISO (C:\WIN11.iso) with Oscdimg:
[
{
"CatalogVersion": "23.01.08",
"Status": null,
"Component": "DriverPack",
"ReleaseDate": "21.05.06",
"Manufacturer": "Microsoft",
"Model": "Surface 3",
"Product": "Surface_3",
"Name": "Microsoft Surface 3 WiFi Win10 18362",
@everydayintech
everydayintech / PS32toPS64.ps1
Last active January 25, 2024 16:15
Run PowerShell Script in 64-bit PowerShell from a 32-bit PowerShell Process on 64-bit OS
# Original Script: https://z-nerd.com/blog/2020/03/31-intune-win32-apps-powershell-script-installer/
# Added Exit Code handling by: baartch
# Improved Exit Code handling by: https://github.com/everydayintech
If ($ENV:PROCESSOR_ARCHITEW6432 -eq 'AMD64') {
Write-Host 'Detected 32-bit PowerShell on 64-Bit OS, starting 64-bit PowerShell process...'
$argsString = ''
Try {
foreach ($k in $MyInvocation.BoundParameters.keys) {
switch ($MyInvocation.BoundParameters[$k].GetType().Name) {
@everydayintech
everydayintech / IntuneDependencyGraph.ps1
Created March 7, 2024 15:09
Intune App Dependency Analysis
Import-Module Microsoft.Graph.Beta.Devices.CorporateManagement -ErrorAction Stop
$ReadAllScopes = @(
"DeviceManagementApps.Read.All"
)
Connect-MgGraph -NoWelcome -Scopes $ReadAllScopes
$WindowsAppsFilter = "(isof('microsoft.graph.win32CatalogApp') or isof('microsoft.graph.windowsStoreApp') or isof('microsoft.graph.microsoftStoreForBusinessApp') or isof('microsoft.graph.officeSuiteApp') or (isof('microsoft.graph.win32LobApp') and not(isof('microsoft.graph.win32CatalogApp'))) or isof('microsoft.graph.windowsMicrosoftEdgeApp') or isof('microsoft.graph.windowsPhone81AppX') or isof('microsoft.graph.windowsPhone81StoreApp') or isof('microsoft.graph.windowsPhoneXAP') or isof('microsoft.graph.windowsAppX') or isof('microsoft.graph.windowsMobileMSI') or isof('microsoft.graph.windowsUniversalAppX') or isof('microsoft.graph.webApp') or isof('microsoft.graph.windowsWebApp') or isof('microsoft.graph.winGetApp')) and (microsoft.graph.managedApp/appAvailability eq null or microsoft.graph.managedApp/appAvailability eq
@everydayintech
everydayintech / Remove-ItemToRecycleBin.ps1
Created April 2, 2024 19:13
Moves a file or directory to the Recycle Bin
<#
.SYNOPSIS
Moves a file or directory to the Recycle Bin.
.DESCRIPTION
The Remove-ItemToRecycleBin function moves a specified file or directory to the Recycle Bin.
It uses the Microsoft.VisualBasic.FileIO.FileSystem class to perform the operation.
Original author: Ste (https://stackoverflow.com/users/8262102/ste)
Improved by: everydayintech (github.com/everydayintech)