List all Snapshots of a certain age in SCVMM 2012

I recently wanted to list all snapshots that were older than 30 days. To do this, I created the following powershell script:

The Script

import-module virtualmachinemanager
$Now = get-date
$Days = ”30”
$snapshotage = $Now.AddDays(-$Days)
Get-scvmcheckpoint | where-object {$_.AddedTime –le “$snapshotage”} | ft

How it works
The above snippet basically get the current date and works out the date 30 days ago:

import-module virtualmachinemanager
$Now = get-date
$Days = ”30”
$snapshotage = $Now.AddDays(-$Days)

Once this is calculated, we use where-object to filter the results to show all snapshots older than the 30 days specified in $days:

Get-scvmcheckpoint | where-object {$_.AddedTime –le “$snapshotage”}
=========================================================================
[Disclaimer]
This post is my own work and does not have any connection with my employer.
Following any of the information in these posts are at your own risk. TameYourCloud do not accept any responsibility for any issues that may arise.

[Copyright Notice]
This content is owned by Paul Sanders from TameYourCloud.com. This cannot be copied or distributed without his express permission. A simple quotation for up to 2 sentances maybe used, but a link to the original post must be provided.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

SCSM Fundamentals Part 2 – Query Results for Runbook Automation

In SCSM Fundamentals Part 1 – Query Results for Runbook Automation, we created a runbook to search the SCSM database for related items and add a user to a group. In Part 2, we look at creating the templates in Service Manager and automating the process.

Step 2 – Create the Service Templates

As we now have the runbook created, it should have synchronised with SCSM and appear under Runbooks within the library interface.

1) Simply choose your runbook and click on ‘New Automation Runbook Activity’ from the action pain:

2) On the next pop-up choose a Management Pack to store the template in:

3) After pressing ok, you will be greeted with a template to modify. First step is to stick ‘Ready for Automation’. This ensures the step will run automatically when it should:

4) You will need to configure a mapping between the Runbook ID and the Runbook Variable ‘Runbook ID’. This is done by clicking on the Runbook tab within the template and clicking on ‘Mapping’ next to the Runbook ID variable. Chose Work Item/ID as the map:

Now click on OK to close and save your Runbook Automation Activity (RAA) Template.

Read the rest of this entry »=========================================================================
[Disclaimer]
This post is my own work and does not have any connection with my employer.
Following any of the information in these posts are at your own risk. TameYourCloud do not accept any responsibility for any issues that may arise.

[Copyright Notice]
This content is owned by Paul Sanders from TameYourCloud.com. This cannot be copied or distributed without his express permission. A simple quotation for up to 2 sentances maybe used, but a link to the original post must be provided.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

SCSM Fundamentals Part 1 – Query Results for Runbook Automation

- This is a two part blog about the fundamentals for for SCSM & Query Results. For part 2, please click here.

I remember when I was first getting into Service Manager and Orchestrator. I loved the fact you could query objects within the service manager and utilise them within your runbooks. It seemed to take me forever to work out how to utilise the ‘Query Results’ feature within my ‘Request Offering’.

To run through the process, we will create a Request Offering to add an Active Directory user to a group.

Pre-Reqs

Before we can start this runbook, you need to have completed a few configuration steps. You will need to have the following configured:

- Service Manager Installed and healthy.
- Active Directory Connector configured and populating the database with Users, Computers and Groups.
- You have imported both the Active Directory and Service Manager Integration packs into Orchestrator.

I am going to include two types of input to show how SCSM can pass different types of information into Orchestrator. One being a user String Input the other a ‘Query Results’.

Step 1 – Create the Runbook

First we will create the runbook. The basic process will need to search SCSM for the user inputs (Group Name, Username etc). So log yourself into the Runbook Designer and create a new runbook. Lay it out as follows:

It looks a little complicated doesn’t it? No need to worry though, things makes perfect sense when you start going through the motions:

1) As with all runbooks we need to set our variables with an Initialize Data. For this runbook we will need two variables, one for our RunbookID, the other our users. Configure these both as a string:

