Recently we got tasked with protecting all objects in a specific OU from accidental deletion. There were about 60 users in this OU so we wanted to script this and by scripting this we would also be able to set up a scheduled task so that the change got applied to new users who got added to the OU also.
First of all open PowerShell and run “Import-Module activedirectory”
Now run the following but obviously change the DN name so that it points at the OU relevant for your domain.
Get-ADobject -Filter * -SearchBase “OU=Users,DC=Domain,DC=com” | Set-adobject -ProtectedFromAccidentalDeletion $true
All users in the OU should now be protected from accidental deletion 
Just a quick useful command that you can run to find out which DCs hold which FSMO Role.
“netdom query fsmo”

There is a quick way to record your session in PowerShell to a text file so you have a record of every command you have typed.
In PowerShell run the following command (Change location to wherever you would like)
Start-Transcript c:\Powershell.txt –Append
Now use PowerShell as you usually would, once you have finished with PowerShell run the following command “Stop-Transcript”
If you now open the “PowerShell.txt” you will see everything you have just done in your PowerShell session.
**********************
**********************
Windows PowerShell Transcript Start
Start time: 20110810173323
Username : Test
Machine : Test (Microsoft Windows NT 6.1.7600.0)
**********************
Transcript started, output file is c:\MySession.txt
[PS] C:\>Get-Mailbox –Identity Dan
Name Alias ServerName
—- —– ———-
Dan Dan Test
[PS] C:\>Get-User -Identity risual
Name RecipientType
—- ————-
Dan UserMailbox
[PS] C:\>Stop-Transcript
We got an error recently when trying to install the PrerequisiteInstaller.exe from the SharePoint media. The error message was “Error: the tool was unable to install Windows Identity Foundation (KB974405)”.
We simply resolved this by installing the component manually (Download Link http://www.microsoft.com/download/en/details.aspx?id=17331)
We then re-ran installer and all worked fine 
We had an issue recent where we could install Software update 1 on Forefront TMG. We were displayed with the following error each time we went to install it “Setup cannot read the Registry Value ProductID”

To troubleshoot the issue i ran PROCMON at the same time as running the install, in my procmon logs i noticed that it referenced “ProductID” value that was displayed in TMG install error. The error it gave in PROCMON was Name_Not_Found.

So what i did was create a REG_SZ string with the name “ProductID” and left the value blank. I then re-ran the installation and all completed successfully 
We have came across an error this month after patching our environment.
Most of our windows 2008 R2 servers started having the below event flooding the event logs
“Activation context generation failed for “C:\Windows\system32\conhost.exe”. Dependent Assembly Microsoft.Windows.SystemCompatible,processorArchitecture=”amd64″,
publicKeyToken=”6595b64144ccf1df”,type=”win32″,version=”6.0.7600.16816″ could not be found. Please use sxstrace.exe for detailed diagnosis.”
It turns out that this error is caused by “Security Update for Windows Server 2008 R2 x64 Edition (KB2507938)” and this can safely be ignored. For more information please see “http://support.microsoft.com/kb/2507938/”.
You can get rid of the alert by upgrading to 2008 R2 SP1.
Just a quick way to change your IP, Subnet Mask and Default gateway via command prompt
- First Run “netsh int ipv4 show interface” and note down the name of the adapter of which IP settings you want to change.

- Now the next command will change the IP configuration for you ( Please note “Local Area connection” was the name of the adapter i wanted to change.
I wanted to set the following settings
IP 192.168.1.1
Mask 255.255.255.0
Default Gateway 192.168.1.254
Command
set address “Local Area connection” static 192.168.1.1 255.255.255.0 192.168.1.254
We came across an issue recently when trying to create a test mailbox for our SCOM monitoring.
On the Exchange Sever we ran the following script to create the test mailbox “New-TestCasConnectivityUser.PS1”
However the command produced the following error “CreateTestUser : Mailbox could not be created. Verify that OU ( Users ) exists and that password meets complexity requirements.”
To resolve this we specified the DN name of the OU in the New-TestCasConnectivityUser.PS1 script by editing the following line in the PS1 script.
$OrganizationalUnit = “Users”
We changed this to
$OrganizationalUnit = “CN=Users,DC=Domain,DC=CO,DC=UK”
We then re-ran the script and all worked fine 
We had the following alert appear on our Exchange Server recently.
“Process powershell.exe (PID=19640). Object [CN=Username,OU=Mailboxes,OU=OU,DC=Domain,DC=com]. Property [HomeMTA] is set to value [Domain.com/Configuration/Deleted Objects/Microsoft MTA
DEL:d016338e-12ce-409b-a82a-da6217c8e67f], it is pointing to the Deleted Objects container in Active Directory. This property should be fixed as soon as possible.”
Basically the issue is that the user referenced in event has an incorrect homeMTA value. If you browse to the user via ADSI edit and view the attribute homeMTA you will see that it references deleted objects.

To sort this issue run the following command 
get-mailbox –identity USERNAME | Update-Recipient
We came across an issue recently where we were receiving Event ID 2937 in our event logs in regards to the offline address pointing to the deleted objects container in Active Directory.
Process powershell.exe (PID=14836). Object [CN=Exchange 2010 OAB,CN=Offline Address Lists,CN=Address Lists Container,CN=Name,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=servername,DC=net]. Property [PublicFolderDatabase] is set to value [servername.net/Configuration/Deleted Objects/PF
DEL:f03f8b36-7d36-4d3d-98a7-a0f6e2f325a6], it is pointing to the Deleted Objects container in Active Directory. This property should be fixed as soon as possible
We resolved this issue by doing the following.
- Open ADSIedit
- Navigate to “CN=Exchange 2010 OAB,CN=Offline Address Lists,CN=Address Lists Container,CN=Name,CN=Microsoft Exchange,CN=Services,CN=Configuration”
- Right click Exchange 2010 OAB and choose properties.
- Navigate to the siteFolderServer attribute and you will see the same value specified here as in the event id.
- If you choose clear on this and apply the setting.
- Now open the Exchange Management Shell navigate to Organization Configuration > Mailbox > Offline Address Book
- Right click the OAB in question and browse to the distribution tab.
- Now uncheck “enable folder distribution” and choose ok
- Now if you go back to the same setting and re-enable “enable folder distribution “
- This should now have fixed your issue, you can refresh ADSIEDIT and check the siteFolderServer attribute just to make sure it no longer references the deleted object container.