Month: June 2014

Supply , installation and support

Powershell: backup all DHCP servers

This script MUST be run on a 2012 server #you define some share ( eg \server1dhcpbackup$  , and DNS suffix eg my.domain.com #remove any variables that might have been stored, otherwise it has a bit of a wobble. Remove-Variable dhcpServer Remove-Variable dhcpServers #we are going to do a check first for all files/folders that are…
Read more

Powershell : Ping all machines

In theory you should know if all your machines are active or not in your environment. However as the environment gets bigger or more people work on it this can become confusing. This powershell script reads a list ( in txt format ) of machines you want to ping , how many pings , max…
Read more

Powershell : Find all servers in a domain

This code will find all servers in a domain and return its canonical location   $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.Filter = ‘(OperatingSystem=Window*Server*)’ “Name”,”canonicalname”,”distinguishedname” | Foreach-Object {$null = $objSearcher.PropertiesToLoad.Add($_) } $objSearcher.FindAll() | Select-Object @{n=’Name’;e={$_.properties[‘name’]}},@{n=’ParentOU’;e={$_.properties[‘distinguishedname’] -replace ‘^[^,]+,’}} | ft -autosize

Powershell : add users from one group to another.

Simple script to add multipe users from one group to another easily.   Will show on screen error if they already are members of the destination group but carry on going on error.     ====================================================================================== $Source_Group = “CN=MAC,OU=Test Groups,OU=Groups,OU=GB,,DC=whatever,DC=com” $Destination_Group = “CN=newMAC,OU=Test Groups,OU=Groups,OU=GB,,DC=whatever,DC=com”   $Target = Get-ADGroupMember -Identity $Source_Group foreach ($Person in $Target) {…
Read more