2) We then need to add a ‘Get Object’ activity from our Service Manager Integration pack. This will query the service manager for the Runbook Activity ID (the unique ID for this call to orchestrator).

Read the rest of this entry »=========================================================================
[Disclaimer]
This post is my own work and does not have any connection with my employer.
Following any of the information in these posts are at your own risk. TameYourCloud do not accept any responsibility for any issues that may arise.

[Copyright Notice]
This content is owned by Paul Sanders from TameYourCloud.com. This cannot be copied or distributed without his express permission. A simple quotation for up to 2 sentances maybe used, but a link to the original post must be provided.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

HowTo – Install Server 2012 on Cisco UCS B200 M2 Blade

As Server 2012 RTM was made available to download on Tuesday 4th September, I was pretty keen to get it installed into the Cisco UCS environment. Although Server 2012 isn’t fully supported yet, they will soon be offering the official drivers. (See more information here: )

You are able to get the system working with the Server 2008 R2 drivers. So here are the steps I followed:

1) Create a new service profile and the relevant vNics. In my setup I have two for Servers, two for CIFS and two for Management. Make a note of the MAC addresses as you will need them later.

2) Apply the Service Profile to your blade and boot it up from the Server 2012 ISO.

3) Run through the usual windows (accept license agreement, choose mode and choose ‘New Installation.’) As we will be booting from SAN, we will need to install the Storage Controllers. To do this, mount the Cisco UCS driver CD to your session and choose ‘Load Driver’:

4) You will need to find the correct driver by mapping down to d:\Drivers\Storage\M81KR\W2K8R2\x64:

5) You will now be shown the digitally signed version. Simply select it and choose ‘Next’:

6) You will now need to mount the Server 2012 ISO and create a partition on your newly added drive. Bear in mind, MPIO is not configured at this stage, so the device will show as twice:

7) You will now run through the installer and reboot to the login screen.

8) Once logged in, check the Device Manager and you will notice your NIC drivers are not installed. Simply remount the ISO and choose ‘Update Driver’. Point it to the Drivers/Network folder:

There you have it, Server 2012 RTM running on a UCS blade. My next article will go through setting up your network teams and configuring MPIO in preparation for SCVMM.
=========================================================================
[Disclaimer]
This post is my own work and does not have any connection with my employer.
Following any of the information in these posts are at your own risk. TameYourCloud do not accept any responsibility for any issues that may arise.

[Copyright Notice]
This content is owned by Paul Sanders from TameYourCloud.com. This cannot be copied or distributed without his express permission. A simple quotation for up to 2 sentances maybe used, but a link to the original post must be provided.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Howto Install the NetApp SMI-S agent in Windows Server 2012 & SCVMM

Since the release of System Centre Virtual Machine Manager 2012, administrators are now able to configure their storage devices as part of their cloud fabric. To control this process, Microsoft use an open standard called SMI-S. With NetApp being leaders in the storage market, they offer a decent SMI-S solution:

The NetApp Data ONTAP SMI-S Agent, which supports the entire line of NetApp FAS systems and NetApp V-Series Virtualized storage systems, has been certified by SNIA’s Conformance Testing Program (CTP) suite for compliance with SNIA’s SMI-S v1.2 specification.

The functionality supported by the NetApps’ Data ONTAP SMI-S Agent includes features supported via standard profiles as well as NetApp-specific extensions.

Standard profiles support:

•Fibre Channel SAN functionality, including LUN creation, mapping and masking, and reporting
•NAS functionality, including resource discovery (aggregates, volumes, RAID groups, etc.) and system health monitoring
•iSCSI SAN functionality, including LUN creation and export, and session and connection creation
•NetApp-specific extensions support
•Capacity utilization (in the context of multi-protocol storage systems)

The Configuration

To configure SMI-S, you will need to configure a broker that controls all communication between SCVMM and the storage device. To set this up in my lab, I have the following systems in place:
- ms-vmm01 – My SCVMM server.
- ms-smis – This is my SMI-S broker Server
- ms-filer01 – This is my NetApp Filer.

