Recently in one of my Virtual Machine (VM)s I received the above error message when trying to connect to a SQL Server which I used to connect on other times.

image

After having a look I found that the trust between my virtual machine and the domain was broken. You can find the status of the secure channel by using the PowerShell command Test-ComputerSecureChannel.

image

This will also be evident when you try to login to the computer using a domain account. It will generate the following message.

image[6]

To fix this you can try using the below methods.

1. PowerShell

Use the command Test-ComputerSecureChannel.

If your current login has the required access in the domain you can use the below command.

Test-ComputerSecureChannel –Repair

If you need to use another account than the current logged user then you need to use the –Credential parameter when calling the command.

Test-ComputerSecureChannel –Repair –Credential MyDomain\MyUser

2. Joining the domain again.

This will also get fixed by removing the machine from the domain and adding it back. Before removing the computer from the domain make sure you have access to a local administrator account on the computer. Otherwise you will not have a way to login to the computer.

This can be achieved by going to computer system properties,

  1. removing the computer from the current domain,
  2. restarting the computer.
  3. adding the computer to the domain again
  4. restarting the computer

To avoid the two restarts you can try using the following PowerShell commands.

$myPC = Get-WmiObject Win32_ComputerSystem
$myPC.UnjoinDomainOrWorkGroup("Account Password", "Account Username”, 0)
$myPC.JoinDomainOrWorkGroup("Domain", "Account Password", "Account Username", $null, 3)
Restart-Computer -Force

Advertisements

While trying to setup and use the Code Plugin by Rich Hewlett I had trouble getting the plugin loaded into Live Writer. I did add the registry entry required as mentioned in the site, but still the plugin did not load.

Registry

Location – HKEY_CURRENT_USER\SOFTWARE\OpenLiveWriter\PluginAssemblies

Key – SyntaxHighlight_WordPressCom_OLWPlugIn

Value – C:\Users\Arjuna\AppData\Local\OpenLiveWriter\Plugins\SyntaxHighlight_WordPressCom_OLWPlugIn.dll

After a while I figured out that, when loading the plugin Live Writer encounters the following error.

"System.IO.FileLoadException: Could not load file or assembly ‘file:///C:\Users\Arjuna\AppData\Local\OpenLiveWriter\Plugins\SyntaxHighlight_WordPressCom_OLWPlugIn.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: ‘file:///C:\Users\Arjuna\AppData\Local\OpenLiveWriter\Plugins\SyntaxHighlight_WordPressCom_OLWPlugIn.dll’ —> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

This is due to a security feature of .Net Framework 4 or later. Before framework 4, if a DLL is downloaded (which is created in another computer), they used to run in full trust in the zone the assembly is running, but with frameworks 4 and later, downloaded DLLs will not run by default. To make them run, simply grant the DLL full access by going to file properties and selecting the Unblock checkbox in the security section as seen in the below image. This will apply to any plugin you download from internet. Also keep in mind to do this to DLLs you trust safe. Otherwise your computer will be unsafe.

image

To troubleshoot plugin and other errors you can refer to Open Live Writer log file located in C:\Users\Arjuna\AppData\Local\OpenLiveWriter\Open Live Writer.log.

With the unavailability of Windows Live Writer for newer versions of Windows, a good replacement for it is Open Live Writer. It is a open source application which enables you to create, edit and publish blog posts. Since the code is based on the Windows Live Writer, it looks and behaves the same so whoever used Windows Live Writer will find it easy to use.

It can be downloaded using the Open Live Writer web site.

You will be able to find plugins to use with the writer. If you are needing to post source code you can try the Code Plugin by Rich Hewlett.

image

Recently I was interested in finding a way to monitor a windows service. What I needed was to check whether the service is running and if not running get a notification and try to restart the service. Following PowerShell script does exactly that, it checks for Microsoft CRM Asynchronous Service and the Microsoft CRM Asynchronous Maintenance Service activity and send 2 emails to Admin and Dev. This needs to be then scheduled using Windows Task Scheduler or SQL Server Job.

### Checking for CRM Async and Maintenance service failure and try restarting, if failing send an email notification.

 

## Function to send mail notification.

function Send_Email ([string]$strEmailSubject, [string]$strEmailBody)

{

       $EmailFrom = "Arjuna@Email.com"

       $EmailTo = "Admin@Email.com, Dev@Email.com"

       $EmailSubject = $strEmailSubject

       $EmailBody = $strEmailBody

       $EmailSMTPServer = "SMTP.server.com"

       ## Creating Mail Message object.

       $SMTPMessage = New-Object System.Net.Mail.MailMessage $EmailFrom, $EmailTo, $EmailSubject, $EmailBody

       ## Enabling HTML mail body.

       $SMTPMessage.IsBodyHtml = $true

       ## Creating SMTP client object.

       $SMTPClient = New-Object System.Net.Mail.SMTPClient $EmailSMTPServer

       ## Sending mail.

       $SMTPClient.Send($SMTPMessage)

       ## Sending mail method 2.

       ##send-mailmessage -from "Arjuna@Email.com" -to "Admin@Email.com, Dev@Email.com" -subject "CRM Async Service Failed" -body "Please check." -smtpserver "SMTP.server.com"

       ## Sending mail method 2 using parameters.

       ##send-mailmessage -from $EmailFrom -to $EmailTo -subject $EmailSubject -body $EmailBody -smtpserver $EmailSMTPServer

}

 

## Function to check the service activity.

function Check_Service

{

       ## Get all services which has a Name like MSCRMAsyncService, Start Mode is Auto and service State is Running.

       $FailedAsyncService = Get-WmiObject Win32_Service | Where-Object {$_.Name -like ‘MSCRMAsyncService’ -and $_.StartMode -eq ‘Auto’ -and $_.State -ne ‘Running’} | Select-Object DisplayName

       ## For Testing.

       ##Write-Host "A: " $FailedAsyncService

 

       ## Get all services which has a Name like MSCRMAsyncService$maintenance, Start Mode is Auto and service State is Running.

       $FailedAsyncMainteService = Get-WmiObject Win32_Service | Where-Object {$_.Name -like ‘MSCRMAsyncService$maintenance’ -and $_.StartMode -eq ‘Auto’ -and $_.State -ne ‘Running’} | Select-Object DisplayName

       ## For Testing.

       ##Write-Host "B: " $FailedAsyncMainteService

 

       ## Checking whether the Async Service has failed.

       if ($FailedAsyncService -ne $NULL)

       {

              ## Trying to start the failed Async Service.

              Start-Service -displayname "Microsoft Dynamics CRM Asynchronous Processing Service"

              ## Service Name can also be used to start the servie.

              ##Start-Service MSCRMAsyncService

              ## Get all services which has a Name like MSCRMAsyncService, Start Mode is Auto and service State is Running.

              $AsyncServiceStarted = Get-WmiObject Win32_Service | Where-Object {$_.Name -like ‘MSCRMAsyncService’ -and $_.StartMode -eq ‘Auto’ -and $_.State -ne ‘Running’} | Select-Object Name

              ## Checking the service to see whether it started.

              if ($AsyncServiceStarted -ne $NULL)

              {

                     ## Calling Send_Mail function to notify.

                     Send_Email ("CRM Async Service Failed.") ("System has detected that the following CRM Async Service has failed. System automatically tried restarting the service but it was unsuccessful. Try manual start. <BR/><BR/>" + $FailedAsyncService)

              }

              else

              {

                     ## Calling Send_Mail function to notify.

                     Send_Email ("CRM Async Service Restarted.") ("System has detected that the following CRM Async Service has failed. System automatically tried restarting the service and it was successful. <BR/><BR/>" + $FailedAsyncService)

              }

       }

 

       ## Checking whether the Async Maintenance Service has failed.

       if ($FailedAsyncMainteService -ne $NULL)

       {

              ## Trying to start the failed Async Maintenance Service.

              Start-Service -displayname "Microsoft Dynamics CRM Asynchronous Processing Service (maintenance)"

              ## Get all services which has a Name like MSCRMAsyncService$maintenance, Start Mode is Auto and service State is Running.

              $AsyncMainteServiceStarted = Get-WmiObject Win32_Service | Where-Object {$_.Name -like ‘MSCRMAsyncService$maintenance’ -and $_.StartMode -eq ‘Auto’ -and $_.State -ne ‘Running’} | Select-Object Name

              ## Checking the service to see whether it started.

              if ($AsyncMainteServiceStarted -ne $NULL)

              {

                     ## Calling Send_Mail function to notify.

                     Send_Email ("CRM Async Service Failed.") ("System has detected that the following CRM Async Service has failed. System automatically tried restarting the service but it was unsuccessful. Try manual start. <BR/><BR/>" + $FailedAsyncMainteService)

              }

              else

              {

                     ## Calling Send_Mail function to notify.

                     Send_Email ("CRM Async Service Restarted.") ("System has detected that the following CRM Async Service has failed. System automatically tried restarting the service and it was successful. <BR/><BR/>" + $FailedAsyncMainteService)

              }

       }

}

 

## Calling the Check_Service function.

Check_Service

It seems to be easy to replace the internal lights of your car if you would like to do it your self. Recently I did change my Halogen lights to LED. Following steps are for a 2011 Toyota RAV4, but some of the steps may be applicable to other vehicle models as well.

Vanity Lights

You can remove the vanity light by inserting a flat head screw driver or a panel remover tool from the left side of the light. If you are using a screw driver, you can use a cloth to minimise the damage caused. Be careful not to try from the right side, since the wire connections are there on the right side. So if you try forcing it out from the right side, it will break. You will get the idea from the below images.

Vanity 1Vanity 2

Cargo Area Light

Cargo light is the light on the back door of the RAV4, this can be easily removed by inserting a tool from the side where the switch is located. Do not try from the other side since it will break.

Once the light assembly is removed you need to remove the plastic cover to access the light. If you are replacing the globe with a LED, remember to turn the LED to the other side, so the light will emit to the cargo area. You will be able to get a better understanding by the following pictures.

Cargo (1)Cargo (7)Cargo (8)Cargo (9)

Cargo (10)Cargo (11)

Recently I did upgrade the interior lights of my car, since there are not much articles with the steps,  thought this will be helpful to the other readers.

1. Use a car trim remover tool or a flat head screwdriver to gently remove the light cover. If using a screwdriver, it is better use a cloth to reduce the damage to the plastic components.

You just need to insert the tool in the below marked areas to get it undone. Note that we re only removing the lens cover, not the entire dome light assembly. So insert the tool between the lens cover and the plastic.

image

image

2. You will be able to pull the existing bulb without much effort.

image

After replacing the globe, remember to check before fitting the cover.

image

Recently I was interested in replacing the Halogen map light bulbs with LEDs, I thought this might be useful for other readers as well if I let you know the steps to do it. Even though I did it on a Toyota RAV4 2011 model, some of the steps may be helpful to do the same on other vehicles. But be careful since if you do it wrong things might break.

It is always better to use a trim panel remover tool to reduce the damage caused by just using a flat head screw driver. If you have to use a screwdriver, use a cloth to minimise the damage.

image

1. Using a panel remover, flip the top and bottom of the lens covers to remove the lens covers.

Dome 1

Below images will show you the mechanism holding the lens cover, so you just need to insert the tool at the right location and gently tilt the tool to get it removed. For example if you insert the tool from the right or left sides and use force, then the small plastic piece will break, needing you to buy a new one.

imageimage

2. Once the covers are removed you will see the light globes, here you need to be careful. To remove the globes you just need to pull the globe out from the holder. If you turn the globes then the holder will get detached. If you are not too careful the released holder will fall in.

In case you rotate the holder, very carefully rotate it back to the place, before it falls inside.

3. After taking the globe out you can put the new globe in and fit the lens cover back. remember to check the light before fixing the lens cover.

image

In case your holder fell inside, then you can try few ways to get the holder back.

a. Use a magnet to try to get it out.

b. Carefully use a cable to get it.

c. Remove the entire map light assembly.

Since both a. and b. will have less percentage of success, I will explain how to remove the entire assembly. Since most Toyota’s do not use screws many components are held in place by clips. Mostly they will be plastic. So you need to know where to pull / push so you are not going to break any.

To remove the map light assembly you just need to pull hard to detach the 4 plastic clips see below. It may be really hard so some tools might help.

image

There is a small black connector which connects the lights to the vehicle’s electricity system. This can be removed by pressing the lock and pulling.

imageimage

Hope this helps you to stay out of trouble or save some hours while replacing your globes.