TUGA IT conference – First as Staff, now as Speaker!

I’m very proud to announce that I’ll be speaking on one of the biggest Portuguese technological conference, the TUGA IT . This conference gathers speakers from all around the world, who are passionate about what they do and want to share their experiences/knowledge.

This has an ever bigger meaning for me, since it was the first conference organization that I’ve attended other than the local User Groups. Highly motivated by Cláudio (b|t), last year I’ve helped the organization, and this year I’m a speaker. It was also where I was able to meet awesome folks such as Jaap (b|t) and Rob (b|t).

For me this is a HUGE achievement, both personally and professionally.

“But what will you be talking about?”

I will talk about using PowerShell on a RaspberryPi. I’ll share my experience with, what have I done with it, how, and what I expect to do. If you like PowerShell but don’t know RaspberryPi or the other way around, this might be a good session to attend to.

“Oh, that sound awesome but I can’t attend to it.”

If you just thought something like this don’t worry. You can always check out a previous presentation here, although I will probably have something new (but the core is still the same) 🙂 .

And as if speaking sessions weren’t enough, they also have WORKSHOPS

Registrations are open!

If you are not still convinced, check out the speakers list, and the schedule!

If you have interest (and you should!) I have good news for you: you can grab your seat today !

Final words…

I’m really excited about this event and I really hope that if you attend to the event, you sure to say hello!




I’ve shared Internet connection between Linux and headless RaspberryPi but can’t SSH


1 – Follow the first 4 steps described here;

1.1 – Additionally, just to be sure, ignore IPV6 on IPV6 tab;

2 – Instead of trying to ssh into the given network ( in my case), run

cat /var/lib/misc/dnsmasq.leases

connect to the given IP address.


I’ll be presenting using my raspberry and my laptop, so I have the need to be able to connect to it (raspberry) via SSH. In order to be able to do that, I need to have both devices on the same network. Connecting the laptop to the network is usually easy, since you are given an username and password and in the worst case you need to open the browser and login into some page.

As for the raspberry, that’s another story. I could carry around a keyboard, mouse and monitor just to establish the connection, but even that could not be enough… what if I have the lite version (just the console)? If the network provider want me to login into a webpage, that will be an headache.

After a quick word with André Melancia (t) he mentioned that Internet Connection Sharing (ICS) was easy since Windows XP. But… I’m using Linux 😀

A quick search on Google yielded this thread . Although many people there said that the first 4 steps were enough, for me they weren’t, because even so I wasn’t able to connect (you will understand why later).

Let’s see what we got

After following those steps, I’ve ended with the same output as the person who posted it


Ok, cool! Let’s test it.


We got it! Now I can SSH into my Pi…


Hum… I’m sure that I’ve entered the correct credentials (it is a fresh install, so in raspbian the user will always be pi and the password raspberry). What’s wrong?


Nmap (used for network descovery) even says that it allows SSH and it’s open…

Re-reading that thread, someone posts something that he states as relevant which is basically to ignore ipv6. Still no luck.

So what’s wrong?

Well, turns out I was targeting the wrong address. At first, everything was matching:

  • I was able to ping;
  • I was able to SSH into it, but I was getting permission denied;


How did you know that you were targeting the wrong address?

Digging a little bit more, I found this post , which suggests a command to run that will give us the correct address:

cat /var/lib/misc/dnsmasq.leases


which yielded something like:

1526507253 xx:xx:xx:xx:xx:xx raspberrypi xx:xx:xx:xx:xx:xx


It worked!


So what’s dnsmasq and how did it help finding/solving the problem?

According to  the official website and I quote:

Dnsmasq provides network infrastructure for small networks: DNS, DHCP, router advertisement and network boot

In resume, this tool scans the smaller network (in this case the ethernet one that only have one device) and gives us the ip address.

Do you have another methods? Please share!

Thanks for reading!

Simple Tip: How do I open explorer on current path in Powershell? Explore different ways

See what I did there? “Explore different ways”… “explorer”… no? ok…