To ensure your SMI-S solution is scalable and remains in a supported state, it must not be installed on the SCVMM server.

Now time to get some configuration done. I assume that you already have the NetApp filer (or vSim) and SCVMM server up and running and is a member of your domain. You can then follow these steps:

1) Download the NetApp SMI-S provider from the NetApp Now Site (you will need a login).

http://www.netapp.com/us/company/leadership/industry-standards/smi-s-agent.html

2) Log into your SMI-S broker server (in my case ms-smis) as an administrator and run through the wizard:
– Run the MSI as an administrator and click Next/Install:

– The wizard will then run through the progress. Once complete, click finish:

3) Once installed, you need to add your storage device by running the following command:

SMIS ServiceAccount ServicePassword add ms-filer01.ms.local filerrootAccount FilerPassword
(Where ServiceAccount is an AD account, and fileroot is a local filer account).

- If this is successful, you will see the following output:

Returned Path ONTAP_FilerData.hostName="ms-filer01.ms.local",port=80

5) Now that you have the SMI-S broker configured, you will need to add it into your Fabric with SCVMM:

You will need to load up your SCVMM console and make your way into the Fabric screen. From here, right click on ‘Providers’ under the Storage drop down and choose add device:

You will need to point this to your SMIS-Provider server (in this example ms-smis.ms.local:5988) and choose a relevant RunAs account.

You will then be asked which aggregates you wish to add and what classification they will be given. I will cover designing your SMI-S setup in a later blog post.

=========================================================================
[Disclaimer]
This post is my own work and does not have any connection with my employer.
Following any of the information in these posts are at your own risk. TameYourCloud do not accept any responsibility for any issues that may arise.

[Copyright Notice]
This content is owned by Paul Sanders from TameYourCloud.com. This cannot be copied or distributed without his express permission. A simple quotation for up to 2 sentances maybe used, but a link to the original post must be provided.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

PowerShell Password Management within Orchestrator

If you end up managing a large number of machines with your Orchestrator setup, you will find you need to keep re-adding your credentials for the various systems.

There are a couple of ways you can do this:

1) Store your password in your source code:
This is the unsecure version, but can be quite useful when you are just testing your code. You simply enter the following code into your scripts:

$securePassword = ConvertTo-SecureString "Password" -AsPlainText -force
$credential = New-Object System.Management.Automation.PsCredential ("Administrator",$securePassword)

You can then use these credentials with the ‘-Credential’ flag:

Connect-Nacontroller filer01.domain.local -Credential $credential

2) Store your password in an encrypted file:
The second method is much more secure, but can be a bit of a nightmare to keep up to date. First things first, you need to store your credentials into a binary file on your local harddrive:

$credential = get-credential
$credential.Password | ConvertFrom-SecureString | out-file c:\work\password.txt

This will prompt you to enter your credentials and will output it to c:\work\password.txt. If you were to open this file, you wouldn’t have the faintest idea as to what the credentials were. To use these in your script, you would call the following:

$securepassword = type C:\Users\srv-scorchservice\Documents\democreds.txt | ConvertTo-SecureString
$credential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist "Username", $securepassword

3) Use Encrypted Orchestrator Variables
In my opinion, created an encrypted password within orchestrator is the easiest password management solution within Orchestrator. Simply create yourself a global variable with your password as the value. Make sure you tick ‘Encrypted’:

You can then use your this password within your runbook by subscribing to the variable:

This also makes changing your password much easier. Instead of having to go back to every activity and update your password, you can simply modify the variable.

Enjoy

=========================================================================
[Disclaimer]
This post is my own work and does not have any connection with my employer.
Following any of the information in these posts are at your own risk. TameYourCloud do not accept any responsibility for any issues that may arise.

[Copyright Notice]
This content is owned by Paul Sanders from TameYourCloud.com. This cannot be copied or distributed without his express permission. A simple quotation for up to 2 sentances maybe used, but a link to the original post must be provided.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

