I went to push out Java 6 Update 22 with SCCM found that the MSI no longer works and was reporting a success even though it hadn't fully installed. Sun decided to make the install a multi-part install and the MSI that we used to extract is only part of the application. This left me with several machines with half of a working Java install but a successful report back from almost all of them.
I did some searching and found that supposedly you could pass the old MSI arguments to the jre-6u22-windows-i586-s.exe and gave that a try only to find that they didn't work. Guess I should have known that one ahead of time. In testing and troubleshooting I found that some of the Java 6 U 22 installs wouldn't even uninstall. So I came up with a quick and dirty little script that removes the files and registry keys and then reinstalls the full package. I will walk you through each of these steps. Each of the files is pasted below and separated by ===.
I created 2 SCCM programs under the Sun Java Package. 1. is the uninstall and 2. is the reinstall. One advertisement for all of it calls the uninstall program first and then the reinstall command line.
Uninstall:
The first thing we do is stop the jqs, copy over the vbs that does the uninstall of lots of previous packages and run it. Then we remove the registry keys and java folders for Update22. At the end we delete the uninstall.vbs.
Uninstall.bat
========================================================
net stop "java quick starter"
c:
cd\
copy \\sccmserver\fileshare\javauninstall.vbs c:\
javauninstall.vbs
reg delete "HKEY_CLASSES_ROOT\Installer\Products\4EA42A62D9304AC4784BF238120622FF" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\4EA42A62D9304AC4784BF238120622FF" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F83216022FF}" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\JreMetrics" /f
rd "%programfiles%\java" /s /q
rd "%programfiles% (x86)\java" /s /q
del c:\javauninstall.vbs
=========================================================
javauninstall.vbs
=========================================================
Set objWshShell = WScript.CreateObject("WScript.Shell")
On Error Resume Next
' Java(TM) 6 Update 21 removal.
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216021FF} /qn", 1, True
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216021F0} /qn", 1, True
' Java(TM) 6 Update 20 removal.
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216020FF} /qn", 1, True
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216020F0} /qn", 1, True
' Java(TM) 6 Update 19 removal.
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216019FF} /qn", 1, True
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216019F0} /qn", 1, True
' Java(TM) 6 Update 18 removal.
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216018FF} /qn", 1, True
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216018F0} /qn", 1, True
' Java(TM) 6 Update 17 removal.
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216017FF} /qn", 1, True
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216017F0} /qn", 1, True
' Java(TM) 6 Update 16 removal.
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216016FF} /qn", 1, True
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216016F0} /qn", 1, True
' Java(TM) 6 Update 15 removal.
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216015FF} /qn", 1, True
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216015F0} /qn", 1, True
' Java(TM) 6 Update 14 removal.
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216014FF} /qn", 1, True
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216014F0} /qn", 1, True
' Java(TM) 6 Update 13 removal.
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216013FF} /qn", 1, True
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216013F0} /qn", 1, True
' Java(TM) 6 Update 12 removal.
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216012FF} /qn", 1, True
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216012F0} /qn", 1, True
' Java(TM) 6 Update 11 removal.
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216011FF} /qn", 1, True
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216011F0} /qn", 1, True
' Java(TM) 6 Update 10 removal.
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216010FF} /qn", 1, True
objWshShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83216010F0} /qn", 1, True
' Java(TM) 6 Update 7 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0160070} /qn", 1, True
' Java(TM) 6 Update 6 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0160060} /qn", 1, True
' Java(TM) 6 Update 5 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0160050} /qn", 1, True
' Java(TM) 6 Update 4 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0160040} /qn", 1, True
' Java(TM) 6 Update 3 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0160030} /qn", 1, True
' Java(TM) 6 Update 2 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0160020} /qn", 1, True
' Java(TM) 6 Update 1 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0160010} /qn", 1, True
' Java(TM) 6 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0160000} /qn", 1, True
' J2SE Runtime Environment 5.0 Update 12 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0150120} /qn", 1, True
' J2SE Runtime Environment 5.0 Update 11 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0150110} /qn", 1, True
' J2SE Runtime Environment 5.0 Update 10 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0150100} /qn", 1, True
' J2SE Runtime Environment 5.0 Update 9 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0150090} /qn", 1, True
' J2SE Runtime Environment 5.0 Update 6 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0150060} /qn", 1, True
' J2SE Runtime Environment 5.0 Update 4 removal.
objWshShell.Run "msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0150040} /qn", 1, True
wscript.quit
================================================================
Reinstall program:
Put this as your Command Line: jre-6u22-windows-i586-s.exe /quiet /norestart
There are other arguments you can pass too but I wanted quick and dirty to get these machines functional again.
Run whether a user is logged in or not and with administrative rights.
Run the uninstall first and always run it first.
Suppress program notifications.
And then advertise it.
This successfully pushed out Java 6 Update 22 to almost all of my machines. A friend of mine has published a script that does this more cleanly by first determining if the machine is x86 or x64. You can find that article and his SCCM MVP blog here: http://sms-hints-tricks.blogspot.com/2010/11/i-was-getting-tired-of-some-of-problems.html
This is my attempt to post things that I have encountered, found little or incomplete information for, and hope to be able to help others with. Topics will be Information Technology centric with most dealing with Microsoft System Center. The concept of a jumpbag is to contain all the things you need to survive most situations.
Tuesday, November 16, 2010
Exchange script in Task Scheduler
Want to run an Exchange script on a schedule? For example, the script I posted to remove all items in the Deleted Items folder that are more than 30 days old. If you are running an Exchange CCR, this should be done on a separate role from the mailbox nodes.
First you will have to add a line to the script so that it will know which domain controller to use. Add these lines below and replace FQDN with that of your own domain controller.
#Sets the Exchange Server to use a specific domain controller.
Set-ExchangeServer -DomainController FQDN
In Windows Server 2008, open the Task Scheduler and create a new task.
Give it a Name and Description
Set the user to run under which should probably be one with Exchange Admin rights.
Check Run whether user is logged on or not
Set your schedule on the Triggers tab such as when you want it to run.
For the Action select Start a Program
I created a batch file with this line. This will call Powershell with the Exchange extensions and then feed in the script we created for deleting items.
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command ". 'C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1'"; ". 'C:\Scripts\DeletedItems30Days.ps1'"
Program/script: Powershell.exe
Add arguments: -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\ExShell.Psc1" -Command ". 'C:\Scripts\DeletedItems30Days.ps1'"
Set any Conditions and Settings and press OK.
I get a nice little email every Friday evening with a list of all accounts, the number of items deleted and the amount of space removed from each account, then totals of each at the bottom.
First you will have to add a line to the script so that it will know which domain controller to use. Add these lines below and replace FQDN with that of your own domain controller.
#Sets the Exchange Server to use a specific domain controller.
Set-ExchangeServer -DomainController FQDN
In Windows Server 2008, open the Task Scheduler and create a new task.
Give it a Name and Description
Set the user to run under which should probably be one with Exchange Admin rights.
Check Run whether user is logged on or not
Set your schedule on the Triggers tab such as when you want it to run.
For the Action select Start a Program
I created a batch file with this line. This will call Powershell with the Exchange extensions and then feed in the script we created for deleting items.
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command ". 'C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1'"; ". 'C:\Scripts\DeletedItems30Days.ps1'"
Program/script: Powershell.exe
Add arguments: -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\ExShell.Psc1" -Command ". 'C:\Scripts\DeletedItems30Days.ps1'"
Set any Conditions and Settings and press OK.
I get a nice little email every Friday evening with a list of all accounts, the number of items deleted and the amount of space removed from each account, then totals of each at the bottom.
Tuesday, October 26, 2010
Exchange 2007 SP3 and Rollup 1 issues
Before you install Exchange 2007 Service Pack 3, read this first.
Service Pack 3 breaks S/MIME in OWA because of a version mismatch between the client mimectl.dll and the PropertyVersion on the MSI file owamime.msi on the CAS server. Here is Microsoft's technet article about it. http://blogs.technet.com/b/schadinio/archive/2010/07/10/exchange-2007-sp3-and-owa-s-mime-version-mismatch.aspx. And here is a link to the Exchange Team blog about the issue. http://msexchangeteam.com/archive/2010/07/09/455445.aspx?CommentPosted=true#commentmessage.
SP3 Rollup 1 fixes the S/MIME but breaks more. After installing Rollup 1, the Exchange Management Console (EMC) throws errors when trying to manage Exchange Cluster or the CAS server. The error message is:
Retrieving the COM class factory for remote component with CLSID
{2B72133B-3F5B-4602-8952-803546CE3344} from machine
failed due to the following error: 800706ba.
This error is related to dynamic RPC ports not being open on the firewall. I have read that you can create inbound firewall rules on each CCR node to resolve the error, but this did not work for me. Follow these steps to try that.
1. New inbound rule in the Windows Firewall with Advanced Security.
2. Rule Type: Custom
3. Program: All Programs
4. Protocol and Ports: type: "TCP"; Local port: "Dynamic RPC"; Remote ports: "All ports"
5. Scope: Any for both local and remote or you can try entering your specific IPs
6. Action: Allow connection
7. Profile: "Domain"
8. Name: Call it what you want like "Dynamic RPC Ports"
The other issue with SP3 seems to be related to backups. If you are using Microsoft Data Protection Manager 2007 for backups, log truncating on CCR nodes is broken. DPM still reports successful backups but log files are not truncated. I read a post where someone using BackupExec had a similar problem.
Rollup 1 supposedly fixes this but it was broken for me after the install of RU1. It wasn't until after I did the following workaround and then refreshed the Protection Group that the backups started truncating the logs again.
You can set the backup to run against the active node instead of the passive as a workaround.
http://social.technet.microsoft.com/Forums/en-US/exchangesvravailabilityandisasterrecovery/thread/2b5de9de-7c7e-4398-8793-8a6c397f2195
Service Pack 3 breaks S/MIME in OWA because of a version mismatch between the client mimectl.dll and the PropertyVersion on the MSI file owamime.msi on the CAS server. Here is Microsoft's technet article about it. http://blogs.technet.com/b/schadinio/archive/2010/07/10/exchange-2007-sp3-and-owa-s-mime-version-mismatch.aspx. And here is a link to the Exchange Team blog about the issue. http://msexchangeteam.com/archive/2010/07/09/455445.aspx?CommentPosted=true#commentmessage.
SP3 Rollup 1 fixes the S/MIME but breaks more. After installing Rollup 1, the Exchange Management Console (EMC) throws errors when trying to manage Exchange Cluster or the CAS server. The error message is:
Retrieving the COM class factory for remote component with CLSID
{2B72133B-3F5B-4602-8952-803546CE3344} from machine
failed due to the following error: 800706ba.
This error is related to dynamic RPC ports not being open on the firewall. I have read that you can create inbound firewall rules on each CCR node to resolve the error, but this did not work for me. Follow these steps to try that.
1. New inbound rule in the Windows Firewall with Advanced Security.
2. Rule Type: Custom
3. Program: All Programs
4. Protocol and Ports: type: "TCP"; Local port: "Dynamic RPC"; Remote ports: "All ports"
5. Scope: Any for both local and remote or you can try entering your specific IPs
6. Action: Allow connection
7. Profile: "Domain"
8. Name: Call it what you want like "Dynamic RPC Ports"
The other issue with SP3 seems to be related to backups. If you are using Microsoft Data Protection Manager 2007 for backups, log truncating on CCR nodes is broken. DPM still reports successful backups but log files are not truncated. I read a post where someone using BackupExec had a similar problem.
Rollup 1 supposedly fixes this but it was broken for me after the install of RU1. It wasn't until after I did the following workaround and then refreshed the Protection Group that the backups started truncating the logs again.
You can set the backup to run against the active node instead of the passive as a workaround.
http://social.technet.microsoft.com/Forums/en-US/exchangesvravailabilityandisasterrecovery/thread/2b5de9de-7c7e-4398-8793-8a6c397f2195
Wednesday, June 30, 2010
SCCM Queries for Software Collections - Copy and Paste These
Queries for collections of machines with different versions of Adobe Acrobat, Symantec Anti-Virus or Symantec Endpoint Protection, or Microsoft Office.
As of today (6/30/2010), Adobe doesn't support or update the full version of Acrobat or Reader less then version 8.
Adobe Acrobat 6 or less:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "Adobe Acrobat%" and SMS_G_System_ADD_REMOVE_PROGRAMS.Version < "7%"
Adobe Acrobat 7:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "Adobe Acrobat%" and SMS_G_System_ADD_REMOVE_PROGRAMS.Version >= "7%" and SMS_G_System_ADD_REMOVE_PROGRAMS.Version < "8%"
Adobe Acrobat 8:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "Adobe Acrobat%" and SMS_G_System_ADD_REMOVE_PROGRAMS.Version >= "8%" and SMS_G_System_ADD_REMOVE_PROGRAMS.Version < "9%"
Adobe Acrobat 9 (10 doesn't exist yet, so we can't put a <"10%":
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "Adobe Acrobat%" and SMS_G_System_ADD_REMOVE_PROGRAMS.Version >= "9%"
Symantec Anti-Virus or Symantec Endpoint Protection:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "symantec antivirus" or SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "symantec endpoint protection"
Microsoft Office 2003:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceId = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName = "Microsoft Office Professional Edition 2003" or SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName = "Microsoft Office Basic Edition 2003" or SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName = "Microsoft Office Standard Edition 2003"
Microsoft Office 2007:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceId = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName = "Microsoft Office Enterprise 2007"
Microsoft Office 2010 (I had problems getting it to take all of this as 1 rule, so there are 2. 1 for x86 and 1 for x64)
Rule 1: Office 2010 x86
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "Microsoft Office Professional Plus 2010"
Rule 2: Office 2010 x64
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS_64 on SMS_G_System_ADD_REMOVE_PROGRAMS_64.ResourceId = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS_64.DisplayName like "Microsoft Office Professional Plus 2010"
Friday, June 18, 2010
My Top Exchange 2007 Links
These are pages that I have found very useful and I believe that every Exchange admin should have bookmarked.
- Microsoft Technet: http://technet.microsoft.com/en-us/library/aa996058(EXCHG.80).aspx
- For certificates, I highly recommend DigiCert and their UC certs: https://www.digicert.com/easy-csr/exchange2007.htm, and http://www.digicert.com/ssl-certificate.htm
- The Microsoft Exchange Team Blog: http://msexchangeteam.com/
- MSExchange.org: http://blogs.msexchange.org/
- Computer Performance Exchange 2007: http://www.computerperformance.co.uk/exchange2007
- Exchange Non-Delivery Reports: http://www.computerperformance.co.uk/exchange2007/exchange2007_ndr.htm
- Performance Troubleshooting using the PAL tool: http://blogs.technet.com/b/mikelag/archive/2008/08/20/performance-troubleshooting-using-the-pal-tool.aspx
- Replacing the Exchange 2007 Self-Signed Certificate: http://www.exchangeinbox.com/article.aspx?i=127
Thursday, June 17, 2010
Exchange 2007 Management Shell Commands
I'll try to add to these over time as I remember and as I learn more. These are some of the Exchange 2007 Management Shell commands that I use and why. The blue words are the commands and the red words need to be replaced with your information.
When you see a Get-Mailbox, you can leave it alone and the command will get all mailboxes or you can add in switches such as -server, -database, or -identity to select smaller groups.
When you see a Get-Mailbox, you can leave it alone and the command will get all mailboxes or you can add in switches such as -server, -database, or -identity to select smaller groups.
1. Do a user who needs full access to all mailboxes, maybe for legal or audit reasons. Replace "useraccount" with the account of the person who needs full access. The second line removes the full access from all mailboxes for the specified user.
Get-Mailbox | Add-MailboxPermissions -AccessRights FullAccess -User useraccount
Get-Mailbox | Remove-MailboxPermissions -AccessRights FullAccess -User useraccount
2. Need to set set the MaxSendSize and MaxReceiveSize for all mailboxes at once. You can write the number out such as 20480 will be the same as 20MB. Or you can use KB, MB, GB, or TB at the end to shorten it.
Get-Mailbox | Add-MailboxPermissions -AccessRights FullAccess -User useraccount
Get-Mailbox | Remove-MailboxPermissions -AccessRights FullAccess -User useraccount
2. Need to set set the MaxSendSize and MaxReceiveSize for all mailboxes at once. You can write the number out such as 20480 will be the same as 20MB. Or you can use KB, MB, GB, or TB at the end to shorten it.
Get-Mailbox | Set-Mailbox -MaxSendSize 20MB
Get-Mailbox | Set-Mailbox -MaxReceiveSize 20MB
3. Run an Exchange CCR Cluster, type Get-Sto and hit tab twice to get to Get-StorageGroupCopyStatus and press enter to get a list of all of your storage groups and their copy status, copy and replay queue lengths, and last inspected log time. This is faster then opening the EMC and going to Server Configuration/Mailbox and give you a little more information.
4. Need mailbox statistics.
This will give you details stats on a single mailbox.
Get-MailboxStastics user |fl
This will give you the mailbox name, item count, storage limit status (if you have one), and last logon time for every mailbox in the specified database.
Get-MailboxStastics -database yourdatabase
Thursday, June 10, 2010
Exchange 2007 Script - 30 day old Deleted Items with email report
My current Exchange environment is a decentralized one where I maintain one configuration and others maintain their own. We do not have mailbox policies configured for the entire organization. So I wanted to remove any items in my users Deleted Items folders that are more than 30 days old and then be able to see how many items were removed and how much space this freed up. This use to be easy in Exchange 2003 with Mailbox Maintenance Policies.
After several days of learning Powershell scripting and trying so many different syntaxes, I finally have a working script. I can't say that I know much about Powershell but I definitely know a lot more than I did a week ago. This script will need to be modified to fit your environment but I added documentation on where to do that. You can copy the text below into your own text file and save it with the .ps1 extension. If you copy be sure to watch for line wrapping. Once you have made the few modifications for your environment you can set this to run on a schedule with Windows Task Scheduler.
#This Powershell script will go through every mailbox on your Exchange 2007 mailbox server and will delete
#all items in the Deleted Items folder that are more than 30 days old and then emails a report to you.
#You can set this with Windows Task Manager to run on a set schedule.
#Written by Brad Goodman
#Sets the $date variable to 30 days before today.
$date = Get-Date
$date = $date.AddDays(-30)
$date = $date.ToShortDateString()
#Sets the output file name.
$filename = "DeletedItems{0:MMddyyyy}" -f (Get-Date)
#Defines the output table.
$mbxcomb = "" | Select "Display Name", "Items Deleted", "Space Saved(KB)"
#Begins a transcipt and saves it in the Documents folder of the user running the script.
Start-transcript -Path $home\documents\$filename.txt
#Calls the mailboxes. You can set a -database or -server to be more specific after the Get-Mailbox.
#I suggest that you set the -server to your mailbox server if you don't manage all in your Exchange org.
Get-Mailbox -server "your mailbox server" | foreach {
$mbx = $_.DisplayName
$strmbxUser = $NULL
#Determine the initial size of the mailbox in KB.
$intSizeBefore = (Get-MailboxStatistics $mbx).TotalItemSize.Value.ToKB()
#Removes any items in the Deleted Items folder that are older than 30 days.
$strMbxUser = Export-Mailbox $mbx –includefolders “\Deleted Items” –StartDate “1/1/1995” –EndDate $date –DeleteContent -Confirm:$False
#Save the number of deleted items to the variable $intTotalDeleted.
$intTotalDeleted = $strmbxUser.StandardMessagesDeleted
#Gets the new size of the mailbox after deleting items and then finds the amount of space saved in KB.
$intSizeAfter = (Get-MailboxStatistics $mbx).TotalItemSize.Value.ToKB()
$intSpaceSaved = $intSizeBefore - $intSizeAfter
#Stores the specifics about each mailbox in the table.
$mbxcomb."Display Name" = $mbx
$mbxcomb."Items Deleted" = $intTotalDeleted
$mbxcomb."Space Saved(KB)" = $intSpaceSaved
#Creates totals of mailboxes processed, items deleted, and space saved through each iteration of the
#get-mailbox.
$intmbxTotal = $intmbxTotal + 1
$intmbxDeleted = $intmbxDeleted + $intTotalDeleted
$intmbxSaved = $intmbxSaved + $intSpaceSaved
#Outputs the table to the screen so that the transcript can capture it.
Write-output $mbxcomb
} #End of the Foreach loop.
#Outputs the totals for all mailboxes to the screen so the transcript can capture it.
Write-Host ("`n=======================================`n")
Write-Host ("Mailboxes Processed = $intmbxTotal")
Write-Host ("Total Items Deleted = $intmbxDeleted")
Write-Host ("Total Space Saved(KB) = $intmbxSaved")
Write-Host ("`n=======================================`n")
Stop-Transcript
$transcript = (Get-Content $home\documents\$filename.txt | Out-String)
#Emails transcript file. Replace smtphost, domain, user, password, sender, recipient with your own.
$SmtpClient = new-object system.net.mail.smtpClient
$smtpclient.Host = 'smtphost'
$Credentials = new-object System.Net.networkCredential
$Credentials.domain = "domain"
$Credentials.UserName = "user"
$Credentials.Password = "password"
$SMTPClient.Credentials = $Credentials
$smtpclient.Send('sender', 'recipient', "Exchange Deleted Items Report - {0:MM/dd/yyyy}" -f (Get-Date), $transcript)
After several days of learning Powershell scripting and trying so many different syntaxes, I finally have a working script. I can't say that I know much about Powershell but I definitely know a lot more than I did a week ago. This script will need to be modified to fit your environment but I added documentation on where to do that. You can copy the text below into your own text file and save it with the .ps1 extension. If you copy be sure to watch for line wrapping. Once you have made the few modifications for your environment you can set this to run on a schedule with Windows Task Scheduler.
#This Powershell script will go through every mailbox on your Exchange 2007 mailbox server and will delete
#all items in the Deleted Items folder that are more than 30 days old and then emails a report to you.
#You can set this with Windows Task Manager to run on a set schedule.
#Written by Brad Goodman
#Sets the $date variable to 30 days before today.
$date = Get-Date
$date = $date.AddDays(-30)
$date = $date.ToShortDateString()
#Sets the output file name.
$filename = "DeletedItems{0:MMddyyyy}" -f (Get-Date)
#Defines the output table.
$mbxcomb = "" | Select "Display Name", "Items Deleted", "Space Saved(KB)"
#Begins a transcipt and saves it in the Documents folder of the user running the script.
Start-transcript -Path $home\documents\$filename.txt
#Calls the mailboxes. You can set a -database or -server to be more specific after the Get-Mailbox.
#I suggest that you set the -server to your mailbox server if you don't manage all in your Exchange org.
Get-Mailbox -server "your mailbox server" | foreach {
$mbx = $_.DisplayName
$strmbxUser = $NULL
#Determine the initial size of the mailbox in KB.
$intSizeBefore = (Get-MailboxStatistics $mbx).TotalItemSize.Value.ToKB()
#Removes any items in the Deleted Items folder that are older than 30 days.
$strMbxUser = Export-Mailbox $mbx –includefolders “\Deleted Items” –StartDate “1/1/1995” –EndDate $date –DeleteContent -Confirm:$False
#Save the number of deleted items to the variable $intTotalDeleted.
$intTotalDeleted = $strmbxUser.StandardMessagesDeleted
#Gets the new size of the mailbox after deleting items and then finds the amount of space saved in KB.
$intSizeAfter = (Get-MailboxStatistics $mbx).TotalItemSize.Value.ToKB()
$intSpaceSaved = $intSizeBefore - $intSizeAfter
#Stores the specifics about each mailbox in the table.
$mbxcomb."Display Name" = $mbx
$mbxcomb."Items Deleted" = $intTotalDeleted
$mbxcomb."Space Saved(KB)" = $intSpaceSaved
#Creates totals of mailboxes processed, items deleted, and space saved through each iteration of the
#get-mailbox.
$intmbxTotal = $intmbxTotal + 1
$intmbxDeleted = $intmbxDeleted + $intTotalDeleted
$intmbxSaved = $intmbxSaved + $intSpaceSaved
#Outputs the table to the screen so that the transcript can capture it.
Write-output $mbxcomb
} #End of the Foreach loop.
#Outputs the totals for all mailboxes to the screen so the transcript can capture it.
Write-Host ("`n=======================================`n")
Write-Host ("Mailboxes Processed = $intmbxTotal")
Write-Host ("Total Items Deleted = $intmbxDeleted")
Write-Host ("Total Space Saved(KB) = $intmbxSaved")
Write-Host ("`n=======================================`n")
Stop-Transcript
$transcript = (Get-Content $home\documents\$filename.txt | Out-String)
#Emails transcript file. Replace smtphost, domain, user, password, sender, recipient with your own.
$SmtpClient = new-object system.net.mail.smtpClient
$smtpclient.Host = 'smtphost'
$Credentials = new-object System.Net.networkCredential
$Credentials.domain = "domain"
$Credentials.UserName = "user"
$Credentials.Password = "password"
$SMTPClient.Credentials = $Credentials
$smtpclient.Send('sender', 'recipient', "Exchange Deleted Items Report - {0:MM/dd/yyyy}" -f (Get-Date), $transcript)
Thursday, May 27, 2010
How to completely remove SQL 2005 for DPM reinstall.
This is specifically for Windows Server 2008 Enterprise 64bit with Microsoft Data Protection Manager 2007 and SQL 2005 SP2 but I see no reason why it wouldn’t work on any version of Windows Server, with or without DPM and for probably any service pack level of SQL 2005. This will remove all databases and config and put you back to ground zero. Be sure to have backups if necessary first.
Ever try to uninstall Microsoft Data Protection Manager with SQL 2005 on the same machine and then reinstall it? It doesn’t work very well mostly because SQL Reporting Services doesn’t completely uninstall. The reinstallation of DPM won’t get past the prerequisite check. Even though you may have uninstalled SQL from Add/Remove Programs, not everything is gone. References to the MS$DPM2007$ database are still present, mostly in the registry.
After countless hours of research and trying all kinds of methods I finally found a way to do it. I took pieces from several different forums and guides and came up with a solution.
I was trying to pull the old database back in but it was too corrupt and would crash the system each time. So I got plenty of practice with this complete uninstall method and it worked every time. The official instructions from Microsoft to uninstall SQL 2005 Manually (http://technet.microsoft.com/en-us/library/bb418915.aspx) is difficult to follow and the way I describe is easier and more complete. This method worked for me because I wanted to go back to zero to start again. If you are not trying to do the same, I suggest you find another way. Follow these directions at your own risk.
Step 1. Backup what you want to keep first. Then stop all SQL component and DPM services in services.msc.
Step 2. Uninstall from Add/Remove Programs. DPM always uninstalled fairly well from Add/Remove programs. SQL usually uninstalled but not close to completely. If one of the SQL components won't uninstall, don't worry we will remove it all through the registry. Restart after this step.
Step 3. Delete the DPM and SQL folders from wherever you installed them to. Usually at:
C:\Program Files\Microsoft DPM
C:\Program Files\Microsoft SQL Server
C:\Program Files (x86)\Microsoft SQL Server
Step 4. Open IIS Manager and under the Default Web Site, remove both Reports and ReportServer directories. Then go up to Application Pools and remove the ReportServer app pool.
Step 5. ****Warning: editing the registry is dangerous**** Some of this taken from Gilham Consulting wesite (http://www.gilham.org/Blog/Lists/Posts/Post.aspx?List=aab85845-88d2-4091-8088-a6bbce0a4304&ID=190).
Time to open Regedit.exe and delete some keys. Remove the following keys if they are still present:
HKLM\SYSTEM\CurrentControlSet\Services\MSSQLInstanceName$
HKLM\SYSTEM\CurrentControlSet\Services\MSRS 2005 Web Service
HKLM\SYSTEM\CurrentControlSet\Services\MSRS 2005 Windows Service
HKLM\SYSTEM\CurrentControlSet\Services\ReportServerInstanceName$
HKLM\SYSTEM\CurrentControlSet\Services\SQLAgent$InstanceName$
HKLM\SYSTEM\CurrentControlSet\Services\SQLBrowser
HKLM\SYSTEM\CurrentControlSet\Services\SQLWriter
HKLM\SOFTWARE\Microsoft\Microsoft SQL Native Client
HKLM\SOFTWARE\Microsoft\Microsoft SQL Server
HKLM\SOFTWARE\Microsoft\Microsoft SQL Server 2005 Redist
HKLM\SOFTWARE\Microsoft\MSSQLServer
HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Native Client
HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server
HKLM\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer
Step 6. Do a search in regedit for the InstanceName$ of your SQL instance if you know what it is. If this is a Microsoft DPM server, your instance name will be MS$DPM2007$. If you find one and it is a value, not a key, press ctrl+tab to move to the key and then delete the whole key. If they are under LEGACY keys you won't be able to delete them and they are fine. There may be 4 or 5. Close out of regedit.
Step 7. Download and install Little Registry Cleaner (http://sourceforge.net/projects/littlecleaner/). Open this little app and let it scan the registry. It will find several leftovers. You can look through and select or de-select the ones you want. These are broken links that it finds and it should be safe to remove them all. Press the Fix button to have them removed. Restart the server.
Step 8. Your server is now free of SQL and you can begin installing again. DPM will make it past the pre-reqs for SQL now and as long as there aren't other issues not covered by this post, you should be able to reinstall DPM now.
Reference links:
http://www.gilham.org/Blog/Lists/Posts/Post.aspx?List=aab85845-88d2-4091-8088-a6bbce0a4304&ID=190
http://support.microsoft.com/kb/909967
Step 2. Uninstall from Add/Remove Programs. DPM always uninstalled fairly well from Add/Remove programs. SQL usually uninstalled but not close to completely. If one of the SQL components won't uninstall, don't worry we will remove it all through the registry. Restart after this step.
Step 3. Delete the DPM and SQL folders from wherever you installed them to. Usually at:
C:\Program Files\Microsoft DPM
C:\Program Files\Microsoft SQL Server
C:\Program Files (x86)\Microsoft SQL Server
Step 4. Open IIS Manager and under the Default Web Site, remove both Reports and ReportServer directories. Then go up to Application Pools and remove the ReportServer app pool.
Step 5. ****Warning: editing the registry is dangerous**** Some of this taken from Gilham Consulting wesite (http://www.gilham.org/Blog/Lists/Posts/Post.aspx?List=aab85845-88d2-4091-8088-a6bbce0a4304&ID=190).
Time to open Regedit.exe and delete some keys. Remove the following keys if they are still present:
HKLM\SYSTEM\CurrentControlSet\Services\MSSQLInstanceName$
HKLM\SYSTEM\CurrentControlSet\Services\MSRS 2005 Web Service
HKLM\SYSTEM\CurrentControlSet\Services\MSRS 2005 Windows Service
HKLM\SYSTEM\CurrentControlSet\Services\ReportServerInstanceName$
HKLM\SYSTEM\CurrentControlSet\Services\SQLAgent$InstanceName$
HKLM\SYSTEM\CurrentControlSet\Services\SQLBrowser
HKLM\SYSTEM\CurrentControlSet\Services\SQLWriter
HKLM\SOFTWARE\Microsoft\Microsoft SQL Native Client
HKLM\SOFTWARE\Microsoft\Microsoft SQL Server
HKLM\SOFTWARE\Microsoft\Microsoft SQL Server 2005 Redist
HKLM\SOFTWARE\Microsoft\MSSQLServer
HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Native Client
HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server
HKLM\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer
Step 6. Do a search in regedit for the InstanceName$ of your SQL instance if you know what it is. If this is a Microsoft DPM server, your instance name will be MS$DPM2007$. If you find one and it is a value, not a key, press ctrl+tab to move to the key and then delete the whole key. If they are under LEGACY keys you won't be able to delete them and they are fine. There may be 4 or 5. Close out of regedit.
Step 7. Download and install Little Registry Cleaner (http://sourceforge.net/projects/littlecleaner/). Open this little app and let it scan the registry. It will find several leftovers. You can look through and select or de-select the ones you want. These are broken links that it finds and it should be safe to remove them all. Press the Fix button to have them removed. Restart the server.
Step 8. Your server is now free of SQL and you can begin installing again. DPM will make it past the pre-reqs for SQL now and as long as there aren't other issues not covered by this post, you should be able to reinstall DPM now.
Reference links:
http://www.gilham.org/Blog/Lists/Posts/Post.aspx?List=aab85845-88d2-4091-8088-a6bbce0a4304&ID=190
http://support.microsoft.com/kb/909967
Exchange 2007 - Administratively set mailbox send and receive size limits
These commands can be used in the Exchange Management Shell to set the MaxSendSize and MaxReceiveSize for all mailboxes at once. If you use a number like 20480, that will set it as KB. Or you can use MB at the end to shorten it.
get-mailbox | set-mailbox -MaxSendSize 20MB
get-mailbox | set-mailbox -MaxReceiveSize 20MB
One or more users cannot be added to the folder access list. Non-local users cannot be given rights on this server.
Exchange 2007
If you are trying to add a mail-enabled distribution or security group to a resource such as a shared calendar or task list and you may get the error "One or more users cannot be added to the folder access list. Non-local users cannot be given rights on this server."
If you can't do it from within that shared resource mailbox you may be able to do it from a regular user mailbox that has full access to that shared resource mailbox. Then in Outlook with that user mailbox go to Tools, Account Settings, Change, More Settings, Advanced tab, and add that resource mailbox. Click Ok, Next and Close out. Now you have access to that mailbox on the left column of Outlook.
Open the Folder view so you can see all the folder and then right click on Tasks or Calendar or the folder you want to add permissions to. Go to Properties and the Permissions tab. Now you should be able to add your mail-enabled distribution or security group to this resource.
If you are trying to add a mail-enabled distribution or security group to a resource such as a shared calendar or task list and you may get the error "One or more users cannot be added to the folder access list. Non-local users cannot be given rights on this server."
If you can't do it from within that shared resource mailbox you may be able to do it from a regular user mailbox that has full access to that shared resource mailbox. Then in Outlook with that user mailbox go to Tools, Account Settings, Change, More Settings, Advanced tab, and add that resource mailbox. Click Ok, Next and Close out. Now you have access to that mailbox on the left column of Outlook.
Open the Folder view so you can see all the folder and then right click on Tasks or Calendar or the folder you want to add permissions to. Go to Properties and the Permissions tab. Now you should be able to add your mail-enabled distribution or security group to this resource.
Subscribe to:
Posts (Atom)