Category: powershell

[Programmer Tools] Powershell Modules

The list have been obtained with the help of VisualAPI, former BlocklyAutomation.
You can obtain a list on your device by running


dotnet tool update --global programmerall --no-cache
programerall

Then browse to http://localhost:37283/blocklyAutomation/automation/loadexample/powershellModules and press Execute
( You can have automation the same for your site – just contact me)

My powershell modules

  1. EPS:EPS

    1.0.0

    EPS (Embedded Powe…

  2. FormatMarkdownTable:FormatMarkdownTable

    1.0.4

    Format PowerShell object to Markdown table

  3. oh-my-posh:oh-my-posh

    7.85.2

    A prompt theme engine for any shell

    Minimum Pow…

  4. posh-git:posh-git

    1.1.0

    Provides prompt with Git status summary information and tab complet…

  5. PSReadLine:PSReadLine

    2.2.6

    Great command line editing in the PowerShell console host

  6. Terminal-Icons:Terminal-Icons

    0.10.0

    PowerShell module to add file icons to terminal based on fil…

  7. WinGet:WinGet

    0.0.8

    Package Management (OneGet) provider that facilitates installing WinG…

[RO] Evaluare proprie la examenul de evaluare nationala, clasa a 9-a

Am copil / adolescent care a dat examenul de evaluare nationala – nu conteaza pe ce loc s-a clasat. Ideea este : in functie de rezultatele anterioare, unde are sanse la profilul pe care il vrea ? Excel ,Powershell si un pic de API/JSON din HTML rezolvat problema …

Mai intii, vedem pe ce loc s-a clasat ( sa zicem 1000 )

Luam rezultatele anterioare pe judet http://static.evaluare.edu.ro/2021/rezultate/B/index.html si le exportam in csv, ca sa le deschidem cu Excel :

$url= “http://static.evaluare.edu.ro/2021/rezultate/B/data/candidate.json?_=1656825447506″
$response = Invoke-WebRequest -Uri $url
$jsonObj = ConvertFrom-Json $([String]::new($response.Content))

$jsonObj | ConvertTo-Csv | Out-File C:\Temp\Rez2021.csv

Deschidem cu Excel (daca nu converteste bine, atunci Data => Text To Columns cu separator  ) si vazut ce medie are cel de pe locul

1000 ( sa zicem 9.5 )

Acum vedem cum s-au calificat la licee http://static.admitere.edu.ro/2021/repartizare/B/index.html 

Alt json rezolva

$url  = “http://static.admitere.edu.ro/2021/repartizare/B/data/candidate.json?_=1656823951672″
$response = Invoke-WebRequest -Uri $url
$jsonObj = ConvertFrom-Json $([String]::new($response.Content))

$jsonObj | ConvertTo-Csv | Out-File C:\Temp\Adm.csv

Acum mai trebuie un pivot dupa specializare si , pe values, Max(adm) si Min(Adm)  – optional filtru dupa liceu .

ACEST POST NU ESTE O RECOMANDARE CE SA PUNETI. ESTE DOAR CA SA VEDETI MEDIILE . NU IMI ASUM NICI O RESPONSABILITATE.

Windows terminal + Powershell to run IDE, Angular, .NET Core

I work at http://github.com/ignatandrei/BlocklyAutomation – and every time I need to run Angular , Visual Studio Code IDE and .NET Core run ( and Visual Studio  sometimes  – it is more web based)

Also, sometimes I need to run in a container – to install globally something that I do not want to have in my PC.

So  I have 1 windows terminal command to run those :

First one

wt new-tab   –title RootSource –suppressApplicationTitle -p “Windows PowerShell” -d . cmd /k “cd src && code . && powershell” ;split-pane  –title Angular –suppressApplicationTitle -V -p “Windows PowerShell” -d . cmd /k “cd src &&  npm run start –watch && powershell” ;split-pane  –title LocalAPI_NetCore –suppressApplicationTitle -V -p “Windows PowerShell” -d . cmd /k “cd src/Local/LocalAPI/LocalAPI && dotnet watch run”

As you see , I have

code .

to run VSCode,

npm run start –watch

to run Angular and

dotnet watch run

to run dotnet.

Second one:

wt new-tab -p “Windows PowerShell” -d . ;split-pane -p “Windows PowerShell” -d . cmd /k “cd src && devcontainer open .”

The second it just works with devcontainer  – if you are interested in sources, see https://github.com/ignatandrei/BlocklyAutomation/tree/main/src/.devcontainer 

With those, I can start my developer environment fast ( how fast, that depends on my PC)

Fun with Moniker- naming assembly versions

I liked the way docker generates names for every container instance – it was a funny way to differentiate them. I was thinking  – what about nuget packages – or any other release  ?

I have discovered Moniker – https://github.com/alexmg/Moniker . Can be used as in docker – to generate different names at various runs. However, what I wanted is to make every release to have a funny name.

I have put in .NET Core local tools ( see https://youtu.be/iHLRBxi4S7c  and the blog post http://msprogrammer.serviciipeweb.ro/2020/06/08/net-core-local-tools/ ) and I have used from powershell ( see https://github.com/ignatandrei/NETCoreBlockly/ for the usage)

First, I have created a variable

if($result -eq 0){

$moniker = “$(dotnet moniker -s moby)-$dateToPrint”

}

else{

$moniker = “$(dotnet moniker -s moniker)-$dateToPrint”

}

then used this variable in the release notes

$releaseNotes += (“;BuildNumber $env:BUILD_BUILDNUMBER with name “+ $moniker)

and in assembly title

dotnet-property “**/*.csproj” AssemblyTitle:”NetCoreBlockly $moniker”

Then, in C# , I write in the console:

static string nameBlockly()

{

var ass = Assembly.GetExecutingAssembly();

var assName = ass.GetName();

var nameBlockly = assName.Name;

try

{

var title = ass.GetCustomAttribute<AssemblyTitleAttribute>();

nameBlockly = title?.Title ?? nameBlockly;

}

catch

{

//do nothing

}

return $”{nameBlockly} version:{assName.Version.ToString()}”;

}

If you want to see in action , you can:

  1. Look at the nuget release notes at https://www.nuget.org/packages/NetCore2Blockly/ ( see BuildNumber … with name
  2. See the change log https://github.com/ignatandrei/NETCoreBlockly/blob/master/changelog.md – every release has the name
  3. Install NetCoreBlockly  and see the name 

See the tests in VSCode and improvements in powershell–part 24

I wanted that the user can see the tests when running in  VSCode. So in devcontainer.json I have put

“extensions”: [
“ms-vscode.csharp”
“ms-vscode.csharp”,
“hbenl.vscode-test-explorer”,
“formulahendry.dotnet-test-explorer”
]

and in the settings.json on .vscode folder

 

dotnet-test-explorer.enableTelemetry”: false,
“dotnet-test-explorer.testProjectPath”:”**/*.sln”,
“dotnet-test-explorer.autoExpandTree”:true

 

So far, so good. But – I remember that powershell have a problem. And I figure why – before running

dotnet pwsh

I should run

dotnet tool restore

in order to run the dotnet-toolsjson from .config file

 

{

“version”: 1,

“isRoot”: true,

“tools”: {

“powershell”: {

“version”: “6.2.3”,

“commands”: [

“pwsh”

]

}

}

}

 

.And this command should be executed both in Docker and in Azure

Infovalutar

And one hour passes...
(This is the result of 1 hour per day auto-challenge as a full cycle developer for an exchange rates application)
( You can see the sources at https://github.com/ignatandrei/InfoValutar/ )
NrPost 
1Start
2Reading NBR from internet
3Source control and build
4Badge and test
5CI and action
6Artifacts and dotnet try
7Docker with .NET Try
8ECB
9Intermezzo - Various implementations for programmers
10Intermezzo - similar code - options
11Plugin implementation
12GUI for console
13WebAPI
14Plugin in .NET Core 3
15Build and Versioning
16Add swagger
17Docker - first part
18Docker - second part
19Docker - build Azure
20Pipeline send to Docker Hub
21Play with Docker - online
22Run VSCode and Docker
23Deploy Azure
24VSCode see tests and powershell
25Code Coverage
26Database in Azure
27Sql In Memory or Azure
28Azure ConString, RSS
29Middleware for backward compatibility
30Identical Tables in EFCore
31Multiple Data in EFCore
32Dot net try again
33Start Azure Function
34Azure function - deploy
35Solving my problems
36IAsyncEnumerable transformed to IEnumerable and making Azure Functions works
37Azure functions - final
38Review of 37 hours
39Last Commit in AzureDevOps
40Create Angular WebSite
41Add static Angular to WebAPI .NET Core
42Docker for Angular
43Angular and CORS
44SSL , VSCode, Docker
45Routing in Angular
46RxJS for Routing
47RxJs Unsubscribe

Powershell vs console application

I have decided to make the utilities that I use in form of Powershell applications instead of Windows / Console applications

Pros:

There are simpler to use  – just run the powershell

The parsing of command line is powerfull in powershell

There are simpler to maintain ( just text scripts files)

There are no big dependencies( .NET Core/ .NET 4.x  to be installed)

This is a good tool under  my toolbelt

Everything you do in .NET you can do in Powershell ( sometimes it is much harder in .NET rather then powershell)

 

The repository is https://github.com/ignatandrei/PowershellUtils and the first item is to move the big files from C: into another drive to free space by making a junction dir ( e.g. C:\ProgramData\Package Cache and C:\Windows\Installer )

WifiHotSpot

 

I have become tired of reading about how to enable Wifi HotSpot in Windows 10 . The reference is here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd815243%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 . ( also, for bandwidth throttling you can try  https://github.com/jagt/clumsy and / or https://reqrypt.org/windivert.html   )

I was trying to make a Windows Store application – but, apparently, it is very difficult to run command lines application from Windows Store/

So I made a small powershell file ( hosted at https://github.com/ignatandrei/WIFIHotSpot )

Enjoy!

Powershell and always use explicit

 

Let’s suppose you have a variable $x=”http://msprogrammer.serviciipeweb.ro/

In powershell the following are the same

$x

Write-Host $x

 

I want to make a function that returns a value . Let’s say

Function Add([string] $a, [string]$b)

{

#debug to see arguments

$a

$b

return $a + $b

}

 

If I call this function with

Add 10 17 # the syntax for calling powershell is WITHOUT comma – the comma indicates arry

it shows

10

17

27

However , if I wrote

$x = Add 10 17

it does not wrote

10

17

 

Do you know why ?

 

Answer in the first comment

powershell and clean iis

Sometimes it is necessary to remove IIS temp files from windows directory

So I have made this following script in powershell

iis reset

What it does:
restarts iis ( run as admin in Windows 7)

Cleans temporary folders from

$windir + “\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files”

$windir + “\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files”

Enjoy !(iis reset)

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.