Skip to content

nexssp/language_powershell

Repository files navigation

PowerShell implementation for Nexss PROGRAMMER 2.0

To Install Nexss Programmer please go to Nexss Programmer CLI for more information.

Nexss Programmer Examples

nexss file add myprogram.ps1
nexss myprogram.ps1 # execute script
nexss myprogram.js # execute NodeJS
nexss myprogram.py # execute Python.. etcetc..

Use multiple versions of Powershell

To use multiple powershell versions you can add at the top of the file # nexss-compiler tag eg.

To use Powershell 5

# nexss-compiler:Powershell
Write-Host "My current Powershell version: "$PSVersionTable.PSVersion.Major

Other versions of Powershell 6, 7

It depends what you have installed on your machine it will use it. Remove # nexss-compiler:Powershell as pwsh.exe is default compiler.

Installation of latest Version of PowerShell

https://github.com/PowerShell/PowerShell/blob/master/tools/install-powershell.ps1

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI -Preview"

Useful links

& Operator
Table of Basic PowerShell Commands

Powershell Examples

(Get-Location).path #current working directory (location of command run)
($pwd).path
echo $MyInvocation.MyCommand.Path # script file path
echo $PSScriptRoot # script root

$filebase = Join-Path $PSScriptRoot $testFilename
$PSScriptRoot #

Combine to Objects

$dockerResult.psobject.Properties | ForEach-Object {
    $NexssStdout | Add-Member -MemberType $_.MemberType -Name $_.Name -Value $_.Value -Force
}