Tag Archives: command

Localhost on Mac is taking long time to resolve

If you are using Mac OS X with MAMP (Mac Apache MySQL PHP) installed in your OS and you are still scratching your head asking why “localhost” or MAMP starting page “localhost/mamp” is taking ages to load. Yes, you are having the same problem that i had previously.

First of all, please make sure your “locahost” is not incorrectly mapped in your hosts file.

  1. Kindly open Terminal (or you can hit Command + Shift + U then double click on Terminal)
  2. enter command “sudo nano /private/etc/hosts” and enter your admin password.
  3. Ensure the following entries in your file. No duplicate of localhost broadcasthost
    ::1 localhost
    fe80::1%lo0 localhost
  4. Control + O, Control + M and Control + X to save and exit the file

If your hosts file is correct. Please check your Activity Monitor for any suspicious running backend process. (You can find the Activity Monitor in Utilities Command + Shift + U)

In my case, there is this “mdworker” process which was taking high %CPU!

After googling of this mdworker (here), this is actually a ‘metadata server worker’ used as search engine for Spotlight. In the referenced article, it is shared that this process will search into your external hard drive and apparently I just had my 1TB external hard drive plugged into my MBA! And it is also running Time Machine Backup job.

For those who don’t really need their external hard drive to be indexed in Spotlight, you can actually exclude this mdworker from crawling your external hard drive


  1. Simply go to System  > Spotlight
  2. Under Privacy tab, click Add button to include all your external hard drive partition into the “Prevent” list.

Mac OS Localhost slow   Woah la~

And if you do not wish to exclude your external hard drive from indexing. All you can do is to wait until the indexing is completed. :(

Set multiple SQL databases Recovery MODE to Simple

It is always handy to have an automated script to perform task for you. Manual click vis SSMS could be tedious and prone to error.

I came out with a simple SQL which allow me to set recovery mode of all database in one instance to Simple or Full.

DECLARE @name varchar(255),@sql varchar (500)
SELECT name FROM sys.databases where name not in (‘master’,’tempdb’,’model’,’msdb’)

OPEN databases

— Perform the first fetch.
INTO @name
— Check @@FETCH_STATUS to see if there are any more rows to fetch.
— This is executed as long as the previous fetch succeeds.
SET @sql =
‘USE [‘+@name+’];
+ ‘DBCC SHRINKFILE([‘+@name+’_log], 1)’
print @sql
INTO @name

CLOSE databases
DEALLOCATE databases


Note that if you are doing Log Shipping, you need to use FULL recovery mode or Bulk-logged

How to grant Local Administrator rights

The following steps show you how to grant a domain user or local user with Local Administrator rights.
  1. Logon to the machine/server that you want to grant Local Administrator right to.
  2. Open “Run” from the Start Menu. Or alternatively hit [Windows + R] key
  3. enter “dsa.msc” (if you are in a Domain Controller machine) or “lusrmgr.msc” (for any other machine)
  4. Navigate to your domain (if DC) and then to “Built in”
  5. Double click on the Administrator group.
  6. Go to “Members” tab and click “Add” button
  7. Assign the account that you want to grant access with.
  8. Click Ok to complete

How to Assign Local Administrator Right

How to find your SharePoint Farm Account

Surprisingly, if you are new to SharePoint, you may be confused by the fancy terminology such as, SharePoint Setup Account, SharePoint Database Access Account, SharePoint Central App Pool account bla bla..

In usual case (if you did follow Technet properly), your SharePoint Farm Account would be the same as y our SharePoint Database Access Account.

So how do you know which account you have setup as SharePoint Farm Account (though it may sound silly to ask your self this question)? or maybe to check on other’s existing SharePoint farm? You can try the following

Approach 1

  1. Go to your SharePoint Central Administration (CA) page. (or you may fire up a CMD run with Administrator and execute the following)
    "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\BIN\psconfigui.exe" -cmd showcentraladmin
  2. Go to “Security” > “Configure Service Accounts”. (or you may directly hit the relative path from your CA ‘/_admin/FarmCredentialManagement.aspx’)
  3. In the Drop Down list, select Farm Account
  4. Your SharePoint Farm Account will be shown. In my case, it is “SP2013\spfarm”

How to find my SharePoint Farm Account

Approach 2

  1. Go to “Services”. (or fire up Run – [Windows + R] key and enter “services.msc”)
  2. Look up to “SharePoint Timer Services” and check the value in “Log on as” column.
  3. The account running SharePoint Timer Services is always the SharePoint Farm Account.

Approach 3

(if only you have access to the Active Directory)

  1. Go to “Active Directory Users and Computers”. (or you may fire up Run – [Windows + R] key and enter “dsa.msc”)
  2. Navigate to Your Domain  > Users
  3. Double click on “WSS_ADMIN_WPG” group.
  4. Click on “Members” tab
  5. If you setup the Farm base on Technet guide, you shall see 2 accounts added into this group. One of them is SharePoint Setup Account and another one should be the SharePoint Farm Account.

How to find your SharePoint Farm Account

Adding Powershell Script inside XML

At times, you will require to read your data in XML format using Powershell Script. Possible reason to do that is such that you can amend the XML file without editing your original Powershell Script. That’s provided that the standardized Powershell Script can fulfill your requirements.

To cater for More flexibility, you can actually insert Powershell Script within your XML. Here is how you can perform that.

Note that this required a minor change in your Powershell Script. (Not to worry, you only need to edit this once and for all).

$xml = (Get-Content .\yourxml.xml)

$expression = $xml.Scripts.script

#Optionally you can put a foreach loop to run each of your script

Invoke-Expression $expression

Below is the simple xml of mine

 <script>   Write-Host "Halo";   Write-Host "Testing";
The output looks like this
Adding Powershell script into XML

STSADM taking so long time to run – SLOW!

If yours is Intranet SharePoint Application, this is a very common issue “SLOW stsadm command”!!! Yes, you may not need to bother about this if you are not using it frequently. BUT,  if you have thousand lines of stsadm command you need to execute (such as migrating users from SharePoint 2007 to SharePoint 2010, installing/uninstalling solution packages), this could be an ass painful process.

Despite trying the following article http://dirkvandenberghe.com/2009/01/08/speed-up-sharepoint-spin-up-and-stsadm-execution-time-by-jeroen-ritmeijer.html, the slowness still persist

One thing that i notice from my previous project experience is that this issue will only happen when there is no internet connection in your Share Point server. You can try to enable internet access though. However, most of the cases,  you wont get the privilege to do so as this could be a security breach or the policy merely doesn’t allow you.

Nevertheless, the following modification could actually solve the slowness prooblem.


Navigate to .NET Framework folder C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG  and look for machine.config file. (Note that the Location may be different if your server is running on 32 bit)

Look for the following section. (You might want to do a backup before making any changes)



Change to


<generatePublisherEvidence enabled="false"/>


Save the file and try STSADM now!