Thursday, June 9, 2016

How to Remove Azure Account (Cached) using PowerShell

Recently I’ve done quite a lot of testing using various accounts to Azure.  All the commands are executed in the PowerShell ISE (Run ISE are Administrator).

The PowerShell should have the Azure Commands in it already.  If not, can download from here.

Select the Install from the Command-line tools

image

When I tried to Get-AzureAccount, it displayed more than one account and subscriptions

image

I need to remove the other subscriptions.  Therefore I perform as follow :

image

Execute the command as below :

  • Get-AzureAccount | format-table id

Once displayed, I execute to remove the account using

  • Remove-AzureAccount account-name

Note : Just replace the account-name with the account that needs to be deleted.

Another way is to remove all the accounts then re-add it back. 

To do this execute it as below to remove all the accounts :

  • Get-AzureAccount | ForEach-Object {Remove-AzureAccount $_.ID -Force}

To add the account that I’m working on, use :

  • Add-AzureAccount

 

keys : add azure account, remove azure account in cache, Azure powershell command line, command-line, azure subscription, AzureSubscription, get-azureaccount, remove-azureaccount, Azure SDK

Thursday, May 26, 2016

Reset Local Administrator Password for Azure VM

Recently I had set up quite a couple of VMs in Azure and one of the VMs local administrator’s password I’ve keyed in wrongly and totally forgotten what is it anymore.

So in the Azure new portal there’s a feature to reset the password.

Local Administrator username : bkhoo

The steps taken are as below :

    image

    • On the left menu bar click on the Virtual Machines
    • In the Virtual Machines, select the specific Virtual Machine that want to reset the local administrator password.

    image

    • In the settings menu on the right, click Reset password .

    image

    • Key in the new password and confirm password, then click on Reset 

    Then I test it, I can now RDP into the VM using the new reset password .

    keywords : forgot password,local administrator password, Azure VM, Virtual machine password, how to reset local administrator password in virtual machine, VM, VMs, virtual machines

    Monday, April 4, 2016

    Killing a Hung VM in Task Manager (Another PowerShell command)

    This is another command of how to kill a Hung VM by identify the Process ID using PowerShell command :

    image

    For Windows 2012

    Get-WmiObject -Namespace root\virtualization -class msvm_computersystem | select elementname, operationalstatus, processid, name| ft –auto

    For Window 2012 R2

    Get-WmiObject -Namespace root\virtualization\v2 -class msvm_computersystem | select elementname, operationalstatus, processid, name| ft –auto

    Once the Process ID is obtain, launch the Task Manager and kill the VMWP.exe process with the correspondence Process  ID to that particular VM.

    image

    Hope this helps.

    keywords : hang VM, hung VM, stuck VM, Hyper-V virtualization stuck Server 2012 R2, vmwp.exe, killing vwmp.exe

    Killing a Hung VM in Task Manager

    Sometimes the VM we tried to stop hangs.  So in order to kill the process using the Task Manager, we can end process of VMWP.exe.  But the next question is which one.  Each VM has a unique Process ID.

    image

    Therefore, I launch the elevated Powershell by executing the following command below

    Get-WmiObject win32_process -Filter "Name like '%vmwp%'" | Select-Object ProcessID, @{Label="VMName";expression={(Get-VM -Id $_.commandline.split("")[1]|Select-Object VMName).VMName}}|ft –AutoSize

    image

    So I go back to the Task Manager and Right-Click on it and end task,base on the Process ID of that particular VM.

    image

    Hope this command helps you as it helped me.

    keywords : hang VM, hung VM, stuck VM, Hyper-V virtualization stuck Server 2012 R2, vmwp.exe, killing vwmp.exe

    Friday, March 11, 2016

    DPM 2012 Reporting Issue (ID : 220)

    After upgrading from SCDPM 2012 SP1 to SCDPM 2012 R2, I hit the issue when I tried to configure the Reporting to be send out periodically in the Report Module of SCDPM 2012 R2.

    image

    The steps taken was the following :

    • Launch the Reporting Services Manager (in my example is SQL 2008 R2, since it’s upgraded gradually from SCDPM 2012 SP1 to SCDPM 2012 R2)
    • Ensure to the correct database that I’m pointing to  (e.g. MSDPM2012)
    • Navigate to E-Mail Settings.
    • Key in the valid Sender Address and SMTP Server.
    • Click Apply

    SNAGHTML5532c4a

    • Launch the SCDPM 2012 R2 – Reporting
    • Configure the schedule reporting with emails, tested with no issues.keywords : SCDPM 2012, DPM cannot enable e-mail subscription for reports unless SMTP details are configured in the remote SQL Server Reporting Service Installation. SMTP details need to be configured manually when an existing SQL Server is chosen to be used for DPM during DPM setup.  Please enter the SMTP server name, SMTP port number and SMTP From address manually in the SQL Server Reporting Services configuration File.
      Configuration file path : c:\Program Files\Microsoft DPM\SQL\MSRS10.MSDPM2010\Reporting Services\ReportServer\RSReportServer.config
      The SMTP Server  details on the SMTP Servers tab in the Options dialog enables only DPM alert notifications. For more details, see DPM Help (ID : 220)
      SCDPM Report error, Systems Center Data Protection Manager Report Error, cannot configure email distribution in DPM report

    Friday, March 4, 2016

    Systems Center Data Protection Manager 2012 R2 Keeps Crashing – ID:917

    Have managed to upgrade from SCDPM 2012 SP1 to SCDPM 2012 R2.  The DPM agents and the Protection Groups are still intact.

    However, when I tried to edit or remove the Protection Group, the SCDPM 2012 R2 Administrator console keeps crashing and restart the DPM Administrator Console

    image

    After finding out, the issue is NOT the Data Protection Manager, but it’s the SQL that is storing the DPM Database.  The SCDPM 2012 R2 has also been patched with UR6, however it still crash whenever I tried to edit or remove the Data Protection.

    Therefore these are the steps taken.

    • Take a backup of the DPM Database
    • Right-click on the SQL Management Studio and select “Run as administrator”

    SNAGHTML1b6d0e

    • Once the SQL Management launched, right-click on the DPMDB and select “New Query
    • Copy and paste the following SQL Script
    update tbl_IM_ProtectedGroup 
    SET IMCatalogXML = replace(cast(IMCatalogXML as nvarchar(max)), '<AllowedBackupType>FullBackup', '<AllowedBackupType>Regular')  
    from tbl_IM_ProtectedGroup where IMCatalogXML like '%<AllowedBackupType>FullBackup%' 
    • Click Execute and it should show the results.  The example is as above picture. 
    • Launch the SCDPM 2012 R2 Administrator Console, and it’s successful can edit or remove the Protection Group.

    keywords : SCDPM 2012 R2, upgrade of SCDPM 2010 to SCDPM 2012 R2, Error : 917, Systems Center Data Protection keeps crashing after upgrade in place, in-place, inplace, Restarting Administrator Console.

    Monday, February 29, 2016

    "Cannot connect to WMI provider. You do not have permission or the server is unreachable" in SQL Server

     

    When trying to open MS SQL Server Configuration Manager, a dialog may appear..

    image

    Cannot connect to WMI provider. You do not have permission or the server is unreachable. Note that you can only manage SQL Server 2005 and later servers with SQL Server Configuration Manager. Invalid class [0x80041010]

    Cause :
    An issue with the compiled SQL Configuration Manager GUI’s communication with WMI.

    A work around is as follow :

    Open a command prompt (elevated, run as administrator)

    Then Navigate to your SQL version’s shared directory (cd <version path>):

     

    SQL 2008 C:\Program Files (x86)\Microsoft SQL Server\90\Shared\
    SQL 2008 R2 C:\Program Files (x86)\Microsoft SQL Server\100\Shared\
    SQL 2012 C:\Program Files (x86)\Microsoft SQL Server\110\Shared\
    SQL 2014 C:\Program Files (x86)\Microsoft SQL Server\120\Shared\

    After that execute the following command :
    mofcomp sqlmgmproviderxpsp2up.mof

    image

    After that reboot the server to get all related services to start.

    keywords : Cannot connect to WMI provider. You do not have permission or the server is unreachable. Note that you can only manage SQL Server 2005 and later servers with SQL Server Configuration Manager. Invalid class [0x80041010]; SQL,