07 December 2012

Find A Specific Email Address in Exchange

Sometimes we want to know what mailbox is associated with a particular email address. Here is the easy way to find out.

Exchange 2003
For Exchange 2003, Neil Hobson writes a very good article on www.msexchange.org that makes the process very simple. You must be logged onto a PC or server that has both Active Directory tools and Exchange 2003 management tools installed. See the full article at http://www.msexchange.org/articles/finding-duplicate-smtp-addresses.html

One thing he doesn't specifically mention is that you can use wildcards, such as '*', in your search, which is handy when you don't know the exact address you're looking for.

Exchange 2007/2010
For newer versions of Exchange, simply open the Exchange Management Shell on your mail server and type the following command:
get-recipient emailaddress@domain.com

References
http://www.msexchange.org/articles/finding-duplicate-smtp-addresses.html

13 November 2012

SharePoint Updates Cause Site to Fail

Connecting to Windows Internal Database MICROSOFT##SSEE

Notes on Recovering / Restoring Exchange

26 October 2012

Find Old Computers in AD

For Windows 2003/2008
(Must be 2003 Native domain or newer)
In a Command Prompt window type:
dsquery computer -inactive <num>
Where <num> is the minimum number of weeks the device has been inactive for. Advice seems to be to use at least 2, as anything less than that is not fully reliable.

For Windows 2008 R2+
In a PowerShell  window type:
$time=Read-host "Enter a date in format mm/dd/yyyy"
then
Get-ADComputer -Filter * | Get-ADObject -Properties lastlogontimestamp | where {(([DateTime]::FromFileTime($_.lastlogontimestamp) - ([system.datetime]$time)).totaldays) -lt 0 } | select name

You can change what you include in the select command at the end to get more or different info.

If you want to then remove all resulting computer accounts use the following command:
Remove-ADObject -recursive
in place of the select name

That is, to remove all computers older than $time use the following command:
Get-ADComputer -Filter * | Get-ADObject -Properties lastlogontimestamp | where {(([DateTime]::FromFileTime($_.lastlogontimestamp) - ([system.datetime]$time)).totaldays) -lt 0 } | Remove-ADObject -recursive
For more detail or a better example (of which this is basically a cut and paste at the moment), see reference site below.

References:
http://blog.mattvogt.net/powershell-last-logon-timestamp-for-single-ho 

10 October 2012

Reset Offline Files Cache in Windows 7

To reset the offline files cache in Windows 7

  1. Create a registry file called resetcache.reg file with the following contents:

    Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\CSC\Parameters] "FormatDatabase"=dword:00000001
  2. Double click the file and it should merge with registry. Alternatively, use command line:
    E.g. regedit.exe /s resetcache.reg
  3. Reboot the PC

Reference:
http://www.networknet.nl/apps/wp/archives/1093

Find the Desktop

It can be REALLY hard to access the desktop using scripts, especially batch scripts, if it has been moved from the default location of C:\Users\%username%, or even worse if it has been moved out of the %userprofile% location by the way of Folder Redirection.

As batch files cannot find this location, and I do not want to start learning VB script, I want a Powershell method I can use to find it.

This is the method I found:

$desktop = [Environment]::GetFolderPath("Desktop")

The $desktop variable now contains the location to the currently logged-in user's desktop. To view this path simply type

write-host $desktop

Happy day!

Reference:
The comment on the post at http://stackoverflow.com/questions/11349885/get-currently-logged-in-users-with-powershell-to-add-shortcut-to-desktop

:-)