How to make a widget for Blogengine.net 2.0

by Ron 13. augustus 2011 11:03
  1. Make a Web User Control in Visual Studio the way you always do. If you never made a user control, try to learn how to make one first before you continue.
  2. Go to the folder widgets and copy a folder. For this example we copy the Calendar folder.
  3. Rename te folder to something new. For example Calendar2

  4. In the widget.ascx.cs file, put the foldername here (it must be exactly written as the name of the folder ----> Calendar2):

  5. In the widget.ascx file, rename the Inerits part to Calendar2 and the namespace in the widget.ascx.cs file to namespace Widgets.Calendar2:





  6.  Now try to load the new widget. The advantage is that you can see errors later on.

  7. After this step, you are almost there. Find #region Public Methods in widget.ascx.cs: 


    public override void LoadWidget()
    {
    //PLACE YOUR ASCX code (webuser control code, page load part) HERE. 


  8.  Copy and paste the classes in your code from your ascx (web control) file:



  9. Now your widget should work! Here the empty code to get started:

widget.ascx

 

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="widget.ascx.cs" Inherits="Widgets.Calendar2.Widget" %>

<%@ Import Namespace="BlogEngine.Core" %>

<div style="text-align: center">

////////////YOUR CODE HERE/////////////

</div>

 

widget.ascx.cs

 

using ////////////YOUR CODE HERE/////////////

using App_Code.Controls;

namespace Widgets.Calendar2

{

    public partial class Widget : WidgetBase

    {

        #region Properties

        public override bool IsEditable

        {

            get

            {

                return false;

            }

        }

        public override string Name

        {

            get

            {

                return "////////////YOUR FOLDERNAME HERE/////////////";

            }

        }

        #endregion

        #region Public Methods

        public override void LoadWidget()

        {

 ////////////YOUR CODE HERE/////////////

 }

        #endregion

    }

}

How to find the IP numbers of your VM's in Hyper-V CORE

by Ron 27. juli 2011 09:34

I don't know why but I always seem to forget the IP numbers of the VM machines I run in Hyper-V. The PowerShell Management Library for Hyper-V at http://pshyperv.codeplex.com does not include a script to do this so you have to use a script of yourself.

To find out specific information about the ip address of a VM, I am using the following script I found at http://luka.manojlovic.net/category/ms-scripting/powershell/

 

 

$vm = "!!!NAMEOFYOURVM!!!";

filter Import-CimXml

{

    $CimXml = [Xml]$_

    $CimObj = New-Object -TypeName System.Object

    foreach ($CimProperty in $CimXml.SelectNodes("/INSTANCE/PROPERTY"))

    {

 if ($CimProperty.Name -eq "Name" -or $CimProperty.Name -eq "Data")

 {

         $CimObj | Add-Member -MemberType NoteProperty -Name $CimProperty.NAME -Value $CimProperty.VALUE

 }

    }

    $CimObj

}

$VmObj = Get-WmiObject -Namespace root\virtualization -Query "Select * From Msvm_ComputerSystem Where ElementName='$vm'"

$KvpObj = Get-WmiObject -Namespace root\virtualization -Query "Associators of {$VmObj} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent"

$KvpObj.GuestIntrinsicExchangeItems | Import-CimXml

 

 

In Hyper-V Core open notepad by typing notepad in the shell. After that copy and paste the following code into the notepad window and safe your file as (example): C:\ip.ps1

To run this powershell script, cd to C:\ and the type in Powershell: C:\> .\ip.ps1

How to manage a Hyper-V core with powershell on the Hyper-V machine

by Ron 24. februari 2011 06:23

Virtual computers have always impressed me. Back in the days I had an Amiga 1200 with a Blizzard 1230VI expansion card. I emulated a Macintosh on this computer. Nowadays I have a Macbook and a copy of Windows Server 2003 Web Edition on it (VMware Fusion 2.0). I also have a bootcamp partition on which Hyper-V Core is installed. On this Hyper-V core a copy of Server 2008 WEB is installed. The only free option to manage the Hyper-V Core is using a MMC plugin in Windows Vista or Server 2008 server edition. I am using Powershell on the Hyper-V server. To use the powershell you must have a RDC with the Hyper-V machine.

Powershell

I experimented a lot with Powershell lately. I read somewhere that notepad can be run from the Hyper-V core. Woow, I thought, that is great, that solves the problem I had to get PS1 (Powershell) files on the Hyper-V core. I used a USB stick in the past, but that was very unhandy. The possibility to run notepad makes it possible to copy scripts from the clipboard of my Macbook, and paste them in a notepad document on the Hyper-V Core. In that way I am able to safe them in the C: drive of the Hyper-V core. And voila, then I will be able to execute these PS1 scripts from the Powershell!

notepad

The first script I run was a script to shutdown and boot the Windows 2008 Web edition from Hyper-V. I used the scripts on this website:

http://community.spiceworks.com/how_to/show/1793

And it worked! :-)

