Author Topic: Power Shell Development  (Read 1085 times)

Zen

  • Member
  • ****
  • Posts: 962
  • slightly red-shifted
Power Shell Development
« on: October 02, 2016, 09:04:28 AM »
So,...I've been reading recently,...and, I've learned that it is possible (well,...maybe) to write a Power Shell application.
Windows PowerShell Reference, MSDN

...Yes,...this is but another of my completely insane ideas,... :bgrin:
Have any of you guys ever attempted this (and, lived to tell) ???

Background:
Quote from: Windows PowerShell Reference
Windows PowerShell is a Microsoft .NET Framework-connected environment designed for administrative automation.

...Of course,...Power Shell already exists: Scripting with Windows PowerShell, MSDN,...and, many of you guys have undoubtedly used it.
It's fun,...isn't it ???
On my system (Windows Seven), it lives here: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

System.Management.Automation Namespace, MSDN
PowerShell Managed Assemblies Reference, MSDN

...Conceptually,...this would be a never-ending, MASM Assembly language, unmanaged, COM-Interop/.NET Framework source code debacle, that would undoubtedly require several lifetimes to code successfully. Funding would be supplied by a mysterious, shadowy organization. :bgrin:
I will, naturally,...take out HUGE life insurance policies on all the participants,...:bgrin:

IS EVERYBODY IN ??? THIS IS A FANTASTIC OPPORTUNITY.
Zen

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4809
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Power Shell Development
« Reply #1 on: October 02, 2016, 10:10:31 AM »
From what I have seen of PowerShell, I am glad that I prefer CMD.EXE as a general purpose command line interface.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

Vortex

  • Member
  • *****
  • Posts: 1704
Re: Power Shell Development
« Reply #2 on: October 02, 2016, 08:51:55 PM »
PowerShell is crap. It's a bloated software based on .NET Framework. There are serious complaints reporting degraded performance of login scripts based on PowerShell in a Windows domain environment. Me too, I prefer cmd.exe as it's lighter and faster than PowerShell. It's true that cmd is lacking some important features. To improve it, you can use the tools supplied with the Cygwin project. A better alternative is to write small command-line tools with the assembly language.

GoneFishing

  • Member
  • ****
  • Posts: 950
  • Gone fishing
Re: Power Shell Development
« Reply #3 on: October 02, 2016, 09:09:25 PM »
Hi Zen,

That's right . Powershell can be a nice toy to play with , esp. when you're young  and rich and have lots of free time .
Here    I wrote about  PS and its practical use in MASM COM development.

BTW you didn't mention  ISE - Integrated Scripting Environment shipped with PS . That's what i like the most !
 
...
 Funding would be supplied by a mysterious, shadowy organization. :bgrin:
...

M$ I guess  :biggrin:

GoneFishing

  • Member
  • ****
  • Posts: 950
  • Gone fishing
Re: Power Shell Development
« Reply #4 on: October 02, 2016, 09:20:13 PM »
...
 It's true that cmd is lacking some important features. To improve it, you can use the tools supplied with the Cygwin project. A better alternative is to write small command-line tools with the assembly language.

or use advanced and powerfull CMD replacement  like Take Command
I used to play with JPSOFT'S  4NT package . Tons of fun !
Of course , I must confess  that I'm totally free from all the troubles of system administration and code for fun only .

Vortex

  • Member
  • *****
  • Posts: 1704
Re: Power Shell Development
« Reply #5 on: October 02, 2016, 09:50:00 PM »
Hi GoneFishing,

Take Command looks interesting and powerful. Thanks.

Here is a screenshot of a Cygwin session. I managed to build a small portable Cygwin package weighting 37 Mb.


TWell

  • Member
  • ****
  • Posts: 748

anta40

  • Member
  • ***
  • Posts: 293
Re: Power Shell Development
« Reply #7 on: October 02, 2016, 10:25:58 PM »
Cygwin is definitely a very good option... but probably only if you deal a lot with compiling open source softwares.
Nowadays I use ConEmu as the CMD.exe replacement.

 ;)

Vortex

  • Member
  • *****
  • Posts: 1704
Re: Power Shell Development
« Reply #8 on: October 02, 2016, 10:32:03 PM »
Bash version of MS runs only on 64-bit Windows 10. No support for 32-bit at least for the moment.

Some important notes :

Quote
There are some limitations here. This won’t work with server software, and it won’t work with graphical software. It’s intended for developers who want to run Linux command-line utilities on Windows. These applications get access to the Windows file system, but you can’t use Bash commands to automate normal Windows programs, or launch Bash commands from the standard Windows command-line. They get access to the same Windows file system, but that’s it. Not every command-line application will work, either, as this feature is still in beta./

http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/

Cygwin does not suffer from those restrictions. A quick example, running a Windows command, ipconfig from Bash :

Code: [Select]
Administrator@orion ~
$ ipconfig

Windows IP Configuration

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   IP Address. . . . . . . . . . . . : 192.168.0.24
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.0.1

Administrator@orion ~
$ ipconfig | grep "IP Address"
   IP Address. . . . . . . . . . . . : 192.168.0.24

Administrator@orion ~
$ notepad &
[1] 2284

Administrator@orion ~
$ ps
      PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
     1740    1060    1740       1904  pty0      197108 14:07:55 /usr/bin/ps
     1060    1408    1060       1696  pty0      197108 14:05:59 /usr/bin/bash
     1408       1    1408       1408  ?         197108 14:05:59 /usr/bin/mintty
     2284    1060    2284       2676  pty0      197108 14:06:55 /cygdrive/c/WINDOWS/system32/notepad

Running a Bash script from cmd :

Code: [Select]
D:\>type \cygwin\home\Administrator\test.sh
pwd
ipconfig

D:\>\cygwin\bin\bash --login -i ~/test.sh
/home/Administrator

Windows IP Configuration


Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   IP Address. . . . . . . . . . . . : 192.168.0.24
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.0.1

Zen

  • Member
  • ****
  • Posts: 962
  • slightly red-shifted
Re: Power Shell Development
« Reply #9 on: October 04, 2016, 09:29:44 AM »
Amazing !!! Thanks, you guys for the EXCELLENT INTEL. :bgrin:
The idea for a MASM version, .NET Framework PowerShell application was kind of a joke,...as I'm sure you all are aware.
I was just thinking of exploring the namespace and security, to see how it was implemented.

...To be honest, I've never used PowerShell,...and I know almost nothing about it,...
Zen

jcfuller

  • Member
  • **
  • Posts: 175
Re: Power Shell Development
« Reply #10 on: June 19, 2017, 11:19:40 PM »

The latest Windows 10, Version 1703, does not provide a command window option from File Explore with a shift/right click.  Instead you get a PowerShell option. I understand there is a way to get a command window from File Explorer but it is pia resgistry hack.
Of course cmd.exe is still available but I used the shift/right click a lot.

Most all my coding uses batch files to compile and link so I was curious if PowerShell offered advantages. I've got a PowerShell introductory book coming today. Now if I can only find the time to read it.


James