Archive for category V1

PowerShell find all Server 2008 boxes in a domain


This script will find all Server 2008 (and Server 2008 R2) machines on your domain: 001 002 003 004 005 006 007 008 009 010 011 012 013 $objDomain = [ADSI]” $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = $objDomain $objSearcher.Filter = "(&(objectCategory=computer)(operatingsystem=*Server 2008*))" $objSearcher.PageSize = 1000 $colProplist = "*" foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)} $colResults = $objSearcher.FindAll() $Server2008 = @() foreach ($objResult in $colResults)  { $Server2008 += $objResult.Properties.name } You can change the operatingsystem= line to gather the OS you are interested […]

2 Comments

PowerShell Dealing with Active Directory Latency


Consider the following: 001 002 003 004 005 006 007 New-DistributionGroup -Name "karls test group" ` -SamAccountName "karlstestgroup" ` -DisplayName "Karls Test" ` -Type "Security" ` -OrganizationalUnit "contoso.com/Test/EmailTest" Add-DistributionGroupMember ` -Identity "karlstestgroup" -Member "karlmitschke@contoso.com" If you have latency in your Active Directory, you most likely will get an error on the “Add-DistributionGroupMember” command: Add-DistributionGroupMember : The operation could not be performed because ‘karlstestgroup’ could not be found. Note that […]

Leave a comment

PowerShell Find Date of a previous day in any week


I often need to name a file with a date as part of the file name like: ServerInventory12-18-2009.csv A simple $date = $(get-date).ToString(“MM-dd-yyyy”) works great for today, but I recently had a need to create a file once a week, with a file name of the previous Saturday. I had come across Arul Kumaravel’s WebLog […]

7 Comments

Retrieve a list of stale Active-Sync devices


We allow users who have signed the proper policy to access their Exchange mailbox via Active Sync devices. Users being users, though, we quite often have active sync devices that are registered to a mailbox, but are no longer in use. Users always have a clever excuse like “Oh, i lost that last year”, or […]

11 Comments