27 October 2023

Autofit Excel sheets constantly

While your Excel sheet open, press ALT+F11


and double-click on the Sheet1 to open the blank window


copy this code there

Private Sub Worksheet_Change(ByVal Target As Range)

    Me.Cells.EntireColumn.AutoFit

End Sub


and close the Visual Basic window.

If you make a change to a single cell, all the columns will automatically adjust their width



19 October 2023

Get-WmiObject works on PowerShell 7

 Yeah, a lot of people are saying that you cannot use Get-WmiObject in PowerShell 7 and you must use instead Get-CimInstance. Well, this is true and also not true.


I have PowerShell based WMI scanner to scan all servers in domain to discover disk free space. Some are older Windows versions and Get-CimInstance does not get result back, so I want to use Get-WmiObject -Computername instead.


To enable Get-WmiObject use this command:


Import-Module Microsoft.PowerShell.Management -UseWindowsPowerShell


After that your Get-WmiObject is working