[Powershell] change a local security policy
Go to solution
Solved by TheRealShadoh,
If this is on a domain system, use a GPO, but an easy solution is just change the registry of the box
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -name "dontdisplaylastusername" -value 1
If its more than just your box you're hitting...
try
{
$existingValue = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -name "dontdisplaylastusername"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -name "dontdisplaylastusername" -value 0
$newValue = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -name "dontdisplaylastusername"
}
catch
{
throw
}
Write-Output "Was: $($existingValue)"
Write-Output "Is: $($newValue)"
Do some logging and output stuff to something you can review.
Use a loop if you have a bunch of things to change in registry.
foreach($object in $list)
{
}

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now