The post today is really simple. I fell like I’m failing by not writing content more often, but there’s not always time and/or subject.

The things that might look pretty simple and obvious for some, is not for the others, and that’s what happened to me today.

On my working environment, I’ve set my Powershell window to always start on a specific folder (which is my Workspace folder). That is cool because I’ve a script that I usually need to make some modifications and run, so setting the path to point there was a good start. Even after that, I’ve always ended up opening explorer and navigating to the desired folder (mainly because I need to use other files from there). So today I asked myself “Why don’t I simply open Powershell and open the explorer from there?”

Failed attempts

  • explorer – First attempt, simply type explorer. That launched explorer (as expected, but not on the current directory);
  • Get-Location | explorer – Also launched explorer, but not on the desired directory;
  • explorer Get-Location – This one made plenty of sense to me, although it opened the “My documents” folder instead of the current directory. Funny enough, I was only missing the brackets between the CmdLet – we will see it ahead
  • . – Because I know that the dot “represents” the current directory, I thought that simply typing that would launch the explorer (but why would it ?)

(Funny, because I’ve tried with  explorer  and  but never occurred me to try explorer .)

So, what does work?

Like almost everything in this area, there are many ways to achieve this. After getting help from people @ SQL Server Community Slack (t), here are some options:

  • start .
  • start -filepath “C:\some\path” (start is an alias for start-process)
  • explorer $path (Thank you Gareth (t|b) for all the above)
  • explorer .
  • explorer (Get-Location) (the one that I almost got right).
  • invoke-item . (or even simpler ii .) (Thank you Andy (t|b) )

Fred (t|b) also mentioned a module called PSUtil  that has some functions for explorer (besides many others). I also recommend you to read his post about some things that this module contains.


The purpose of this post was not only (or mainly) to show how to open the current directory on the explorer, but to show that there are many commands and combinations that can be performed to achieve the same purpose. This can also be applied for other cases

Getting started with SignalR Alpha for ASP.NET Core 2.0! – My experience

This looks like a long post but it has lots of code and little explanations since SignalR is on an early stage. Stick until the end 🙂

Previously I’ve overheard about SignalR, which I’ve been told that it’s a library to allow “real time” communication with multiple web clients. My first thought was that it was some kind of message broker (like I’ve used before the RabbitMQ and MQTT protocol), but after a little reading and talking, I found out it’s much easier than that.

A couple of weeks ago, Microsoft announced SignalR (Alpha) for ASP.NET Core 2.0. This blog post is a really good entry point, and if you read it, you get a pretty straightforward idea of what’s new/different, like:

  • JavaScript/TypeScript Client
  • Support for Binary Protocols and Custom Protocols
  • Streaming
  • Scale-out

And many more things like “What’s Changed” (which I won’t cover because like I said, I’ve had zero experience with SignalR before this Alpha) and even the other topics won’t be covered here.

So what will you be talking about?

I will give you my approach/idea about how to work with SignalR in a scenario which is similar to my job’s needs.

My test case scenario and examples

First of all, keep in mind that I will not cover the javascript client, only the C# one. I’ll probably have the necessity to create an implementation on javascript, when I need to I’ll blog about it :).

In order to show a similar “real world” scenario, I’ll build a simple application simulating the following :

There are different type of workers on their workspace and they want to communicate between them. There are 3 groups:

  • Cool employees
  • Way Cooler Employees
  • Bosses

For obvious reasons, they only want to talk to the others on the same group (Cool employees with cool employees, etc etc).

To simulate this interaction we will have another application that simply perform 3 actions, according to correspondent button pressed:

  • C  key pressed – send message only to Cool employees
  • W key pressed – send message only to Way cooler employees
  • B  key pressed – send message only to Bosses

OK… so how does all of this work? Let’s try to visualize it:

Resuming: we want to have employees that belong to the “Cool Employees” group, others to the “Way Cooler Employees” group and the bosses that belong to the “Bosses”group. Have you noticed that I’ve been repeating the word “Groups”? It was with a purpose. With this post, I will show you how can you send messages to specific groups. But before jumping into it, let’s start from the beginning.


