Showing posts with label windows7. Show all posts
Showing posts with label windows7. Show all posts
Notes on Windows PowerShell
Saliya Ekanayake
- Is bit slow and creepy ;) but better than command line
- Running as administrator helps you overcome many of the access denied situations
- PowerShell script files are simple text files with .ps1 extension
- To run a script file,
- Open a PowerShell instance (preferably as administrator)
- Type the path to .ps1 file and hit enter
- If you get an error due to execution-policy is restricted, try
set-executionpolicy remotesigned
- The above will ask for your permission. To avoid that and force use
set-executionpolicy remotesigned -force
- If you want this to be done across a Windows HPC cluster using clusrun command
$nodes="node1,node2,..,noden" clusrun /nodes:$nodes powershell set-executionpolicy remotesigned -force
- To run a script file,
- To start a new process through a script - http://technet.microsoft.com/en-us/library/hh849848.aspx
start-process command "options and args"
- If you want it to be on the same window and wait for it to complete use
start-process command "options and args" -NoNewWindow –Wait
- If you want it to be on the same window and wait for it to complete use
- Invoke a command on a remote machine - http://technet.microsoft.com/en-us/library/hh849719.aspx
Invoke-Command -ComputerName $node -ScriptBlock {Start-Service MyService}
Handling variables
- Local variables
$x=10
$path="C:\users\dd"
$param0=$args[0] $param1=$args[1]
$javaBin=$env:JAVA_HOME + "\bin"
- A better alternative – number 2 indicates system variable. Use number 1 for user variable
$javaHome=[Environment]::GetEnvironmentVariable("JAVA_HOME",2)
[Environment]::SetEnvironmentVariable("Path","$tmp",2)
- String operations (few)
- Concatenation
$name="John" $x="hello " + $name + "! How are you ?"
$name.Substring(1) // "ohn" $name.Substring(1,2) // "oh"
$name.StartsWith("hello") // true
$name.IndexOf("ohn") // 1
$name.Length // 4
$javaHome=$env:JAVA_HOME // e.g. "C:\Program Files\Java\jdk1.7.0_10" $javaBinString=join-path -path $javaHome "bin" // e.g. "C:\Program Files\Java\jdk1.7.0_10\bin"
- For loop
for($i=1;$i -le 10; $i++) { //body }
- -le is <=
- -lt is <
- -gt is >
- -eq is == in usual programming language notation
- Foreach loop
$jars=ls ($env:TWISTER_HOME + "\lib") *.jar foreach ($jar in $jars) { $jar=$jar.DirectoryName + "\" + $jar.Name $cp=$jar+";"+$cp }
$([System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory())This is pretty much I found useful for my work. Feel free to suggest any.
2:44 PM
powershell
,
scripting
,
tutorial
,
windows
,
windows7
WCF Hosting with IIS7
Saliya Ekanayake
I started working with services in Windows world recently and got stuck pretty badly when I tried to host a WCF service in IIS 7. I was receiving errors no matter what solution I tried with Googling. All of them mentioned that I may not have installed ASP.NET properly, but I have installed it properly.
So I was clueless for a while, but luckily found this great article in WCF Tools team's blog, which mentioned that it may be because I installed Visual Studio prior to installing IIS. I did the simple command mentioned there and wow! it worked.
I will post a step-by-step guide in a later post on how to deploy your WCF Service in IIS7.
So I was clueless for a while, but luckily found this great article in WCF Tools team's blog, which mentioned that it may be because I installed Visual Studio prior to installing IIS. I did the simple command mentioned there and wow! it worked.
I will post a step-by-step guide in a later post on how to deploy your WCF Service in IIS7.
Command Line: Relaxing Colors
Saliya Ekanayake
I have been using a color theme for the command line in both Windows and Ubuntu for sometime now and it has been really comfortable for the eyes. So if you feel tired or bored using the white on black try these.
Background Color: #3A4237 (in RGB this is 58,66,55)
Text Color: White
It will give you this feeling of a good old chalk board. Here's a screen capture of how it looks.
Background Color: #3A4237 (in RGB this is 58,66,55)
Text Color: White
It will give you this feeling of a good old chalk board. Here's a screen capture of how it looks.

Windows7: Desktop Icons: CTRL + Wheel
Saliya Ekanayake
I wanted to change the size of the icons in Windows7 desktop as they were bit larger than I like. The solution was a simple one, though I had to do some Googling to find it out.
Just scroll the mouse wheel while pressing CTRL key. That's easy :). In fact, it can be used in many other places like in windows explorer to change the way how items are showed.
Subscribe to:
Posts
(
Atom
)