#1 17 Feb 2009 08:39

microbious
Member
Registered: 13 Feb 2009
Posts: 25

What is powershell for and how to use it

Asking for help for a powershell noob.
I've somewhat learned CMD behavior and want to move up to powershell.
Problem is that i dont relly know what its for and how it works.

Basic things like how to execute a script ?
and why i get error "execution script is disabled on this system" ?
How can i make this script a executable that will run on all OS ?
Does powershell understand environment variables like CMD does or it has even better way of finding locations?
Can i execute 2 commands at same time ?

Things like that are a total mystery so i dont even know why its time for me to move up ?

Any help is any help.

Offline

#2 18 Feb 2009 19:41

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 998
Website

Re: What is powershell for and how to use it

> What it's for

just about anything, in general the more complex the task, the better you will find PowerShell as the solution
the one thing I would not use powershell for yet is login scripts: for drive mapping VBS is still where its at.

>how to execute a script ?
.\myscript.ps1

> why i get error "execution script is disabled on this system" ?

By default you need to digitally sign all scripts before they can be run, to turn this off, and only require signing for downloaded scripts, run:
PS C:\> Set-ExecutionPolicy RemoteSigned

To find out more about signing:
PS C:\> help about_signing

> How can i make this script a executable that will run on all OS ?

Scripts will run anywhere that powershell is installed and has the appropriate signing.
PowerShell v2 will be installed by default on Windows Server 2008 R2 and Windows 7.
For Win XP and 2003, you will need to download and install powershell first.

> Does powershell understand environment variables like CMD does

http://ss64.com/ps/syntax-variables.html

>Can i execute 2 commands at same time ?

Yes I think for most things asynchronous is the default (same as CMD) if you want to wait for a command to complete, then pipe it into Null:
<command> | out-null

> i dont even know why its time for me to move up

It's the future!, if you know Powershell you will soon be able to drive Exchange, Sharepoint and any number of other back office server apps, when companies are increasingly rolling out bigger and bigger server farms the ability to manipulate 50 or 100 servers at once from the command line is a really good skill to have on your CV.

Don't feel stressed that you have to convert everything you do to Powershell overnight, it will take time to get used to a different way of scripting.
I find it helps to put Powershell right on your start menu and just use it for everything - from there you can run CMD or CMD /C when you have to run 'old style' commands but make powershell your home.

Offline

#3 19 Feb 2009 01:33

microbious
Member
Registered: 13 Feb 2009
Posts: 25

Re: What is powershell for and how to use it

CMD is still best and easy because anyone can execute it without having to install anything.

Ill stick with CMD for another 10 years when powershell will be everywhere just like CMD is

Offline

#4 26 Oct 2009 14:23

sarbjitsinghgill
Member
From: TORONTO CANADA
Registered: 09 Dec 2007
Posts: 112
Website

Re: What is powershell for and how to use it

microbious wrote:

CMD is still best and easy because anyone can execute it without having to install anything.

Ill stick with CMD for another 10 years when powershell will be everywhere just like CMD is

Moving to PS; simplest reason; this will be future script. I am just starting; but for sure I know I am bit late.


Sarbjit Singh Gill
IBM certified DBA, MQ Solution Developer

Offline

Board footer

Powered by FluxBB