This post is based off of the CRM2011 SDK. If you do not have a Windows Live DeviceID and Device Password, you will need to build and run CreateCRM2011Device. After running, it creates an XML file in C:\Users\your_username\LiveDeviceID called LiveDevice.XML that contains your DeviceID and Device Password. You should first check to see if you have this file if you are unsure of whether or not you have a DeviceID and Password. Also, you will need to install WIF.
After you have created your DeviceID and Password, I recommend creating "CrmSvcUtil.exe.config" containing:
<add key="deviceid" value="your_Device_ID" />
<add key="devicepassword" value="your_Device_Password" />
<trace autoflush="false" indentsize="4">
<filter type="System.Diagnostics.EventTypeFilter" initializeData="Error" />
This config file will hold your DeviceID and Password and enable tracing for easier troubleshooting, should any errors occur.
If you try to run CrmSvcUtil the way the SDK shows, it will not work. There are switches that the SDK says to use that are not valid, they should be removed: /disco /partner /env /org. The only switches that willbe needed to accomplish the task at hand are /url /out /username and /password. With that in mind, your command should look like:
CrmSvcUtil.exe /out:Code.cs /url:https://Your_CRMOnline_URL/XRMServices/2011/Organization.svc "/username:Windows_Live_Username" "/password:Windows_Live_Password"
NOTE: The url MUST look exactly as above. It cannot end with "/" or "/$metadata" and should not be OrganizationData.svc