2013/10/07

Blogger - Adding PowerShell code in your blog post

From time to time you might be interested to have your code syntax highlighted or presented with a neat format in your blog posts.

Plain text is boring and it can really mess up the layout of your post. Also It can be very hard to understand some code without some sort of syntax highlighting.





Here are a few methods that I found useful for Blogger: (those can probably be applied to Wordpress and other platforms)

  • Method 1: Using Syntax Highlighter from Alex Gorbatchev
  • Method 2: Using an Editor to copy the code as HTML language
  • Method 3: HTML CSS Rectangle (PowerShell console look a like)
  • Method 4: Embedded code using Gist (GitHub)

2013/10/06

PowerShell Studio 2012 - WinForms - Creating a basic GUI (Video)

The following post will demo how to create a basic Graphical User Interface with SAPIEN PowerShell Studio 2012.

Update: See also the second part of this post: PowerShell Studio 2012 - WinForms - GUI ToolMaking

Last year I released a PowerShell script called LazyWinAdmin 0.4 which is a script that generate a Graphical User Interface. I used SAPIEN PowerShell Studio 2012 to create this Interface and write my PowerShell code.

LazyWinAdmin script allows SysAdmins/IT Pros to Query Information on their Workstation / Servers and to Perform some actions like :
  • List Shares (with local path), Processes, Services, ...
  • Test the Connection, Permission, PowerShell Remoting, RDP availability ...
  • Reboot/Shutdown
  • Query and Kill any RDP Session opened
  • Etc...

Since then, I got a lot of emails asking me questions about PowerShell and how to make GUIs using PowerShell Studio 2012. So here is a quick demo..


2013/08/15

WS2012 Storage - Creating a Storage Pool and a Storage Space (aka Virtual Disk) using PowerShell

In my previous posts I talked about how to use NFS and iSCSI technologies hosted on Windows Server 2012 and how to deploy those to my Home Lab ESXi servers.

One point I did not covered was: How to do the Initial setup with the physical disk, Storage pooling and the creating the Virtual Disk(s) ?

The cost to acquire and manage highly available and reliable storage can represent a significant part of the IT budget. Windows Server 2012 addresses this issue by delivering a sophisticated virtualized storage feature called Storage Spaces as part of the WS2012 Storage platform. This provides an alternative option for companies that require advanced storage capabilities at lower price point.

2013/07/18

PowerShell - Free Trainings from Microsoft Virtual Academy

Update: Getting Started with PowerShell 3.0 and Advanced Tools & Scripting with PowerShell 3.0 recorded videos are now available on Microsoft Virtual Academy. Links below.


I get a lot of questions from my friends and coworkers about PowerShell ...
"Hey FX, How can i get all the process that start by... and then kill them all in PowerShell ?
"How can I add a Windows Feature in W2012 in PowerShell ?"
"How can I get the list of programs installed on those 50 computers using PowerShell ?"
 "How can I change the Multipath policy of all my LUNs in VMware vSphere using PowerShell (PowerCli) ?"

Well if you are just like them, you'll be happy to hear that Microsoft Virtual Academy will offer not one, but Two free PowerShell trainings !! Here are the details.

2013/07/16

WS2012 Storage - iSCSI Target Server - Configuring an iSCSI Initiator on VMware vSphere 5.1


I recently switched the backend storage of my VMware vSphere 5.1 Home Lab from FreeNas (OS based on UNIX) to iSCSI (Windows Server 2012 Storage Feature). The reason is that I wanted to play with the PowerShell iSCSI modules and do some tests with SMB v3.0.

In a previous post I showed how to create an iSCSI target using PowerShell on Windows Server 2012. Today I will demonstrate how I set the VMware vSphere 5.1 Software iSCSI Adapter using PowerCli and create the datastore using the LUN created in my previous post. I won't cover how to assign the iSCSI traffic to a dedicated PortGroup and dedicated NICs.


2013/07/11

WS2012 Storage - iSCSI Target Server - Create an iSCSI target using PowerShell

For my Virtual Machines needs, some LUNS are presented to my VMware vSphere 5.1 Servers and until now, my lab storage was handle by FreeNas using iSCSI.
For tests purposes, I replaced this FreeNas by Windows Server 2012 to take care of that part.

Note: Before writing this post, I grouped my physical disks together into a container called storage pools to manage those disks as a single storage space. Afterwards, in these storage pools, I created virtual disks (aka LUN) on which I specify a layout, ... which is simply a raid level.


Overview

In the following post I will talk about the following points:
  • Quick iSCSI Terminology
  • Quick look at iSCSI Target Management (GUI and PowerShell iSCSI Modules)
  • Installing the Windows Feature iSCSI Server Target (PowerShell)
  • Creating a iSCSI Virtual Disk (aka LUN) (PowerShell)
  • Creating a iSCSI Target and assigning it to one or more initiator(s) (PowerShell)
    • Finding the iSCSI Qualified Name (IQN) (vSphere Client and PowerCLI)
  • Assigning a iSCSI Virtual Disk (LUN) to a iSCSI Target (PowerShell) 


Terminology


Note: The iSCSI protocol is fully documented by the RFC 3720 and RFC 3721

iSCSI: iSCSI stands for Internet Small Computer System Interface.
It's an Internet Protocol (IP)-based storage networking standard for linking data storage facilities.
iSCSI is used to facilitate data transfers over a network (LAN, WAN or Internet) and transferring data by carrying SCSI commands over IP networks. iSCSI leverages the Ethernet network and does not require any specialized hardware

source: http://blogs.technet.com/b/filecab/

iSCSI Target Server: is the server that shares the storage, it runs the iSCSI Target. The server (machine) consumes the storage is called iSCSI initiator.

iSCSI Initiator: Typically, it is an application server. For example, iSCSI Target provides storage to a SQL server, the SQL server will be the iSCSI initiator in this deployment.

Target: It is an object which allows the iSCSI initiator to make a connection. The Target keeps track of the initiators which are allowed to be connected to it. The Target also keeps track of the iSCSI virtual disks which are associated with it. Once the initiator establishes the connection to the Target, all the iSCSI virtual disks associated with the Target will be accessible by the initiator.

iSCSI Virtual Disk: It also referred to as iSCSI LUN. It is the object which can be mounted by the iSCSI initiator. On Windows Server 2012, the iSCSI virtual disk is backed by the VHD file.

iSCSI Connection: iSCSI initiator makes a connection to the iSCSI Target Server by logging on to a Target. There could be multiple Targets on the iSCSI Target Server, each Target can be accessed by a defined list of initiators. Multiple initiators can make connections to the same Target. However, this type of configuration is only supported with clustering. Because when multiple initiators connects to the same Target, all the initiators can read/write to the same set of iSCSI virtual disks, if there is no clustering (or equivalent process) to govern the disk access, corruption will occur. With Clustering, only one machine is allowed to access the iSCSI virtual disk at one time.

IQN: iSCSI Qualified Name. It is a unique identifier of the Target or Initiator. The Target IQN is shown when it is created on the Server. The initiator IQN can be found by typing a simple "iscsicli" cmd in the command window or using Get-InitiatorPort in PowerShell

Using iscsicli

Using PowerShell (module iSCSI) with the Cmdlet Get-InitiatorPort

2013/07/02

Enabling Change Block Tracking (CBT) on a vSphere 5.1 VM with PowerShell/PowerCli

In one of my previous post, I created two PowerShell functions to enable Copy/Paste operations on VMware vSphere 5.1 between a Guest OS and the vSphere Client remote console.
Today we'll use a very similar piece of code to Enable Change Block Tracking (CBT) on one or more Virtual Machines.

I already talked about CBT in the past, but I just wanted to create re-usable PowerShell functions that will help me when I need it.

2013/07/01

How to Enable Copy/Paste Operations Between GuestOS and Remote Console on vSphere 5.1 (GUI and PowerCli)

In this blogpost I will explain how to enable Copy/Paste operations between the Guest Operating System and the Remote Console on VMware vSphere 5.1 via the GUI and PowerCli (PowerShell for VMware).

VMware does not recommend this manipulation to avoid and limit Exposure of Sensitive Data Copied to the Clipboard section.

Using the GUI this procedure requires the VM(s) to be powered off. Who wants to do that? Not me...

Check the second part of this procedure using PowerCli, this can be applied without powering off the VM. However you'll need to do a stun/unstun operation (i.e. power on/off, suspend/resume, create/delete snapshot/storage VMotion) to achieve the same thing.


Using the Graphical User Interface (GUI)

Applying advanced settings to a VM can be a daunting task.
Doing this manipulation via the GUI is pretty heavy. When dealing with even a few VMs, this can be a very time consuming task time consuming...

The "Configuration Parameters" button is not available while the VM is Powered On.

1 - Power down your VM(s)

2 - Go into Edit Setting, under the Option tab, and select General under Advanced.
You'll see the Configuration Parameters button...



3 - Click on Add Row and enter the Name and Value for each of the following items:
  • isolation.tool.copy.disable = FALSE
  • isolation.tool.paste.disable = FALSE