Friday, March 27, 2015

Configure exchange DAG server in DR to not auto activate

If you have a DAG server in a DR site and you don't want the databases to automount in the event of a failover set the server to intrasite only.

Set-MailboxServer -Identity EXDR01 -DatabaseCopyAutoActivationPolicy IntrasiteOnly 

To confirm this, run 
Get-MailboxServer EXDR01 | Select DatabaseCopyAutoActivationPolicy

You should be told the server auto activation is set to Intrasite only.

To set it back to auto run 
Set-MailboxServer EXDR01 -DatabaseCopyAutoActivationPolicy Unrestricted

If you re-run the get command you will now see it is set to unrestricted.


Wednesday, March 25, 2015

Exchange DAG getting split?

I had an incident where the DAG was telling me all my servers were offline.  I was not able to mount or move any databases.  I ended up running these commands:

From each DAG member run
net stop clussvc
then cluster (dagname) node /forcecleanup

After the cleanup is complete on each dag member remove the nodes from cluster manager.

After that you need to re-add the servers back to the DAG

Start-DatabaseAvailabilityGroup -identity (dagname) -mailboxserver (servername)

after that the databases should mount and come back online.

Tuesday, March 10, 2015

SQL Backdoor

An actual backdoor into SQL Server does exist that does not require restarting and/or rebooting anything into single-user mode. I have done this on systems where I did not have access but needed to check stuff.

Download PSexec tools from here. Place this on the server and then in a command prompt execute this command:psexec -i -s SSMS.exe, or sqlwb.exe

This will open up SSMS as the system account that has sysadmin access to the instance of SQL Server. This is done during installation of SQL Server, however I have heard that this will not be so with SQL 2012.

Script to unexpire/expire a password

Running this expires a password allowing a logged on user to change their password if you have domain requirements needing a certain number of days between password changes.

$User = Get-ADUser user.name -properties pwdlastset
$user.pwdlastset = 0
Set-ADUser -instance $user

If a user has had their password expire, this script will unexpire it:

$User = Get-ADUser user.name -properties pwdlastset
$user.pwdlastset = -1
Set-ADUser -instance $user

This is handy if your domain security requires you to wait a day between password changes.  So if your user forgets their password and you change it, normally they would need to wait a day to change it again.  Instead run the script with the "0" setting once they are logged on and they can change their password.

Wednesday, March 4, 2015

Script to dump IIS logs from exchange

Running this will delete files older than 7 days:
You may also need to run it against w3svc2 as well

forfiles /p "C:\inetpub\logs\LogFiles\W3svc1" /s /m *.* /c "cmd /c Del @path" /d -7

Monday, August 11, 2014

Exchange 2013 drive space alert

You may get this alert:
The performance counter '\\exchange server\LogicalDisk(Datebase)\Free Megabytes' sustained a value of '7,027.00', for the '15' minute(s) interval starting at '8/11/2014 3:48:00 PM'. Additional information: None. Trigger Name:DatabaseDriveSpaceTrigger. Instance:Database

You can disable these alerts, edit the config file:

C:\Program Files\Microsoft\ExchangeServer\V15\Bin\Microsoft.Exchange.Diagnostics.Service.exe (config file)

Change "xchangeJobs.Triggers.DatabaseDriveSpaceTrigger" from "True" to "False".

Friday, August 8, 2014

Exchange 2013 anonymous relay IMPORTANT TIP

If you are running exchange 2013 and need to setup an anonymous relay make sure you choose FRONT END TRANSPORT, not hub transport.  There is an issue with port 25 being used by another transport and it will cause the front end transport service to not start and fill up your event log.  You create the connector the same the rest of the way including the powershell script.

Friday, May 30, 2014

Manually remove trend if it has a password!

start windows in secure mode and change the ofcscan.ini in client intallation path
search for "UninstallPwd" and change the password to:

!CRYPT!523D617DF57CBF0E9ACD37611537EBB612F9B6F1C471EB529B89772E71AD9D2431BC212ACF23B7767831E317364
then the uninstall password will be "test"

Friday, April 25, 2014

Disable windows offline files:

Local Computer Policy\Computer Configuration\Administrative Templates\Network\Offline Files
Change the following:
Allow or disallow use of offline files feature: Disabled
Prohibit user config: Enabled
Sync all offline files when logging on: Disabled
Sync all offline files when logging off: Disabled
Sync offline files before suspend: Disabled
Remove ‘Make offline’: Enabled
Prevent use of Offline Files folder: Enabled

Wednesday, April 16, 2014

Script to delete vmware snapshots, batch file to run as a scheduled task

Run this from power shell to delete your snapshots:

Connect-VIServer vsphereserver

Get-vm "guest vm" | get-snapshot | Remove-Snapshot -confirm:$false

save it as something .ps1

Batch file:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -psc "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -c ". \"C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-VIToolkitEnvironment.ps1\";C:\vmwarescript\yourpowershellscript"


Machine running this will need VMWare powercli installed.  

If your user is not an admin that will be running the script as a scheduled task it will need logon as batch job and service rights and explicit rights to the CMD.exe file in C:\windows\system32.

Thursday, April 10, 2014

Office 2013 tweaks

Keep office from trying to connect to the internet with this registry key:

HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Common\Internet\useOnlineContent

Set Dword to 0

Have Office go directly to a document screen and pass the annoying startup page:
HKEY_CURRENT_USER\Software\MicrosoftOffice\15.0\ommon\General
Create a DWord of DisableBootToOfficeStart
Set DWord to 1

Friday, February 7, 2014

If you move mailboxes and they don't remove here is a cleanup command

set the keep deleted mailbox retention period to 0, run clean-mailboxdatabase "databasename" to remove the disconnected mailboxes. 

Monday, January 6, 2014

Clear log files for exchange if your out of disk space

Dismount any databases, or if the database won't mount because the disk is full.  If the database won't mount, check and make sure it is in a clean shutdown state:

eseutil /MH "Database Location and Name"

Make sure it reports "clean shutdown" or "consistent"

MOVE the log files to somewhere you have space and remount the database.

Friday, January 3, 2014

Users redirectored folders show as My Documents in the folders

If you are redirecting folders to a server share and the folders all show as "My Documents" this could be due to the desktop.ini in the root of the users folder.  If the administrators or domain admin group has full control, set them to deny read.  Make sure the user is the owner of the folder as well.

Friday, December 27, 2013

Use PSEXEC to run a command against a list of machines and have it run a command from the machine

Start by creating a list of computers that need the command run on them (pclist.txt.).  Use the file copy command for /f %a in (pclist.txt) do copy /y \\server\share\file.bat \\%a\c$\ to copy the files to the machines in the pclist.txt.  In this example the file is copied to the root.  Next, from an elevated command prompt run:
psexec @pclist.txt c:\file.bat

This will execute the batch or exe file you copied to the remote machine on the remote machine. 
If you need to authenticate run:
psexec @pclist.txt -u domain\user c:\file.bat and it will prompt for a password.



copy files to multiple remote computers

To copy a file to multiple computers first create a txt file with all the computer names in it.  Place the file you want to copy in an accessible location for all the machines.  Run the following command:

for /f %a in (pclist.txt) do copy /y \\server\share\file.txt \\%a\c$\

This "should" copy the file to the machines listed assuming you have remote access.

Thursday, December 19, 2013

Exchange dynamic distribution groups based on security groups.

To create an exchange dynamic distribution group based on security group this can be done through powershell. The command specifies where to create the dynamic distribution group and what group the users will be a member of to pull the addresses from. The group name is “Dyn_universal” the security group is dyn_test, so any user in the OU test that is a member of dyn_test will get mail sent to the distribution group. New-DynamicDistributionGroup "Dyn_universal" -Alias "Dyn_universal" -OrganizationalUnit "OU=Test,DC=mydomain,DC=local" -RecipientFilter "MemberOfGroup -eq 'CN=dyn_test,OU=test,DC=mydomain,DC=local'"

Tuesday, November 5, 2013

Unable to send pictures from phones through exchange

With the following command you can change the value (in this case 10MB): C:\Windows\System32\inetsrv\appcmd.exe set config -section:system.webServer/serverRuntime /uploadReadAheadSize:"10485760" /commit:apphost C:\Windows\System32\inetsrv\appcmd.exe set config "Default Web Site" -section:system.webServer/serverRuntime /uploadReadAheadSize:"10485760" /commit:apphost restart IISAdmin service.....

Tuesday, September 17, 2013

Remove .local from exchange web settings

1.Start the Exchange Management Shell. 2.Modify the Autodiscover URL in the Service Connection Point. The Service Connection Point is stored in the Active Directory directory service. To modify this URL, type the following command and then press ENTER: Set-ClientAccessServer -Identity CAS_Server_Name -AutodiscoverServiceInternalUri https://mail.contoso.com/autodiscover/autodiscover.xml 3.Modify the InternalUrl attribute of the EWS. To do this, type the following command, and then press ENTER: Set-WebServicesVirtualDirectory -Identity "CAS_Server_Name\EWS (Default Web Site)" -InternalUrl https://mail.contoso.com/ews/exchange.asmx 4.Modify the InternalUrl attribute for Web-based Offline Address Book distribution. To do this, type the following command, and then press ENTER: Set-OABVirtualDirectory -Identity "CAS_Server_name\oab (Default Web Site)" -InternalUrl https://mail.contoso.com/oab 5.Open IIS Manager. 6.Expand the local computer, and then expand Application Pools. 7.Right-click MSExchangeAutodiscoverAppPool, and then click Recycle.

Wednesday, August 28, 2013

Exchange 2010 bug not removing mailboxes after migration to an new database

While moving mailboxes from one database to another the move request finishes with a warning: Warning: Failed to clean up the source mailbox after the move. Error details: MapiExceptionUnexpectedMailboxState: Unable to delete mailbox. (hr=0x80004005, ec=2634) You will see the mailbox is disconnected but won't delete. To remove the mailbox use exchange powershell and enter these commands: $aa=Get-MailboxStatistics -Database Mailbox database name| where {$_.DisconnectReason -eq “SoftDeleted”} $aa | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted}