Tag Archives: script

Scripting DHCP server deployments using netsh in Windows Server 2008 R2

Windows_Server_2008_R2_Logo

Another quick post to show how you can quickly deploy fully working DHCP server with multiple scopes in a matter of seconds. In my case it was a single server with 90 very different scopes and doing this manually would be just soo boring and long that’s unreal. Unfortunately Windows Server 2012 wasn’t an option so no PowerShell love but Windows Server 2008 R2 is still pretty decent and using netsh wasn’t as painful as it seemed. To get us started we need to install the DHCP Server role and start the required service (dhcpserver):

Next step is to authorize DHCP server in the enterprise so we can actually use it to dish out IP addresses:

Other useful commands here would include:

To deauthorize the server –

and to list all authorized servers –

Continue reading

Active Directory Script to Shutdown Computers per OU

Windows_Server_2008_R2_Logo

If you need to shutdown computers per OU in Active Directory here is one way of doing it:

The only change you have to make for this script to work is to provide an LDAP string/path to the OU in AD where you’d like to shut the PCs.

In my company we had to come up with a solution to comply with the “green” policy enforced upon us. Initially I have tried the built-in shutdown command and feeding in computer names using Excel and CONCATENATE function. Issue with that approach was that my script was trying to reach out to each machine to check if its on the network and pingable taking too long to complete. Script above doesn’t have the same issues – it literally fires up shutdown request simultaneously to all machines on the specified OU – much quicker and definitely more effective!

If you guys have other ideas or have other solutions please let me know in comments below!