Monday, 16 July 2012

JAVA SCRIPT: SharePoint Get Current User



JAVA SCRIPT: SharePoint Get Current User 


Use following Java Script

<script language="javascript" type="text/javascript">
_spBodyOnLoadFunctionNames.push("GetCurrentUserName");
function GetCurrentUserName()
{
var Loginname = document.getElementById("zz8_Menu").innerHTML ;
var end = Loginname.indexOf("<");
var nameOnly = Loginname.substring(8, end);
alert(nameOnly);
}
</script>

Cheers :)

JQUERY: SharePoint 2010 Get Current User for web application


JQUERY: SharePoint 2010 Get Current User for web application

·         Download the latest jquery.js from SPServices Jquery.
·         Most releases of the library include both a minified and a normal version of the release. If you would like to understand the workings of the library, look at the normal version, but use the minified version for any production use.
·         Upload the minnified js file to the style library of your site.

The library can be implemented by adding a reference to it into a single page, a page layout, a content query web part or a master page, depending upon your desired scope of use

I recommend storing the jQuery library and SPServices in a Document Library in your Site Collection and referencing it as needed, like this:

<script language="javascript" type="text/javascript" src="/jQueryLibrary/ jquery.SPServices-0.7.1a.min.js"></script>

<script language="javascript" type="text/javascript" src="/jQueryLibrary/ jquery.SPServices-0.7.1a.min.js"></script>

Obviously, the src attributes should point to wherever you've put the .js files.

·         Add the following code
$().SPServices.SPGetCurrentUser({ fieldName: "Name", debug: false });

This is a quick script to check if everything is working OK:
<script type="text/javascript">
alert ("js on.");
$(document).ready(function() {
alert ('jQuery on.');
var theuser= $().SPServices.SPGetCurrentUser();
alert ('Current user for web application is : ' + theuser);
});
</script>

Cheers :)

Sunday, 15 July 2012

Basic PowerShell Commands


·       Get-Help


The first PowerShell cmdlet should learn is Get-Help. You can use this command to get help with any other command.
For example, if you want to know how the Get-Process command works, you can type:
Get-Help -Name Get-Process
And Windows will display the full command syntax.
You can also use Get-Help with individual nouns and verbs.
For example, to find out all the commands you can use with the Get verb, type:

Get-Help -Name Get-*

·       Get-Service

The Get-Service command provides a list of all of the services that are installed on the system. If you are interested in a specific service you can append the -Name switch and the name of the service (wildcards are permitted) When you do, Windows will show you the service’s state.

·       ConvertTo-HTML

PowerShell can provide a wealth of information about the system, but sometimes you need to do more than just view the information onscreen. Sometimes, it’s helpful to create a report you can send to someone. One way of accomplishing this is by using the ConvertTo-HTML command.
To use this command, simply pipe the output from another command into the ConvertTo-HTML command. You will have to use the -Property switch to control which output properties are included in the HTML file and you will have to provide a filename.
You want to create an HTML report that lists the name of each service along with its status (regardless of whether the service is running). To do so, you could use the following command:
Get-Service | ConvertTo-HTML -Property Name, Status > C:\services.htm

·       Export-CSV

Just as you can create an HTML report based on PowerShell data, you can also export data from PowerShell into a CSV file that you can open using Microsoft Excel. The syntax is similar to that of converting a command’s output to HTML. At a minimum, you must provide an output filename. For example, to export the list of system services to a CSV file, you could use the following command:
Get-Service | Export-CSV c:\services.csv

·       Select-Object

If you tried using the command above, you know that there were numerous properties included in the CSV file. It’s often helpful to narrow things down by including only the properties you are really interested in. This is where the Select-Object command comes into play. 
The Select-Object command allows to specify specific properties for inclusion. For example, to create a CSV file containing the name of each system service and its status, you could use the following command:
Get-Service | Select-Object Name, Status | Export-CSV c:\services.csv

·       Get-Process

Just as you can use the Get-Service command to display a list of all of the system services, you can use the Get-Process command to display a list of all of the processes that are currently running on the system.

·       Stop-Process

Sometimes, a process will HANG. When this happens, you can use the Get-Process command to get the name or the process ID for the process that has stopped responding. You can then terminate the process by using the Stop-Process command. Terminate a process based on its name or on its process ID. For example, Terminate WINWORD by using one of the following commands:
Stop-Process -Name winword
Stop-Process -ID xxxx
Keep in mind that the process ID may change from session to session.
Cheers :)

PowerShell Commands


PowerShell commands to obtain critical system information

·       Determine screen resolution

When a software package requires a certain resolution or minimum resolution, you can query the local computer to return the resolution of the primary monitor. Multiple monitors are not supported in this command.

Get-DisplaySetting

Couple the command with a variable to determine the computer’s name and export it to a local (or central file):

               $NetBIOSName = gc env:computername
               Get-DisplaySetting > C:\$NetBIOSName.txt

·      Enumerate USB devices

Get-USB -Computername System.FullyQualified.Domain
you can run this command against remote systems natively. Running the command with the -computername variable will connect the command to a remote system and return the same results as if it were executing locally.

·   Processor information

Get-processor

Cheers :)

Visual Representation of SQL Joins:A picture is worth a thousand words

A picture is worth a thousand words


Easiest way to understand SQL JOINS

Thursday, 12 July 2012

Get month and year from a datetime in SQL

Today's Learning:

How to get the current Date and Time in SQL
  Use follwoing SELECT command in SQL

SELECT GETDATE() AS DATE.

Below is output

How to get the MONTH value from GETDATE()
   Use following SELECT command in SQL

SELECT DATEPART (MONTH,GETDATE()) AS MONTH

Below is output

How to get the YEAR value from GETDATE()
   Use following SELECT command in SQL

SELECT DATEPART (YEAR,GETDATE()) AS YEAR

Below is output

Thursday, 5 July 2012

How to take backup of GAC (Global Assembly Cache)

Today's Learning

How to take backup of the Global Assembly Cache in Dot Net


Type the  following in RUN



StartàRunàC:\Windows\Assembly\GAC_MSIL

Whole GAC will appear in FOLDER structure and now you can take backup easily :)

Cheers :)