HowTo : Import SCVMM (VirtualMachineManager) Module into Server 2008 R2

During a runbook creation this morning, I needed to utilise the VirtualMachineManager PowerShell module. When trying to import the module I receive the following error:

Import-Module : Could not load file or assembly ‘file:///C:\Program Files\Microsoft System Center 2012\Virtual Machine Manager\bin\Microsoft.SystemCenter.VirtualMachineManager.dll’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

After some investigation, I found it was down to a PowerShell configuration setting that needed to allow the use of DotNet 4 assemblies. To get this working, I needed to create a new configuration file into my PowerShell root directory called Powershell.exe.config:

< ?xml version="1.0"? >
< configuration >
< startup useLegacyV2RuntimeActivationPolicy="true" >
< supportedRuntime version="v4.0.30319"/ >
< supportedRuntime version="v2.0.50727"/ >
< /startup >
< /configuration >

**The above script is basically in XML, make sure you remove the spaces after the < and before the >.**

Once added, I was able to import the module within my own session. However, whenever my Runbook was called, it failed with the same error message. It turns out you need to add a couple of registry keys to change the global behaviour for your DotNet Configuration:

reg add hklm\software\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1
reg add hklm\software\wow6432node\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1

As soon as I added the keys, I was able to call the VirtualMachineManager module and access the cmdlets.
=========================================================================
[Disclaimer]
This post is my own work and does not have any connection with my employer.
Following any of the information in these posts are at your own risk. TameYourCloud do not accept any responsibility for any issues that may arise.

[Copyright Notice]
This content is owned by Paul Sanders from TameYourCloud.com. This cannot be copied or distributed without his express permission. A simple quotation for up to 2 sentances maybe used, but a link to the original post must be provided.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Query SCVMM for an allocated IP Address

As part of my tenant provisioning runbook, I need to connect up to a recently provisioned virtual machine to run a number of PowerShell scripts.

On first impressions this should have been an easy task, but for some reason SCVMM doesn’t present a VMs IP address through the integration tools. To get the information I needed to query what IPs have been assigned from my Logical Network IP Pools. For this to work, you need to modify your VM template to allocate static IP addresses from your Logical Network IP Pools.

In my orchestration runbook I added a ‘Run Dot Net Script’ activity and wrote the following code:

import-module virtualmachinemanager
$VMNetworkConfig = get-scipaddress -VMMServer "< VMM Server>" | where-object {$_.Description -eq "< VM Hostname >"}
$VMIP = $VMNetworkConfig.Name

This code will search any allocated IP addresses and search for the entry with the description ‘VM Hostname’ (which is my recently provisioned VM). This information is then assigned to $VMIP which I add to my databus:

I can now utilise this IP address in my next activity by subscripting the VMIP from my GetVMIP Activity.

And here is how my final runbook looks:

Enjoy :) =========================================================================
[Disclaimer]
This post is my own work and does not have any connection with my employer.
Following any of the information in these posts are at your own risk. TameYourCloud do not accept any responsibility for any issues that may arise.

[Copyright Notice]
This content is owned by Paul Sanders from TameYourCloud.com. This cannot be copied or distributed without his express permission. A simple quotation for up to 2 sentances maybe used, but a link to the original post must be provided.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

SCCM 2012 – Missing Service Broker Route

Hi All,

Over the past couple of days I have been having a database replication issue with SCCM 2012 SP1 CTP2.

** Please note, CTP2 isn’t ready for production, and modifying the database directly is not supported by MS. I have raised this issue with MS as a possible bug. **

I was in the process of building a multiple forest SCCM hierachy that has two primary sites that report into a CAS. The setup wasn’t anything out of the ordinary, so my basic setup was:

Server Configuration:

MS-SCCMCAS01.ms.local – CAS – Central Administration Site in MS.local.
MS-SCCMPOC01.ms.local – POC – Primary Site in MS.local.
MS-SQL01.ms.loca – Multiple Instance SQL Server in MS.local. This hosted both CAS and POC Databases in their relative instances.

