Skip to content

Instantly share code, notes, and snippets.

@mendel129
Created June 1, 2017 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mendel129/c56fb7e72702b60da44d7e0c71067bd6 to your computer and use it in GitHub Desktop.
Save mendel129/c56fb7e72702b60da44d7e0c71067bd6 to your computer and use it in GitHub Desktop.
adds ntlm exception
# used together with the Windows security policy "Network security: Restricit NTLM.
# if all NTLM is blocked, a computer becomes pretty useless, so this script to create exceptions based on failed connections from the NTLM log
# Adds exception to Network security: Restricit NTLM: Add remote server exceptions for NTLM authentication
function add-ntlmexception
{
$event = Get-WinEvent -FilterHashTable @{LogName='Microsoft-Windows-NTLM/Operational'; ID = 4001} -maxevents 1
$newexception = ((([xml]$event.toxml()).Event.EventData.Data) | ?{$_.name -eq "targetname"}).'#text'
$regpath = "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0"
$regname = "clientallowedntlmservers"
$currentvalues = (Get-ItemProperty $regpath).$regname
$futurevalues = $currentvalues
$futurevalues += $newexception
New-ItemProperty -Path $regpath -Name $regname -Value $futurevalues -PropertyType MultiString -Force
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment