Page 1 of 1

What is powershell for and how to use it

Posted: 2021-Jul-25, 11:23 am
by MigrationUser
17 Feb 2009 08:39
microbious


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.

----------------------------

#2 18 Feb 2009 19:41
Simon Sheppard


> 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

https://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.

----------------------------

#3 19 Feb 2009 01:33
microbious


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

----------------------------

#4 26 Oct 2009 14:23
sarbjitsinghgill
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.