Wednesday, August 27, 2014

If you have multiple versions of Power Shell how do you change from one to the other?

If you have two or more versions of Power Shell on your computer it is possible to choose the one you want to run.

By default the highest version may be one that runs as in the present case on Windows 8.1 Professional (version 4.0 is installed in Windows 8.1 by default and Version 3.0 in Windows 8).
As described in the previous post, version 2.0 is also present.

You can run the version you want by the following command:
PS C:\>Powershell -version

This is how you run the version you want.
---------------
Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.
The next command displays the version number
PS C:\Users\Jayaram> $PSVersionTable.PSVersion
Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1

The following changes the version to 2.0. Note that there is no response.
PS C:\Users\Jayaram> PowerShell -version 2.0
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

The following displays the version after change
PS C:\Users\Jayaram> $PSVersionTable.PSVersion
Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1

PS C:\Users\Jayaram>

How do you install NuGet Package Manager?

NuGet is the package manager for Microsoft development platform including Microsoft .NET. NuGet gallery at nuget.org is the central package repository.

NuGet Package Manager is available for the following clients:
  • For Visual Studi 2010, 2012 and 2013 through Visual Studio Extension Gallery that you can access from Tools|Exrensions and Upgrades... in Visual Studio IDE.
  • For WebMatrix 3 in the WebMatrix Extension
  • Command-line: http://nuget.org/nuget.exe
This is how you access in Visual Studio 2013 Express for Windows.



How do you manage packages? Read here for details:
http://msdn.microsoft.com/en-us/magazine/hh547106.aspx

Sunday, August 24, 2014

What is SQLDiag?

SQLDIAG is an utility that provide general purpose diagnostics (collection).
It can be run as console application or as a service. It is available
in all versions starting from SQL Server 2005 to SQL Server 2014.
SQLDIAG collects the following types of information:

•Windows Event Logs (Application, System, and Security) in .CSV files

•System Monitor (aka Perfmon) performance counters in .BLG file/s

•SQL Server Profiler traces in .TRC file/s

•SQL Server Blocking chains in a _BLK.TRC file

•SQL Server error logs, configuration, point-in-time snapshots of several DMVs in
a .OUT file

•System information via the Msinfo32 utility in a .TXT file

You can customize the utility by editing (manually)  the XML configuration file
of the utility, SQLDiag.xml

There is also a GUI tool which you can use to visually edit the xml file at the
codeplex site here.
http://sdct.codeplex.com/

File location on your computer:
If you have installed SQL Server in the present post SQL Server 2012 it should be
installed in the same directory as SQL Server which is usually,
%ProgramFiles%\Microsoft SQL Server\110\Tools\Binn

Tuesday, August 19, 2014

Can multiple versions of PowerShell exist on a computer?

Power Shell is one of the most powerful scripting languages to use if are working with Windows. Often you may want to know what version you have on your computer and you may also want to know whether multiple versions can exist side-by-side on a computer.

I purchased a Windows 8.0 laptop and a few days later it was upgraded to Windows 8.1. There have been many Windows Updates since I bought the computer and I am not sure if a version of PowerShell was installed. Also a few months later I installed SQL Server 2012 Developer Edition.
After looking through I discovered that I have two versions 2.0 and 4.0; and they can exist side-by-side.

In my previous post here, I mentioned that you can find the version of your PowerShell installation using the following commandlet.

PS C:\>$PSVersionTable.psversion

As you can see from this post that I had PowerShell Version 3.0 on my Windows 7 (x64) machine

http://hodentekhelp.blogspot.com/2014/08/can-you-use-powershell-to-find.html

In Windows 8.1 using the same commandlet I find the following:
-------------------
Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\Users\Jayaram> $psversionTable.psversion
Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1

---------------------
However when invoked PS from SQL Server as mentioned in this post:
http://hodentekmsss.blogspot.com/2014/04/starting-power-shell-from-sql-server.html

I see that the version is 2.0
--------------------------------
PS SQLSERVER:\SQL\HODENTEK8\REGENCYPARK> $psversionTable.psversion
Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1

------------------------------------
This means that the versions 2.0 and 4.0 can exist side-by-side

Wednesday, August 6, 2014

Can you use Powershell to find the environmental variable Path?

It is very easy to find path using the command line as shown:
C:\>Path

If you want to use Powershell then you should first start Powershell with the following command:
C:\>Powershell

If powershell is installed you should see the following change:
C:\>  changes  to PS C:\>

When you are in PS C:\>
type exactly as shown.
PS C:>get-item env:
Then you should see all the environmental variables (directories) separated by a semi-colon;
A sample listing is shown here:



If you want to get a single environmental variable such as 'Path' for example
You can do this:
PS C:\>$x="Path"PS C:\>get-item env:$x
or
PS C:\>get-item env:"Path"
On this machine Windows 7 (x64) Ultimate, "Path", 'path', path all returned the 'PATH' variable.


If you want to know the version of your powershell, try this:

Have a look at this reference for PATH:
http://msdn.microsoft.com/en-us/library/aa922003.aspx
 

Sunday, August 3, 2014

What is 'Path' in Windows 7 and how do you find it?

What is 'Path'?
Path is an environmental variable.

It is a list of directory paths where the computer looks for a command to execute although the full path to the executable is not given.

For example ,

if you type 'Notepad' at a command prompt a Notepad application opens immediately, although its location on your computer is at:
%windir%\system32\notepad.exe which is the same as C:\windows\system32\notepad.exe.

This is because C:\windows\system32\ is in the list of directories in the path.

How do you find the 'Path'?
You can simply type path at a command prompt and the computer prints to the screen the list of directories as shown:
----------------
C:\>path
PATH=C:\Program Files (x86)\iis express\PHP\v5.4;C:\Program Files\Internet Explorer;;C:\oraclexe\app\oracle\product\11.2.0\se
rver\bin;;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program File
s\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft
 SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft\Web Platform Insta
ller\;c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\SQL Anywhere 16\bin64;C:\Program File
s\SQL Anywhere 16\bin32;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110
\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;c:\Program Files (x86)\Microsoft Visu
al Studio 10.0\Common7\IDE\PrivateAssemblies\;c:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;;C:\Windows\System32\
WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files (x86)\Java\jre7\bin\;

You can also find it another way using the Computer Properties as shown here:
http://hodentekhelp.blogspot.com/2010/08/compiling-java-in-windows-7.html

 

Thursday, July 3, 2014

How do you use MS Query in MS Excel 2010?

MS Query is used to import data into a MS Excel application (Work sheet) in Microsoft Excel. Here Microsoft Excel in the Microsoft Office Professional Plus 2013 (x32bit)  suite is used.

Using Microsoft Query data from a table in SQL Server 2012 can be imported into an excel sheet. The process is explained in great detail here:

http://hodentekmsss.blogspot.com/2014/07/how-do-you-import-data-from-sql-server.html

In order to carry out the steps in the above, you must first create an ODBC connection to SQL Server (in this case SQL Server 2012 Express) will be required. If you do not have a DSN made follow this link to learn how:

http://hodentekmsss.blogspot.com/2013/08/how-do-you-create-odbc-dsn-to-sql.html