Friday, February 17, 2023

Some remarks with PowerShell Core and Azure / PowerBI

All my scripts are under Windows and for automation what means that authentication to Azure is made using a Service Principal, a Register App. 
I'm working from a VM, so I want to use a certificate for Authentication. 

Working with a Proxy
Most people nowadays work behind an enterprise proxy. 
pwsh makes the live more easy behind a proxy - it gets all configuration from IE, so you can even use a pac file - but also implement some diferences. 
With older PowerShell versions, a common configuration was:

$proxyUri = "http://MyProxyUrl:MyProxyPort"
[System.Net.WebRequest]::DefaultWebProxy = new-object System.Net.WebProxy ($proxyUri, $true) 

With PowerShell core this is now: 

$proxyUri = "http://MyProxyUrl:MyProxyPort" 
[System.Net.Http.HttpClient]::DefaultProxy = New-Object System.Net.WebProxy( $proxyUri ) 

PowerShell AzureAD 
It's almost impossible to use a certificate to authenticate with AzureAD module. It works fine under an user, but installing the certificate as computer level normally it will not work. I give up to use AzureAD module because of this error: 
"Connect-AzureAD Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly

I had no luck finding a workaround for this problem..

PowerShell Microsoft. Graph 
Shifting to Microsoft. Graph was almost transparent. Only permissions are now with a different setup in Azure. Make sure that permissions are assigned to application:

 

Parameter -Scope is not available for Service Principals, so all permission configuration is on Azure. 
After connection the available permissions can be listed using:

 (Get-MgContext).scopes
User.Read.All

 

Monday, April 19, 2021

Monday, November 16, 2020

SQL Server - Rebuild all indexes for all tables in a single database

Tuesday, November 19, 2019

Move or relocate /var to another partition in CentOS 6.8

A few steps to easily move or relocate /var in CentOS 6.8:

Start by sudo bash.

- Mount the future /var with a different name, like /newvar.
  Tip: Setup fstab to use /newvar and use "mount -a" will also help you checking if fstab is fine.
- Copy current /var to new location with rsync:
       rsync -aqxP /var/* /newvar
- fix the security contents with
       restorecon -r -v /newvar
- adapt fstab to mount the new /var (if you had setup fstab to /newvar now is the time to set it to /var)
- reboot

Tuesday, February 19, 2019

Use [by default] TLS 1.2 on PowerShell

As simple as this:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Saturday, July 14, 2018

TP-Link MR3420 and Vodafone Modem K5160

TP-Link MR3420 v2 refused to work with my new K5160.

The firmware from TP-Link didn't help so I give a try on "Of Modems and Men" firmware [ROOter].
It's quite simple to install the firmware (but be aware that rollback is not so simple).

ROOter firmware identified the modem correctly but still no connection to the internet. It seems that the hostless modem is still working as MBIM.

The trick is to ssh to the modem, rename /sbin/umbim to something else and reboot the router. 

Thursday, May 10, 2018

Get size of each table on MS SQL Server database

Simple query to get the size of each table on Microsoft SQL Server database.