On the previous image, everything points to a hub, but what’s a hub? A hub is a “kind of” point-of-access (or bridge if you prefer) between the caller and the receiver(s). Having a quick look at this class:

It gives us access to properties like the Context, Clients and Groups, which we will explore next.

Starting with clients

The default Clients property is of the type IHubClients

This one, also implements an IHubClients interface, which has the following methods:

Since in this case T is of the type IClientProxy, we will have the following available:

We are getting somewhere! With this we already know that when sending a message, we will send it to a group and our code will be something like:

But how do we register a client on a group? We’ve seen that the hub has a Groups property.


Consists on a property of the type IGroupManager, which has two methods:

This is it! We already have the knowledge on how to register a client on a group and how to send a message to a specific group. Let’s implement our Hub. We need to allow each connecting client to register himself on a group, in order to receive only the messages that he wants to, and we need to create the method that will say “ok, I will send this information to this group”.

The Hub implementation

Please note that the Groups.AddAsync() method requires a connectionId, which in this case is the connectionId of the client that is registering himself on a group. To get the connectionId for the current client, we can use the Context.ConnectionId property.

A little parenthesis:

I had a doubt on how the groups were created: did I need to create if before trying to add a connection to it, or would it try to add and if the group did not exist it would be created? Due to the amazing community, it was easy to get some of my questions answered pretty quickly, and it even generated a little and quick discussion. Share your questions/ideas with the community, join ASP.NET slack. Here’s an example of what I’m talking about:

slack.pngAnother awesome “feature” of the open source, is that we can have things like this. Gurgen developed an android client library for SignalR that according to him:

“At the moment, it works only by websockets transport, but later I will add all other transports
The plus is that, this is only implementation of .net core signal r for android”


Ok, so before we can run our code and see things happening, there are two things that we need to add to the Startup.cs

