Skip to content

Instantly share code, notes, and snippets.

@d4rkeagle65
d4rkeagle65 / Configure-NTPServer.ps1
Created January 7, 2022 15:02
Enables Windows Server to server NTP to clients on a network and configures the upstream time server to time.windows.com. Also creates a firewall rule to allows incoming connections to UDP port 123 for NTP clients.
Set-TimeZone -Name 'Eastern Standard Time'
Set-Service -Name W32Time -StartupType Automatic
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer' -Name 'Enabled' -Value 1 -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config' -Name 'AnnounceFlags' -Value 0xA -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient' -Name 'Enabled' -Value 1 -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient' -Name 'SpecialPollInterval' -Value 300 -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters' -Name 'Type' -Value 'NTP' -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters' -Name 'NtpServer' -Value 'time.windows.com,0x8' -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config' -Name 'MaxPosPhaseCorrection' -Value 1800 -Force
Set-ItemProperty -Path 'HK
@d4rkeagle65
d4rkeagle65 / gist:412c058527e5b19ef1477fdadedc98b7
Created January 7, 2022 14:42
Activate Windows Command Line slmgr.vbs Quick Refrence
slmgr.vbs /cpky
slmgr.vbs /ipk [NewProductKey]
slmgr.vbs /ato
@d4rkeagle65
d4rkeagle65 / Disable-WindowsHello.ps1
Created August 5, 2021 13:36
Small script to disable Windows Hello Pin and Biometrics. This will disable the prompt the user to set one up, and will remove any existing pin/biometrics already set. Reboot required after running.
Set-ItemProperty HKLM:\SOFTWARE\Policies\Microsoft\Windows\System -Name 'AllowDomainPINLogon' -Value 0
Set-ItemProperty HKLM:\SOFTWARE\Microsoft\PolicyManager\default\Settings\AllowSignInOptions -Name 'value' -Value 0
New-Item -Path 'HKLM:\SOFTWARE\Policies\Microsoft\' -Name 'Biometrics' -Force
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Biometrics' -Name 'Enabled' -Value 0 -PropertyType Dword -Force
New-Item -Path 'HKLM:\SOFTWARE\Policies\Microsoft\' -Name 'PassportforWork' -Force
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\PassportforWork' -Name 'Enabled' -Value 0 -PropertyType Dword -Force
Start-Process cmd -ArgumentList '/s,/c,takeown /f C:\Windows\ServiceProfiles\LocalService\AppData\Local\Microsoft\NGC /r /d y & icacls C:\Windows\ServiceProfiles\LocalService\AppData\Local\Microsoft\NGC /grant administrators:F /t & RD /S /Q C:\Windows\ServiceProfiles\LocalService\AppData\Local\Microsoft\Ngc & MD C:\Windows\ServiceProfiles\LocalService\AppData\Local\Microsoft\Ngc & icacls C:\Wi
@d4rkeagle65
d4rkeagle65 / PowersheelEmbeddedIn.bat
Created December 7, 2020 21:34
Embedded PowerShell in Batch Script
@@echo off
@@findstr /v "^@@.*" "%~f0" > "%~f0.ps1" & powershell -ExecutionPolicy ByPass -File "%~f0.ps1" & del "%~f0.ps1" & exit
# Powershell Here #
# An example template powershell script that will allow you to work with the user registry keys for all users
# on a system or terminal server. It will check if the ntuser.dat file is mounted, and if not mount it with the
# users SID. If the ntuser.dat file was one mounted by the script (ie, user is not logged in), it will unmount
# the dat file after.
# This script uses the example of querying and displaying the set default printer per user for all users on a
# system.
$users = Get-WMIObject Win32_UserAccount
$hku = New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
@d4rkeagle65
d4rkeagle65 / Get-AuthState.ps1
Created November 21, 2020 18:35
Queries Windows 10 devices with dsregcmd, parses the output and determines if a device has the authentication state of either a local user only, local user registered with Azure AD, Azure AD joined, domain joined only, hybrid joined with Azure AD, domain joined with user registered with Azure AD or DRS on-prem.
$dsregcmd = dsregcmd /status | Where-Object { $_ -match ' : ' } | ForEach-Object { $_.Trim() } | ConvertFrom-String -PropertyNames 'Name','Value' -Delimiter ' : '
$joinType = 0
if ( ($dsregcmd | Where {$_.Name -eq 'EnterpriseJoined'}).Value -eq 'YES' ) {
$joinType = 4
} else {
if ( ($dsregcmd | Where {$_.Name -eq 'AzureAdJoined'}).Value -eq 'YES' ) {
if ( ($dsregcmd | Where {$_.Name -eq 'DomainJoined'}).Value -eq 'YES' ) {
$joinType = 3
} else {
@d4rkeagle65
d4rkeagle65 / dsregcmd.ps1
Created November 21, 2020 18:06
Parse dsregcmd.exe output to powershell name/value pairs.
$dsregcmd = dsregcmd /status | Where-Object { $_ -match ' : ' } | ForEach-Object { $_.Trim() } | ConvertFrom-String -PropertyNames 'Name','Value' -Delimiter ' : '
@d4rkeagle65
d4rkeagle65 / Server-SetupForVMToAzureMigration.ps1
Created August 17, 2020 15:03
Server-SetupForVMToAzureMigration.ps1
sfc /scannow
netsh.exe winhttp reset proxy
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation -Name RealTimeIsUniversal -Value 1 -Type DWord -Force
Set-Service -Name w32time -StartupType Automatic
powercfg.exe /setactive SCHEME_MIN
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name TEMP -Value "%SystemRoot%\TEMP" -Type ExpandString -Force
@d4rkeagle65
d4rkeagle65 / Install-WindowsUpdatesAndReboot.ps1
Last active July 26, 2024 00:34
This script will install any available windows updates. If a reboot is required it will setup a temporary user account and enable autologon, then reboot and rerun itself until there are no updates left. Modified gist from https://gist.github.com/joefitzgerald/8203265.
param(
$global:RestartRequired=0,
$global:MoreUpdates=0,
$global:MaxCycles=10
)
Function Get-StringHash {
param(
[String] $String,
$HashName = "MD5"
@d4rkeagle65
d4rkeagle65 / checksumGenerator.bat
Created July 8, 2020 13:09
Checksum Generator with certutil, takes file path as command line argument
@Echo off
:: Pass the file to hash as the only arg
Set "MD5="
For /f "skip=1 Delims=" %%# in (
'certutil -hashfile "%~f1" MD5'
) Do If not defined MD5 Set MD5=%%#
Set MD5=%MD5: =%
Echo:%MD5%