MS-SCCMDEV01.ms.local – DEV – Primary Site in AD.local. This also had a dedicated local SQL instance.

As soon as I started to check the replication status within monitoring, I noticed CAS to POC replication was showing
as Failed. After running a Replication Link Analysis, I recieved the following error message:

Detail Name=”result” Value=”Service broker route ConfigMgrBGBRoute_Local is missing or has incorrect address
for service ConfigMgrBGB_SitePOC. Expected address LOCAL.”

After some extensive research, the resolution came down to be Service Broker Routes within SQL. SBRs have taken over
most of the replication traffic in an SCCM hierachy in 2012.

When I logged into the relevant SQL instances, I made my way into the ConfigMgr databases and had a look into the
available routes.

As you can see, the Broker Route ‘ConfigMgrBGBRoute_Local’ is missing. So to create a new one, simply right click
and choose ‘New Route…’. This will give you an SQL query that will need modifying with the correct syntax.

To get my installation working, I had to run the following query on the CM_POC database:

CREATE ROUTE ConfigMgrBGBRoute_Local
AUTHORIZATION dbo
WITH
SERVICE_NAME = 'ConfigMgrBGB_SitePOC',

ADDRESS = 'LOCAL'

ConfigMgrBGB_SiteTEN.

I then had to do the reverse on the CM_DEV database at the opposite end. Once modified, and re-running the Link analyser, everything started replicating again.

=========================================================================
[Disclaimer]
This post is my own work and does not have any connection with my employer.
Following any of the information in these posts are at your own risk. TameYourCloud do not accept any responsibility for any issues that may arise.

[Copyright Notice]
This content is owned by Paul Sanders from TameYourCloud.com. This cannot be copied or distributed without his express permission. A simple quotation for up to 2 sentances maybe used, but a link to the original post must be provided.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Prepare the SCORCH Powershell Environment for Flexpod

When working with the System Centre Orchestrator to run powershell script, I find myself repeating large segments of code to
setup the environment. Take the VMWare PowerCli as an example:

Luckily, we can utilise a feature within powershell that is similar to Profiles.

How to configure a powershell profile:

You will need to create a new Powershell Profile file within the service accounts directory.
To determine this, run cmd as the service account, and run the following command:

$path

In my case, it gave me the following path:

C:\Users\srv-scorchservice\Documents\WindowsPowershell\Microsoft.Powershell_profile.ps1

As this file doesn’t exist yet, I need to create the folder ‘Windows Powershell’ and create a new ps1 document called Microsoft.Powershell_profile.ps1. Once created, I added the following code to configure my environment:


#Profile configuration for SCORCH and Flexpod
#Completed by Paul Sanders

#First, import all the mostly used Modules

import-module DataOntap

Now this profile is created, all I need to do is set the $Profile variable within my ‘Run .Net Script’ activity within Orchestrator:

$path = C:\Users\srv-scorchservice\Documents\WindowsPowershell\Microsoft.Powershell_profile.ps1

Wouldn’t this slow things down?

Bear in mind that adding code to the profile path will slow the execution down, and import a whole raft of un-needed cmdlets for the task in hand. To get around this, I created a number of .ps1 files to configure my environment based on the tasks. For example:

- ImportNetAppConfig.ps1
- ImportVmwareConfig.ps1
- ImportUCSConfig.ps1
- ImportVMWareConfig.ps1

I then add these into Orchestrator as system variables and call them as and I when I need them:

There we go, nice and easy. To add them into my code segment, I simply add them by subscribing to the variable in my activities:

=========================================================================
[Disclaimer]
This post is my own work and does not have any connection with my employer.
Following any of the information in these posts are at your own risk. TameYourCloud do not accept any responsibility for any issues that may arise.

[Copyright Notice]
This content is owned by Paul Sanders from TameYourCloud.com. This cannot be copied or distributed without his express permission. A simple quotation for up to 2 sentances maybe used, but a link to the original post must be provided.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS