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

SQL Server - Check all databases with "Auto Close" active

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.

Monday, June 26, 2017

IE11 on Windows Server 2008

Some notes:

- Download from MS is the same as windows 7;
- This can safe you same time: ie11 install error

Please notice when you cut & paste " from a website to the command line prompt sometimes it does not work. Just clear the quotes and add them again.

Friday, February 24, 2017

Reseting a SMC 8612T Tiger switch

What if you lost the password of an old SMC 8612T Tiger ?

The manual says that you should connect via console and use Ctrl U when it starts but this procedure will lead you to a password prompt. The password that you don't know.

Instead, use Ctrl F. As simple as that. SMC, please fix your manuals.

Tuesday, February 2, 2016

Windows KMS Server - Licenses

Diagnosing KMS is quite simple. Microsoft has a nice technet how-to here.

It shows this interesting command: SLMGR.vbs /dlv

It's also nice to know the registry settings on the client.

Tuesday, March 31, 2015

Error installing Java on Windows 8

If you get into this error while installing Java on Window 8:



Just delete this file:

<User Application Data Folder>\LocalLow\Sun\Java\Deployment\deployment.properties


Saturday, April 26, 2014

Google Drive API - contains querying a title

If you are using Google Drive API to list files be aware:

title contains <YourString> should be taken as title STARTING WITH <YourString>

If you have a file title such as  foo.extension  :


  1. title contains 'foo' will be on the results
  2. title contains '.extension' will not
  3. title contains 'foo.e' will work ok as well

Use  fullText contains  to get the correct results.

  

Thursday, October 31, 2013

Cisco Prime Infrastructure logs

Looking at Cisco Prime Infrastructure logs is annoying: if the logs are small, you can email them, but did you see any installation with small logs? The option to download the logs makes the appliance to zip ALL log files before they can be downloaded. It takes time.

At this time, on Cisco Prime Infrastructure, you can keep a maximum of  20 log files of 50 Mb.

Since there is no option to download just the ncs-* files, I use to ssh login into the console, get root, and ftp the files out of the server. The log files are located on:

/opt/CSCOlumos/logs

That's it.


Sunday, June 2, 2013

TP-Link TL-MR3420 and the new 4G Huawei E392u-12 (TMN Portugal)

Just a quick note to let you know that the TP-Link TL-MR3420 works like a charm with the 4G card from TMN Portugal - Huawei E392u-12.

You just need to upgrade the router firmware and use the modem binary from TP_Link site.

If you are wondering about transfer speeds, I've got 26 Mbit/s for downloads and an amazing 18 Mbit/s for uploads.

Tuesday, February 26, 2013

Cisco Switch reset a single port to factory defaults

I keep forgetting this forget-about-it-and-start-all-over-again command, so here it is a small example:

in mode config:

default interface fa0/18

 

Thursday, January 10, 2013

VMWare Player 5 and Drive Shrinking

It's been a while since I play with VMWare at desktop level. Since I need a Delphi development environment that I could easy transfer between two machines, I thought to give it a try.

VMWare Player just rocks on the new i5 processors. Creating the Virtual Machine and playing around was really easy, until I get into VMWare Tools.

I remember that there was a control panel applet to start VMtools. There isn't any more. I google around for a couple of hours, and I get no information about this. And googling for "Shrink VMWare Disk" always mention the VMTools applet.

I run into the uninstall / install process for some times, until I give up. Something should be really wrong.

Finally I noticed that the applet is not available since version whatever.  You need to use the command line tools. On a Windows 7 guest this is as easy as opening a command line with administrator rights, and invoke the VMWareToolBoxCmd.exe utility.

But before you use the shrink option, you should "zeroing" the hard disk. You can do this using SDelete utility from windows sysutils: download it here.

Use SDelete with -z parameter on each drive before you run the shrink utility. Something like:

sdelete -z C:\

After it, you are ready to go:

<Open Administrator Command Line>
cd "\Program Files\VMWare\VMWare Tools"

This will show you some interesting information:
VMwareToolboxCmd help disk

but if you just want to shrink all disks just run:
VMwareToolboxCmd disk shrinkonly

SDelete it. Shrink it. Stay Free.

Saturday, October 27, 2012

Things to do on a new Ubuntu Box

This is a "note to self" list:

1) apt-get install joe
joe is the best linux editor ever

2) joe ~/.bash_aliases

alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'

[work in progress]

Dear Ubuntu,

I'm an experienced linux sysadmin.

I used a bunch of linux distributions all over the years, and I just got my first Ubuntu box to admin.

I just notice that there isn't by default an alias rm = rm -i.

I don't love you anymore.

Artur





Tuesday, July 10, 2012

Using lkJSON - an example with Google Drive data

lkJSON is free (BSD license) JSon parser for Delphi. It works great with Delphi 7.

lkJSON Source: http://sourceforge.net/projects/lkjson/

When you are looking for a JSon parser, you look for someting that you can use in the next minute. There is no documentation for lkJSON, just a few examples included with the sources. I hope this quick and dirty example can save you some time.

A Google Drive API returns you something like this:



And here is some Delphi code:



stay free.