Remove SQL Server components


Prerequisite MSI Inventory tool, which you can download

You can get the GUID associated with each installed product by searching around the registry, but I would rather use the MSI Inventory tool, which you can download ( from this OneDrive folder, and extract msiinv.exe

PowerShell script to use is:

## Remove SQL Server components
$a = .\msiinv.exe -s | Select-String "SQL Server" -Context 1,1;
$a = $a -replace "Product code:    ","msiexec /x """;
$a = $a -replace ">", "rem";
$a = $a -replace "\t", "";
$a = $a -replace "`}", "`}`" /quiet";
$a | Out-File .\remove.bat -encoding Ascii;


Posted in tools | Tagged , , , , | Leave a comment

WinRAR compress certain files with relative paths

Select tdp and Add to archieve…

Click Add > select tab Files , and add the something similar to the following in the Files to add field:

E:\code\tsm\tdp\..\*dbmanager.csproj E:\code\tsm\tdp\..\*dp.client.csproj E:\code\tsm\tdp\..\*fm.smo.csproj E:\code\tsm\tdp\..\*fm.smo.unittests.csproj E:\code\tsm\tdp\..\*tdpsqlc.vcxproj E:\code\tsm\tdp\..\*dpsqlengine.vcxproj


Posted in tools | Tagged | Leave a comment

Compact the VDI disk

cd /d "C:\Program Files\Oracle\VirtualBox"

To list the VM’s details run:

VBoxManage.exe list -l vms


Name:            RHINO W2012R2


SATA (0, 0): D:\VirtualBoxVMs\RHINO W2012R2\Snapshots/{57f6550e-f818-4bcd-9d46-9b99ef168e5f}.vdi (UUID: 57f6550e-f818-4bcd-9d46-9b99ef168e5f)


Name:            JACK W2012R2


SATA (0, 0): D:\VirtualBoxVMs\JACK W2012R2\Snapshots/{426e12f0-968a-4756-af0b-85f5bc22d466}.vdi (UUID: 426e12f0-968a-4756-af0b-85f5bc22d466)


To compact the VDI disk run:

in case of RHINO VM

VBoxManage.exe    modifyvdi        57f6550e-f818-4bcd-9d46-9b99ef168e5f   compact

in case of JACK VM

VBoxManage.exe    modifyvdi     426e12f0-968a-4756-af0b-85f5bc22d466  compact

Resize the VDI disk

  1. Remove any VirtualBox snapshots
  2. Provide the new size for the disk !!!
VBoxManage.exe modifyhd        "d:\VirtualBoxVMs\RHINO W2012R2\W2012R2.vdi" --resize 51200

Then expand the disk using Disk Management from inside the guest.

Posted in tools | Tagged , , | Leave a comment

Remotely setting network credentials using cmdkey

I have a task to automate the build on Azure VM with custom extension scripts. One of the tasks of the custom extension scripts is to map network drives [and save its credentials]. The custom extension scripts are automatically executed by Azure using the ADMIN user id. This causes problems as the mapped network drive resides in a different user domain. As a consequence, I have to create another script [map.ps1] which does the mapping and have it invoked from a wrapper script [deploy.ps1].

Please note snippets of my script:


$storageCred=”A long string of name value pairs containing the network user id and password”
$domainAdminUserId = “xxxx/yyyy”
$domainAdminPassword = ( ‘zzzz’ | ConvertTo-SecureString -AsPlainText -Force )
$domainAdminCredentials = New-Object -typename System.Management.Automation.PSCredential -argumentlist $domainAdminUserId, $domainAdminPassword

Enable-PSRemoting -Force
Invoke-Command -ComputerName localhost -FilePath “C:\FTPFiles\map.ps1” -Credential $domainAdminCredentials -ArgumentList $storageCred -Verbose


$storageCredArray = $storageCred.Split(‘~’)
$storageCredLookupTable = ConvertFrom-StringData ($storageCredArray | out-string)

Write-Host ‘Mapping file shares – started’ -ForegroundColor Green
$driveLetterAscii = [Byte][char]’X’

foreach ($usr in $storageCredLookupTable.Keys) {
$driveLetter = [Char][byte]$driveLetterAscii
CMDKEY /add:$ /user:$env:COMPUTERNAME\$usr /pass:($storageCredLookupTable.Item($usr))
Net Use ($driveLetter + “:”) “\\$\share” /SAVECRED /PERSISTENT:YES
if (Test-Path ($driveLetter + “:\Interfaces”)) {
Write-Host “$driveLetter mapped to $\share successfully” -ForegroundColor Green
} else {
Write-Host “Failure in mapping $driveLetter to $\share” -ForegroundColor Red

When I run this, it errors while adding the network credentials [cmdkey /add]. I get the following error:

CMDKEY: Credentials cannot be saved from this logon session

Any help on this is much appreciated.

That’s a limitation of the Cmdkey command – not really a PowerShell thing. But it’s related to the way Remotig handles credentials. The remote session doesn’t actually get a credential, it gets a delegated ticket, so there’s no token to actually save. That’s all by design, and not something you can reconfigure.


Posted in develop | Tagged , , , , | Leave a comment

AMD Ryzen Processors and motherboards

Posted in hardware | Tagged , , , , | Leave a comment

Windows 7 on SSD

Posted in tools | Tagged , , , , , | Leave a comment

C# Fundamentals

Posted in develop, Uncategorized | Tagged , , , | Leave a comment