Archive for category V1
PowerShell find all Server 2008 boxes in a domain
Posted by Karl Mitschke in PowerShell, V1, V2 on March 30, 2010
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 […]
PowerShell Dealing with Active Directory Latency
Posted by Karl Mitschke in 2007, Exchange, PowerShell, V1, V2 on January 8, 2010
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 […]
PowerShell Find Date of a previous day in any week
Posted by Karl Mitschke in PowerShell, V1, V2 on December 19, 2009
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 […]
Retrieve a list of stale Active-Sync devices
Posted by Karl Mitschke in 2007, Exchange, PowerShell, V1 on December 4, 2009
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 […]