How to clean up old DHCP server’s entry in a domain via PowerShell and netsh command

It’s very easy to forget old server entries and it may cause an issue in your network.  Sometimes system/network admin wait for approval process or schedule to clean up or just simply don’t know how to.  Whatever your reason is, this should be done to keep your network healthy from any unknown issues.  Here are some ways to clean up, I have listed PowerShell, Netsh and via GUI.

Via PowerShell:

To see list of all DHCP server run PowerShell command:

PS C:\>Get-DhcpServerInDC

To remove it:

You have to be domain or enterprise admin to remove it otherwise, you will get error

PS C:\>Remove-DhcpServerInDC –DnsName YourDHCPserver –IPAddress

This is without error: if you have run as admin

To add it:

You have to be domain or enterprise admin to remove it otherwise, you will get error

PS C:\> Add-DhcpServerInDC –DnsName YourDHCPserver –IPAddress

Using netsh commands

To the list of commands: netsh dhcp list

To add:

Netsh dhcp add server NameOfYourDHCPServer IP address

To delete:

Dhcp delete server NameOfYourServer IP address

Via GUI:

To add:
open your DHCP server, right-click, and select add

To Remove:
open your DHCP server, right-click and select Manage authorized servers …
Then just remove HDCP server that’s no longer in use

That’s it



How to enable Remote Desktop Using PowerShell

Remote Desktop is very common still for many companies remote users to use, not all users needed since they most likely use VPN to get access to apps or just using the cloud-based. PowerShell is a new way to make changes to your remote computer lot easier than opening GUI and waiting for it to load and make changes. If you are admin of the network, it’s very easy to make changes and get the status of remote computer settings. Here in this post will do the Remote Desktop enable using PowerShell, let’s get started it

Computer or server must meet the following requirements:

  • The WinRM service should be started
  • You must have administrator permissions on the remote device
  • Firewall rule should be set to allow RDP connection default port 3389 if you have changed the default port make sure to add to your firewall rule

To start the session from your Windows 10 computer or Windows server, open PowerShell with Administrator

Command: Enter-PSSession -ComputerName YourRemoteComputerName or IP address -Credential domain\administrator

Once you are connected to a remote computer or server, you can run the following command to get current status:

Get-ItemProperty -Path ‘HKLM:\System\CurrentControlSet\Control\Terminal Server’-name “fDenyTSConnections”

Then to change the setting to allow RDP connection, just run following:

Set-ItemProperty -Path ‘HKLM:\System\CurrentControlSet\Control\Terminal Server’-name “fDenyTSConnections” -Value 0

You should also make sure that you have only secured RDP authentication (NLA – Network Level Authentication) to check  run the command: you should see 1

Get-ItemProperty -Path ‘HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp’ -name “UserAuthentication”

 If you see 0 then set it to 1 by running:

Set-ItemProperty -Path ‘HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp’ -name “UserAuthentication” -Value 1

To test the Remote Desktop connection:

Test-NetConnection ComputerName or IP address -CommonTCPPort RDP

That’s it for now, here is a screenshot of the GUI look like after you have enabled the RDP

Note: if the user whom RDP into this remote computer is not admin user you need to add them to a remote desktop group, if you want to do via PowerShell you can check this post out: How to add a local user to windows 10 via PowerShell



How to improve application pool timeouts in IIS

There are many settings you can adjust to improve the application pool in IIS, one of them is timeouts. Please take a backup of your settings before making any changes, in case you need to revert it back. Each default settings you change may impact the health of the overall server. There are many reasons to keep it default and many to change it, all depends on the needs of your application. I would not change the IIS recycle settings, they are there to clean up the resources of applications that aren’t in use, like memory, database sessions, etc.. Some settings can be set up within your application to keep it alive by use of a ping service just makes a request on the site every so often.

Login in to your server, open IIS Manager.

In the left pane (Connections), select Application Pools.
In the middle pane (Application Pools), select YourApp.
On the right pane (Actions), select Edit Application Pool > Advanced Settings… or just right click and select Advanced settings ..

Then in the Advanced Settings window, under Process Model, set Idle Time-out (minutes) to 0 if you want to disable or change from default 20 minutes to whatever works for you.
Then click OK.

You can change other settings that might help your application performance to stay wake longer, so end users don’t feel the slowness, just keep in mind overall server health, load, memory, CPU will be effected. That’s it for now



How to turn on/off Narrator on Windows 10

Sometimes you may have turned on the narrator by mistake or using a combination key of Windows+ CTRL+ ENTER which will turn on and turn off the narrator’s voice.  The quickest way to use the shortcut keys to turn on/off using these key combinations may vary from OS versions. There are many people who find these settings helpful and some just find annoying if they are turning on by mistake. So, whatever your case is here are the options.

When you first turn on the Narrator you get this screen, where it shows the shortcut keys.

Here is a list of keys

To turn off:

  • Hold the CAPS LOCK key and press ESC key
  • Press WINDOWS + CTRL + ENTER key (if it’s off it will turn back on it toggles on/off)
  • Hold the WINDOWS Key and press ENTER

To turn it on/Off:

Press WINDOWS + CTRL + ENTER key (if it’s off it will turn back on it toggles on/off)

You can also go through the settings options to turn it off, but you will have to press each action twice because first is selection narrator will read to you second time it will make the selection.

Select START > SETTINGS

Then click on Open Ease of Access and select Narrator you will see all the options to turn on/off the narrator

Or

Select START>SETTINGS

Then in the search type narrator, it should give you so of these options and for all options click Show all results:

If you have Surface or other tablets, this might work for you:

Hold down the ALT and TAB keys simultaneously. Then it will bring up the Microsoft Settings window, which will give you options to turn on/off the narrator.

I hope this helps others who looking to turn on/off via registry key, please take a backup in case you need to restore it.

If you really want to turn off permanently or disable Narrator including shortcut key, then you will have to do it via registry key: Just change the value from 1 to 0 (1=on or 0=off)



How to add a local user to Windows 10 via PowerShell

PowerShell is very common to use these days as more and more software doing automation.  Many times it’s harder to find Graphical User Interface (GUI) to add a user or find other settings.  In this post, I am adding a local user via PowerShell and adding a user to local group.  PowerShell has built-in help and examples too, so if you want to know more about the command just type Get-Help then Name of command and it will give more info about it. Let’s get started exploring the options starting with viewing current users.

To see current local users:

PS C:\> Get-LocalUser

To see Local Groups:

PS C:\> Get-LocalGroup

Adding user:

PS C:\>New-LocalUser –Name WhatEverName

When you hit Enter it will give you option to put the password

To remove a local user:

Make sure you have at least one user account and it’s a member of LocalAdmin group

PS C:\> Remove-LocalUser -Name WhatEverNameYouWantToRemove

Add user to Local Group:

My example user name is: Admin replace that with your user name

PS C:\> add-LocalGroupMember -Group “Administrators” -Member “Admin”

To see Local Group Member of Administrator (Local admins)

PS C:\> Get-LocalGroupMember ‘Administrators’

To add a user to a Local admin group:

PS C:\> Add-LocalGroupMember -Group “Administrators” -Member “User1”, “User2”, etc…

Many more options you can via PowerShell now, if you get an error make sure to read it and see where the error is, it will give you clue and also some commands require Admin right you will get an error like Access denied