Showing posts with label Windows Power shell. Show all posts
Showing posts with label Windows Power shell. Show all posts

Friday, March 9, 2018

What is the difference between braces{} and parenthesis() in Windows Power Shell?

In Windows Power Shell,
  • Braces{} enclose code and are not immediately evaluated. They must be called using the & operator (called the call operator)
  • Parenthesis() enclose code that is immediately called.

Example parenthesis:
$a=(5+5+25) and it evaluates immediately to 35
as seen here:



 Example braces:
On the other hand when you use braces, it is not evaluated.













What is inside the braces is code and how do you evaluate the code?

What you have inside the braces is called a ScriptBlock.
To run ScriptBlock code  you need to use the call operator & as in the next image.














It is easy.

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