Blog restart || Powershell $errorActionPreference = „Stop”

After this 6 month hiatus I’ve decided to restart my blog, albeit in a slightly different form. The reason is that i’ve had major career (and life) changes the pace of which has been mindboggling even by my standards. The upshot is that i am now doing mostly cloud devops work: Powershell programming, Azure work etc. This move away from traditional network work was a bit challenging at first but i guess i’d been preparing for that for a while so this had to happen at some point anyway.

Consequently, I will be focusing mostly on programming (powershell, python) and Azure, although mostly in a broader context of networks.

Let’s get started, then.
I’ve been improving an azure connection script to create some private endpoints and the (small) challenge was to only proceed with some actions if the endpoint had been created.

The solution (partly borrowed from Powershell Cookbook ) can be threefold:

(Invoke-Command localhost { "Some output" }) -and ("Connection successful!")


$ErrorActionPreference = "Stop"
(Invoke-Command localhost { "Some output" }) 
Write-Host "Connection successful!"

Or after upgrading to Powershell core:

(Invoke-Command localhost { "Some output" }) && ("Connection successful!")


Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:


Komentujesz korzystając z konta Wyloguj /  Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Wyloguj /  Zmień )

Zdjęcie na Facebooku

Komentujesz korzystając z konta Facebook. Wyloguj /  Zmień )

Połączenie z %s

%d blogerów lubi to: