Friday, February 25, 2022

Cannot open backup device. Operating system error 5(Access is denied.). RESTORE HEADERONLY is terminating abnormally. (Microsoft SQL Server, Error: 3201)

Came across this error while trying to restore a SQL database backup which was stored in a container to Azure SQL managed instance.

Operating system error 5(Access is denied.).
RESTORE HEADERONLY is terminating abnormally. (Microsoft SQL Server, Error: 3201)

The blob would connect properly and show the backup file.

Solution:

Deleted the stored credentials in the database and did the process again for restoring backup.





Monday, February 14, 2022

Service time out. Failed to start in time : ServicesPipeTimeout registry setting

Create the following DWORD registry key in on your Windows Server in.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control

Name: ServicesPipeTimeout
Type: REG_DWORD
Data: The number of milliseconds that you want to give the services to start in.

 

I have entered 300000 which is 5 minutes.

 

 

 Here is a small script if you want to run this on multiple servers remotely.

$colComputers = @("GATEWAY1","GATEWAY2")

foreach ($strComputer in $colComputers)

 {
  #Open remote registry
  $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $strComputer)
  #Open the targeted remote registry key/subkey for read and write ($True)
  $regKey= $reg.OpenSubKey("SYSTEM\CurrentControlSet\Control",$True)
  $regKey.Setvalue('ServicesPipeTimeout',300000, 'dword')
  $reg.Close
 }

 

Thursday, December 9, 2021

Firefox install add on error

Error: Unexpected error occurred while installing add ons in Firefox.


Fix: Create the following registry key if its not there. If its present, set the value of Default to 1

 

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Mozilla\Firefox\InstallAddonsPermission]
"Default"=dword:00000000

 

Thursday, December 2, 2021

Resize Azure VMs using Az powershell.

Script to resize Azure VM's from any subscription. If a VM is stopped it will resize it. If it is running it will stop the VM and resize it.


#$NewSize = "Standard_D8s_v3"

$NewSize = "Standard_E4s_v3" 

#$NewSize = "Standard_DS1_v2"

Function Out($message) {
$message = $(Get-Date -Format "MM/dd/yyyyTHH:mm:ss") + ":" + $message
Write-Output $message}

Out "Vm resize script starting...."

function Connect($tenantid)
{
$username = "username@contoso.com"
$password = ConvertTo-SecureString -AsPlainText -Force "password" 
$pscredential = New-Object -TypeName System.Management.Automation.PSCredential($username$password)
Connect-AzAccount -Credential $pscredential -Tenant $tenantId -EnvironmentName AzureUSGovernment
}

Function Resize-VM($VM)
{
 
  Out "Resizing $($vm.name) in $($vm.ResourceGroupName) from $($VM.HardwareProfile.VmSize) to $NewSize"          ## Change here
   $VM.HardwareProfile.VmSize = $NewSize
  Update-AzVM -ResourceGroupName $vm.ResourceGroupName -VM $VM 
}


Function CheckVM($VM)
{            
   if((Get-AzVM -Name $VM.Name -Status).PowerState -eq "VM running")
     {
       Out "$($VM.Name) is resized and Started"
     }
     else {
         Out "$($VM.Name) is resized and not started"
      }
     
}

Connect "put your tenant id here"


$VMList = @("VM1","VM2" ## comma separated list of VM's
)
$Allsubs = Get-AzSubscription 

foreach($sub in $Allsubs)

{
   Select-AzSubscription -SubscriptionId $sub.SubscriptionId | Out-Null
  $VMS = Get-AzVM -Status 
 
foreach($vm in $VMS)
{
 
 foreach($v in $VMList)
   {
     if($v -eq $Vm.name)
      {
        
      if($vm.PowerState -notmatch "VM running"## If the VM is switched off.We resize but dont start it.
        {
          #Resize the vm
          Out "VM $($VM.Name) is already powered off.Resizing...."
          Resize-VM $VM
          
        }

     Else # If the VM is turned on. Turn it off, resize and start it.
        {
          Out "VM is powered on. So Stopping $($VM.Name)"
          Stop-AzVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName -Force
          Start-Sleep -Seconds 120
          #Get VM Status
          if((Get-AzVM -Name $VM.Name -Status).PowerState -eq "VM deallocated")
             {
               Out "$($VM.Name) is now off. Resizing...."
               Resize-VM $VM
               Start-AzVM -Name $VM.Name -ResourceGroupName $VM.ResourceGroupName
               Start-Sleep -Seconds 300
               CheckVM $VM

         }
                 
      }
   }
}

}
}


Wednesday, October 20, 2021

SQL intellisense not working

The following are not a sequence of steps. You can try each one of these and something might work.

Check if you have  intellisense enabled.

 

If the Intellisense is not working only for certain databases.Keep the top check box enabled but remove the underline errors and outline statements.  Open a new query window and check.


  Disable SQLCMD mode.

 

Refresh Local Cache.