So, that was the first step. To make life easier, I wanted to install on the hyper-V server the PowerShell Management Library for Hyper-V at http://pshyperv.codeplex.com/.

I unzipped the files in a directory on the C drive. To use the library you have to install it. You need to re-install after rebooting the Hyper-V machine.

PS: C:\dir_with_library> .\install.cmd

To get the files on the Hyper-V server, I connect the Hyper-V server to a share on the Windows 2008 server. In this share the files are available that can be downloaded from http://pshyperv.codeplex.com.

To set up a share in the Windows 2008 server, you go to computer management and there is an option for adding shares. After setting up this share, I connect the Hyper-V server to this share with the following command in Powershell:

$net = new-object -ComObject WScript.Network
$net.MapNetworkDrive("u:", "\\server\share", $false, "domain\user", "password")

 

After this, you are able to install the files from this new share U:\.

 

With this library installed, it is possible to do all kind of things. For example find the path of the virtual images, export virtual images, take snapshots, etc.:

Finding a VM
Get-VM, Choose-VM , Get-VMHost

Connecting to a VM
New-VMConnectSession

Discovering and manipulating Machine states
Get-VMState , Set-VMState , Convert-VmState, 
Ping-VM , Test-VMHeartBeat, Shutdown-VM , Start-VM, Stop-VM, Suspend-VM
Get-VMKVP, Add-KVP, Remove-KVP, Get-VMJPEG

Backing up, exporting and snapshotting VMs
Export-VM , Import-VM, Get-VMSnapshot, Choose-VMSnapshot , Apply-VMSnapshot , New-VMSnapshot ,Remove-VMSnapshot, Rename-VMSnapShot, Update-VMSnapshot, Get-VMSnapshotTree, Get-VmBackupScript

Adding and removing VMs, configuring motherboard settings.
New-VM , Remove-VM , Set-VM , Get-VMCPUCount, Set-VMCPUCount, Get-VMMemory, Set-VMMemory, Set-VMSerialPort

Manipulating Disk controllers, drives and disk images
Get-VMDiskController
Add-VMSCSIController , Remove-VMSCSIcontroller
Get-VMDriveByController , Add-VMDRIVE , Remove-VMdrive
Get-VMDiskByDrive, Add-VMDISK , Set-VMDisk, Get-VMDisk
Get-VMFloppyDisk , Add-VMFloppyDisk
Add-VMNewHardDisk

Manipluating Network Interface Cards
Get-VMNic , List-VMNic , Choose-VMNIC, Add-VMNIC, Remove-VMNIC , Set-VMNICAddress , Set-VMNICConnection , Get-VMNicport , 
Get-VMnicSwitch, Choose-VMSwitch, New-VMSwitchPort, Get-VMByMACaddress, Choose-VMExternalEthernet,
New-VMExternalSwitch, New-VMInternalSwitch,New-VmPrivateSwitch

Working with VHD files
Get-VHDDefaultPath, Get-VHDInfo, New-VHD, Compact-VHD, Test-VHD,Convert-VHD,Merge-VHD,Mount-VHD, Unmount-VHD

Exporting a virtual machine VHD file to my Macbook

It would be great to be able to store a backup of a virtual machine running in Hyper-V on my Macbook. Then it will be able to run this VHD in Mac Fusion or I can import it in another Hyper-V core machine.

First I needed to do the export job:

PS C:\> export-vm VM c:\ -CopyState -Force

This created the VHD in the C:\ directory. -CopyState is required to copy the VHD to C:\

To see the progess type (please note that the InstanceID is between '':

PS C:\> Test-wmiJob '\\MS_HYPER-V\root\virtualization:Msvm_ConcreteJob.InstanceID="91321CDB-9AF7-49AF-BB08-E08EAB03BC11"'

When ready, it is time to get the file on the Macbook. To do this I shared a drive in MacosX with SMB and added the user that has access to the Hyper-V core. Done!

Happy computing!

Productphotography

by Ron 19. januari 2010 18:20

Bam Bam Rolling Duck productfotografie Bam Bam laarsjes productfotografie

Webshop Development

by Ron 18. januari 2010 12:51

Bam Bam Lief! Boys Essentials