With the routes.MapHub(“entryPoint”) we are specifying that in order to connect to the hub, the route must be ourAddress/entryPoint (in my case it was http://localhost:52846/entryPoint)

Testing what we’ve just created

In order to test this, we need to have a total of three projects: the project with the hub, one to simulate our clients (employees and bosses), and other to send the messages. We already know that our clients must register themselves on a group so that they can receive the desired messages.

In order to simulate the referred scenarios, on the project that simulates the employees and bosses, I decided to create Tasks, in which each simulate a client application, by connecting to the Hub, register itself on a group and setting the callback. Afterwards it just stays on a forever loop. With this in mind, some of the code that I will show isn’t obviously the best approach, but it’s just to make the simulation easier/doable.

Connect to the hub and prepare to receive the messages (employees and bosses project)

The connection itself is pretty straightforward, all we need to do is create a HubConnection object and call the StartAsync method. When the connection is established, we register ourselves on a group, by calling the RegisterConnectionOnGroup method that we created on the hub. For last, we set the callback, defining what should be done when we receive a message. Let’s have a look on the code that simulates a “Cool Employee” client:

NOTE: As I just mentioned above, the connection.StartAsync().GetAwaiter().GetResult() should not be done like that for obvious reasons (it will not be async at all), but honestly I couldn’t figure out how could I await that call inside a Task, because since I’m using Task.Factory.StartNew(new Action(…)) I can’t set the await on the method, because it would change the signature, hence it wouldn’t be an Action. In this case it is just to ensure that we invoke the RegisterConnectionOnGroup only after the connection is established. Do you know how to solve this? Please PM me or even better, comment down below!

The MessageSender project

This application just sits on a forever loop after establishing connection to the hub (via the same HubConnection logic) and “implements” the logic that I previously referred:

  • Send a message only to the bosses? Press B
  • Send a message only to the Cool Employees? Press C
  • Send a message only to the Way Cooler Employees? Press W

With this, we can finally test what was developed. First launch the project that has the Hub (SignalR project, in this case the EmployeeSignalR), then the SignalRClient1 which will create the various clients referred, and finally the MessageSender. Place the SignalRClient1 and MessageSenderconsoles side by side, and press the desired key on the MessageSender‘s console. See the magic happening!

Here’s an example:


For me, this was a whole new world since I’ve never really had contact with SignalR until I had created this project. Obviously, there might be some things that I said that are not exactly like i said, but as I stated at the beginning I tried to “give you my approach/idea about how to work with SignalR in a scenario which is similar to my job’s need”. Since none of us know everything, if you spot a mistake or you have another approach, please let me know!

A special thanks to David Fowler (b | t) for his help and quick replies to my questions! And also, thanks to Gurgen for his intervention on the explanation and his availability to talk to me about signalR.

You can download the full example from my github repo

Thank you very much for reading

PowerShell Modules Central – Share with community – What PowerShell modules are you using?

I think that this is an awesome initiative 🙂

Cláudio Silva's Blog

Like the blog post title states this is all about sharing with others! My idea is to share with the community which PowerShell modules you are using.

Let me introduce to you the PowerShell Modules Central

PowerShellModulesCentral is a GitHub repository that was founded as a central hub to a list of PowerShell modules that people know/use. Each module has a file describing its name, basic information about the module, as well as one or more blog posts/videos from people that have written about or used them.

This way we can reduce friction when people are starting out or are trying to solve similar problems.


When a new module appears on the PowerShell scene it can be difficult to advertise and gain mindshare among developers/end users who could be interested in it. There are also times when difficulties arise in finding if a good tool exists or not, if…

View original post 517 more words

#tsql2sday – NuGet, Visual Studio, PowerShell & dbatools

Of course that you heard the saying

“If the mountain will not come to Muhammad, then Muhammad must go to the mountain”.

Now replace mountain with NuGet and Muhammad with Powershell. Intrigued? Stick with me! 🙂

Before we dive in:

Since I’ve started to attend some community events, namely TugaIT (on this one I was also a volunteer) SqlSaturday,  and other local events, I’ve interacted with many people that are really cool and experienced and even became friends with some. One of those people is Rob Sewell, also known as sql dba with a beard (b | t), a man with an epic beard and an amazing personality. After seeing that he’s hosting this month’s “T-SQL Tuesday” I’ve decided to join.
The “challenge” (as I like to call it, since for me each blog post is a challenge) is simple:

“spend an hour or so with it and tell us how you got on and what and how you learned”

Ok so what have I done and how?

Just to give some context, I’m currently working with ASP.NET Core 2.0 and Entity Framework Core 2.0, using the “database first approach” meaning that whenever there’s a change on the database that changes the model (let’s say add a new table or a new column), there’s the need to reflect those changes on my .NET code.
The way of doing so is by using the Scaffold-DbContext that takes the connection string, the provider and outputdir as parameters (although outputdir is not mandatory, it’s highly recommended since you might want your model on a specific folder). With this you are set, just run the command specifying those parameters and you’ll see the changes reflected on you outputdir folder.

My problem:

There are some tables that I don’t want to be mapped on my .NET code (in my case those are the openiddict and Asp.NET Identity tables). Looking at the Scaffold-DbContext documentation, I can’t find a way to exclude the tables, but I can find a way to say which tables to include. It’s doable… if your database has something like 10 tables!
So, I thought: “How can I get all the tables on my database? And when I get them, how can I exclude those that should not be mapped?”. (please note that in this case, the tables have the same prefix, but we will see an example just ahead) In this post, I’ll be using the AdventureWorks2012 database.

dbatools to the rescue!

First time I’ve heard about dbatools was when Cláudio (b | t) told me that he started contributing to “this open source project developed by the community that aims to make the dba’s tasks easier”. Since that moment, I’ve been following their work, either via twitter or via slack where you can join too!


“That’s not for me, I’m not a DBA, I’m a backend developer”, “those commands must be for those database nerds, not for me”. Well, I’m also a backend developer who write some SQL queries, but there are some useful commands even for “non-dbas” as we will see.
Ok, so since dbatools is so easy to install (on windows 10 you just need to type Install-Module dbatools … ridiculously easy) let’s try to use the Scaffold-DbContext on the powershell console.
This cmdlet can be found on the Microsoft.EntityFrameworkCore.SqlServer package .Since the sintax to install the tools for Entity Framework core is just Install-Package Microsoft.EntityFrameworkCore.Tools, sounds like we can just open powershell and type it in.

Hum… not so easy. Well, the documentation tells us to open Visual Studio and open the Nuget Package Manager Console and type the command. Even more, here it’s stated that:

“The commands listed here are specific to the Package Manager Console in Visual Studio, and differ from the Package Management module commands that are available in a general PowerShell environment. Specifically, each environment has commands that are not available in the other, and commands with the same name may also differ in their specific arguments. “

There’s nothing left to do then because dbatools requires powershell and we can’t use the NuGet commands outside the Package Management Console, meaning we can’t use it on the powershell console.

That’s correct, but Microsoft does not say that you cannot use powershell commands on the Package Manager Console!

Let’s try it. Please pray so that it works!


Oh no! It’s red! Chill out and read the error. It’s just stating that in order to install dbatools it must be executed as administrator. I’ve simply ran Visual Studio as administrator, but probably the scoped install would also work (thank you Ed Elliott (b | t ) for point that 🙂 ) Doing so, we get the following:

In my case, I already had it installed, but you should have no problems now.
Now that we have dbatools installed, how is it going to help us? After a quick search I’ve found the Get-DbaTable that, among other parameters, returns the table name. Using the Get-Help command on the console we can see that:

We just need to pass the instance, the database name and our credentials. After that, we select the name property. In order to securely provide your credentials, use the Get-Credential cmdlet. Look at the following example:

Since we can use native powershell cmdlets like the Where-Object, we can easily filter the tables that are prefixed. Let’s assume that we don’t want to include any table that starts with “Employee”. We just need to pipe the result from the previous command to Where-Object {!$_.StartsWith("Employee")} (here you can see my “backend vein”, using the “!” and the StartsWith where I could have used the “pure powershell” and done with -NOT and LIKE) which results in:

$tableNames = Get-DbaTable -SQLInstance localhost -Database AdventureWorks2012 -SqlCredential $myCredentials | Select-Object -ExpandProperty Name | Where-Object {!$_.StartsWith("Employee")}.

Remember that all of this started because Scaffold-DbContext can receive an argument that is an array of strings, which corresponds to the tables to be mapped. Let’s see if we can put all of this together and get the expected result:

As we can see at yellow, we are getting warning because of some “problems” on the mapping for employees

Take it to the next level:

To avoid extension on this post, I’ll write another one, showing how you can make it even easier and do the scaffold in only one command like this:

I hope that this help you, not only with Scaffold-DbContext but with any other NuGet cmdlets (if I can call it that way) that depend on Powershell cmdlets.

My first Microsoft’s documentation correction experience

Since that at my job I’m currently developing under a lot of “things” that are new to me ( ASP.NET Core 2.0, Entity Framework Core 2.0, OpenIddict, Azure, etc), lately most of my time is spent reading Microsoft’s documentation. Sometimes, when reading some of those documents, I find some typos. After reading this post from Cláudio Silva (t | b), I’ve felt happier because now I can contribute to help fix those typos! It’s really simple and you can contribute to! Check out his blog post explaining you how.

The Microsoft team is really friendly and makes you feel good for contributing, even if it’s the smallest thing! Just so you understand what I’m saying, check this out :


Although this was not my first contribution (https://github.com/aspnet/EntityFramework.Docs/pull/470), I’ve felt really good even with just one little correction 😊

So if you find a typo, or even something that you don’t think that’s well written, make your corrections and submit a PR!

I mean… you even get your Github’s avatar featured on the MS’ documentation site! Am I the only want that finds it super awesome?


Thank you for reading!