Os cmdlets do PowerShell são executados no dotnet do Linux? Ou apenas o Microsoft .NET?

1

Título diz tudo. Wikipedia diz :

Design[edit] PowerShell's developers based the core grammar of the tool on that of POSIX 1003.2.[21]

Windows PowerShell can execute four kinds of named commands:[22]

cmdlets (.NET Framework programs designed to interact with PowerShell) PowerShell scripts (files suffixed by .ps1) PowerShell functions standalone executable programs If a command is a standalone executable program, PowerShell launches it in a separate process; if it is a cmdlet, it executes in the PowerShell process. PowerShell provides an interactive command-line interface, wherein the commands can be entered and their output displayed. The user interface, based on the Win32 console, offers customizable tab completion. PowerShell enables the creation of aliases for cmdlets, which PowerShell textually translates into invocations of the original commands. PowerShell supports both named and positional parameters for commands. In executing a cmdlet, the job of binding the argument value to the parameter is done by PowerShell itself, but for external executables, arguments are parsed by the external executable independently of PowerShell interpretation.[citation needed]

The PowerShell Extended Type System (ETS) is based on the .NET type system, but with extended semantics (for example, propertySets and third-party extensibility). For example, it enables the creation of different views of objects by exposing only a subset of the data fields, properties, and methods, as well as specifying custom formatting and sorting behavior. These views are mapped to the original object using XML-based configuration files.[23]

que indica que .NET é necessário e que o Linux dotnet é insuficiente para executar os cmdlets.

    
por Thufir 21.02.2018 / 20:28

4 respostas

-2

A Microsoft lançou recentemente o PowerShell 6.0 no Linux e no Windows. Os dois são funcionalmente intercambiáveis. No entanto, ambos são um desvio significativo do PowerShell 5.1 no Windows. Portanto, você deve desenvolver para v 6 para garantir a compatibilidade.

Seu gerenciador de pacotes manipulará todas as dependências.

    
por 21.02.2018 / 21:31
4

Windows PowerShell vs. PowerShell Core

As seguintes perguntas frequentes detalham as diferenças.

PowerShell Core is the successor of Windows PowerShell 5.1 and runs on Windows, Linux and macOS.

...

  1. Will all of my old Windows PowerShell scripts work on PowerShell Core, that is, is PowerShell Core backward compatible with Windows PowerShell?

    Previous PowerShell updates were fully backward compatible. This only applies partly to PowerShell Core. Because PowerShell Core is a cross-platform edition of PowerShell, Microsoft made a few compromises. This means you have to test each and every script to make sure it also works on PowerShell Core.

  2. Will all scripts I write for PowerShell Core run on all supported platforms?

    Basic scripts will run on all platforms. However, considering the huge differences between the supported platforms, you have to test each script on all platforms it is supposed to run on.

  3. Do all modules for Windows PowerShell run on PowerShell Core?

    No, many complex modules have to be adapted for PowerShell Core. In some cases, different module versions exist for both PowerShell editions.

  4. Can I use all .NET Framework classes on PowerShell Core?

    No, PowerShell depends on .NET Core, which lacks many features of the .NET Framework. For instance, Windows Presentation Foundation (WPF), Windows Forms, and Windows Workflow are missing on .NET Core. You can find more information here.

(ênfase minha)

Fonte Diferenças entre as versões do PowerShell - 4sysops

    
por 21.02.2018 / 21:37
2

Você pode facilmente determinar isso para si mesmo, simplesmente olhe para ambos lado a lado.

Significado módulo disponível, cmdlets, etc ...

PowerShell v6 / Core

https://docs.microsoft.com/en-us/powershell/scripting/powershell-scripting?view=powershell-6

PowerShell v6.0.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS D:\> (Get-Command -Module *).Count
425

PS D:\> (Get-Command -Name *).Count
1483



Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\> (Get-Command -Module *).Count
1529

PS C:\> (Get-Command -Name *).Count
2474

Então, você literalmente tem "1104" menos módulos e "945" menos cmdlets à sua disposição no PSCore / v6. Então, sim, depende de qual você está usando e se eles estão disponíveis.

Além disso, para tentar aproximar o PSCore do Windows PowerShell, a Microsoft lançou o Pacote de compatibilidade do PowerShell. Ainda assim ...

As reported last month the Windows Compatibility Pack for .NET core is available. This adds back some of the functionality missing from .NET core. "This functionality is ONLY of relevance on Windows machines."

https://richardspowershellblog.wordpress.com/2018/01/04/windows-compatibility-pack

    
por 25.02.2018 / 02:18
1

O PowerShell está disponível para Linux, portanto, presumir-se-ia que os scripts manteriam pelo menos a maioria e talvez todas as suas funcionalidades, independentemente de plataforma.

    
por 21.02.2018 / 21:01