Slashdot Mirror


Microsoft PowerShell Core For Linux Now Available as a Snap (betanews.com)

Canonical announced on Friday that Microsoft's PowerShell Core is now available on Linux platform as a Snap. From a report: If you aren't familiar, a Snap is essentially a packaged version of a program that can be easily installed on many Linux distributions. Many see it as the future of Linux, as it has the potential to reduce fragmentation. "Built on the .NET Framework, PowerShell is an open source task-based command-line shell and scripting language with the goal of being the ubiquitous language for managing hybrid cloud assets. It is designed specifically for system administrators and power-users to rapidly automate the administration of multiple operating systems and the processes related to the applications that run on those operating systems," says Canonical.

3 of 154 comments (clear)

  1. Re:Excellent news by bulled · · Score: 3, Interesting

    So what you want is xonsh then?

  2. Since at least Wednesday by RhettLivingston · · Score: 3, Interesting

    I installed this Wednesday to check out a challenge someone posted in a forum.

    The challenge was to implement the following powershell script using bash:

    param(
    [Parameter(Mandatory=$True)]
    [datetime]$FromDate,
    [Parameter(Mandatory=$True)]
    [datetime]$ToDate,
    [Parameter(Mandatory=$False)]
    [ValidateScript({Test-Path -PathType Container $_ })]
    [string]$Directory = '.'
    )
    Get-ChildItem -Include '*.JPG','*.PNG' -Recurse -Path $Directory | Where-Object { $_.CreationTimeUtc -ge $FromDate -and $_.CreationTimeUtc -le $ToDate } | ForEach-Object { $_.FullName }

    The challenge author also specified that the bash script should match the functionality of the above including:

    1. Output the full filename one per line that fulfills the requirements
    2. I'll totally run the script on a directory that contains some of the more exotic possible file names. (Good luck with that one)
    3. Define the parameters the script can take. Meaning two required parameters - FromDate and ToDate - and one optional parameter the directory. If no directory is specified just use the current one.
    4. Do validation of the passed in parameters. The directory should exist, the datetimes should be valid datetimes and not something else.
    5. And we certainly want tab completion for the parameters and a help that lists what parameters it takes. So the usual bash equivalent of this:
      Code:
      Get-Help .\test.ps1
      test.ps1 [-FromDate] [-ToDate] [[-Directory] ] []

    My first thought was, "I can get a bash script to run on any version of Windows and have been happily using bash and tcsh on Windows since Windows 95 in the 90s. Can that Powershell script run on Linux?" Surprisingly, I installed the powershell core snap, copied the script to test.ps1, and ran it with no issues. It doesn't convert me to powershell, but I was surprised the argument didn't hold.

  3. Re: .NET is dangerous to depend on by Billly+Gates · · Score: 1, Interesting

    Microsoft has released and opensourced
    NET for Linux time ago so your concerns are outdated.