Archive for the ‘Orchestrator’ Category

So, it has been a while.

SO, the requirement for this project was as follow.

1. Use Service Manager

2. Provide a portal for logging a VM Creation request.

3. Build the computername based on a predetermined pattern.

4. Determine first available name

5. Perform a capacity check.

6. Deploy the set number of VMs.

I am going to skip over the first 2 Points, there are numerous topics covering this. So, onto point 3, I created a Service Request Extension, if anyone would like some info on this, also plenty of articles, please let me know and I can do a blog post on the Extension, or I can make the extension available for you to seal yourselves. Anyways, I mapped all the prompts required within the Request Offering and published it to SharePoint Service Manager Portal.

So, now it is onto the Computername Pattern, for the sake of my customer’s privacy, I will not use there exact naming pattern, but rather use XX-YY-Z type of naming, to give you the idea. Of course, Loving PowerShell the way I do, I turned to old faithful.

I will provide the basic PowerShell code in snippets and allow you to expand onto it as you see fit, I built in a fair amount of specific error checking for my customer which will NOT be included in this post.

The Quest Commandlets will be needed for these scripts. The code is being re-formatted due to the blog hoster. Please change the required values.

#================================================================================
#build computer name

$businessApplication = <"value"> #now from ORC as part of SR
$function = <"value">  #now from ORC as part of SR
$location = <"value"> #now from ORC as part of SR
$affinity = <"value">  #now from ORC as part of SR
$role = <"value">  #now from ORC as part of SR
$businessUnit = <"value">  #now from ORC as part of SR

#naming convention
#1 letter - BusinessUnit
$businessUnit = $businessUnit.Substring(0,1)
$businessApplication
#3 letters - location
$location = $location.Substring(0,3)
$location

#placecholder (-)

#1 letter - role
$role = $role.Substring(0,1)
$role

#1 letter - Function
$function = $function.Substring(0,1)
$function

#tiebreaker (XXX)

#3 Letters - Business Application
$businessApplication = $businessApplication.Substring(0,3)
$businessApplication

#1 letter - Affinity
$affinity = $affinity.Substring(0,1)
$affinity

$computernamepattern = $businessUnit+$location+"-"+$role+$function+"XXX"+$businessApplication+$affinity
$computernamepattern

$computernametocheck = $computernamepattern.Replace("XXX&","001")
$computernametocheck

$part1 = $computernamepattern.Substring(0,7)
$part3 = $computernamepattern.Substring(10,4)
$part2 = $computernamepattern.Substring(7,3)

#==============================================================
#Check if computer name exists

Add-PSSnapin quest.ActiveRoles.ADManagement
$i = 1
do
{
  $computername = $part1 + "{0:D3}" -f $i + $part3
  "testing $computername"
  $test = get-qadcomputer $computername
  if ($test)
  {"Computer Exists"}
  Else
  {$computerstartname = $computername}
  $i++
}
until ($computerstartname -ne $null)

#==========================================================
#create computers

$part1 = $computerstartname.Substring(0,7)
$part3 = $computerstartname.Substring(10,4)
$part2 = $computerstartname.Substring(7,3)
[int]$partnumber = $part2.Substring(2,1)
$computerstobeCreated = ''
$computersRequested = "<Value_from_Orc>";

$computersCreated = 0
$filepath = 'C:\Tools\testing.txt'
New-Item -Path $filepath -ItemType file

do
{
  $newcomputer = $part1 + "{0:D3}" -f $partnumber + $part3
  #New-QADComputer -Name $newcomputer -ParentContainer "OU=Test Computer Accounts,OU=System Accounts,DC=bui,DC=co,DC=za"
  write-host $newcomputer
  write-host $computersCreated
  Add-Content -Path $filepath -Value $newcomputer
  $computersCreated++
  $partnumber++
  $computerstobeCreated = $computerstobeCreated + "" + $newcomputer
}
while ($computersCreated -le ($computersRequested-1))

$computerstobeCreated = $computerstobeCreated.Substring(1)

#======================================================================================= 

I  check the nodes within the Cluster and then find the node with the least amount of Virtual Machines on it. Then use this node information for the creation of the VM. Now time for the free space, since this was a Cluster, I simply used the free space attribute within PowerShell and Virtual Machine Commandlets. I get all the CSV information and then sort by the free space and select the first object as this one would have the most amount of free space.

This is a basic capacity check as per the customer’s requirement, as part of this a field within Service Manager is updated to allow some more information to be shared within the members of the team working on this request.

#==========================================================
#Check for placement issues

$VMCluster = <"value">

$VMMServer = <"value">

$numberOfVMS = <"value">

$hostmachinedomain = (gwmi WIN32_ComputerSystem -ComputerName $VMMServer).Domain

$ClusterFQDN = $VMCluster +"."+$hostmachinedomain

$nodes = (get-scvmhostcluster -Name $VMCluster).nodes 

$colPlacementInfo = @()

#$placementInfo = New-Object system.object

foreach ($node in $nodes)
{
  $placementInfo = New-Object system.object

  $placement = (Get-SCVMHost $node).AvailableForPlacement

  switch($placement)
  {
    "True"
    {
      $placementInfo | Add-Member NoteProperty -name Placement -value "True";
    }
    "False"
    {
      $placementInfo | Add-Member NoteProperty -name Placement -value "False"
    }
  }
  $colPlacementInfo += $placementInfo
} 

If ($colPlacementInfo.placement -ccontains "False")
{$Proceed="No"}
else
{$Proceed="Yes"}

#=========================================================================

#capacity check

$VMCluster = "<value_from_orc>"

$VMMServer = "<value_from_orc>"

$numberOfVMS = "<value_from_orc>"

$hostmachinedomain = (gwmi WIN32_ComputerSystem -ComputerName $VMMServer).Domain

$ClusterFQDN = $VMCluster +"."+$hostmachinedomain

$nodes = (get-scvmhostcluster -Name $VMCluster).nodes 

foreach ($node in $nodes)
  {
    #get Memory Information
    $memoryAvailable = (Get-SCVMHost $node.name).AvailableMemory # MB
    $memoryAvailableCluster = $memoryAvailableCluster + $memoryAvailable

    [int]$memoryTotal = ((Get-SCVMHost $node.name).TotalMemory) /1mb #bytes "{0:D3}" -f
    $memoryTotalCluster = $memoryTotalCluster + $memoryTotal

    #get CPU Information
    $CpuCoreCount = (Get-SCVMHost $node.name).CoresPerCpu
    $CpuCoreTotalCluster = $CpuCoreTotalCluster + $CPUCoreCount
    $CpuCoreTotalCluster

    $CpuCount = (Get-SCVMHost -ComputerName $node.name).PhysicalCPUCount
    $CpuTotalClusterCount = $CpuTotalClusterCount + $CpuCount
    $CpuTotalClusterCount

}
#$memoryAvailableCluster = ($memoryAvailableCluster *1024*1024) /1GB
#$memoryTotalCluster = ($memoryTotalCluster *1024*1024) /1GB
$memoryAvailableClusterdisplay = $memoryAvailableCluster *1024 *1024 /1GB
#$memoryAvailableCluster = ($memoryAvailableCluster) /1GB
$memoryTotalClusterdisplay = $memoryTotalCluster *1024 *1024 /1GB
#$memoryTotalCluster = ($memoryTotalCluster) /1GB

  $VMTemplate = Get-SCVMTemplate -Name '<Name>'

  $TemplateMemory =  $vmtemplate.Memory * $numberOfVMS

  $TemplateCPU =  $vmtemplate.CPUCount * $numberOfVMS

  #Memory Calculation

  $memoryAvailbleAfterVm = $memoryAvailableCluster - $TemplateMemory
  $memoryAvailbleAfterVmdisplay = $memoryAvailbleAfterVm *1024 *1024 /1GB
  #$memoryAvailbleAfterVm = $memoryAvailbleAfterVm /1GB
  $memoryAvailbleAfterVm
  $memoryAvailbleAfterVmdisplay
  #$memoryAvailbleAfterVm = $memoryAvailbleAfterVm.tostring() + "GB" 

$Storage = (get-scvmhostcluster $VMCluster).SharedVolumes
$StorageCapacity = ($Storage | Measure-Object -Property Capacity -Sum).sum
$StorageFreeSpace = ($Storage | Measure-Object -Property FreeSpace -Sum).sum
$StorageUsed = $StorageCapacity - $StorageFreeSpace

$VMVHDUsedSpace = $VMTemplate.TotalVHDCapacity *$numberOfVMS
$freeSpaceAfterVMS = $StorageFreeSpace - $VMVHDUsedSpace

#=============================================

So, I have been using bits and pieces of Orchestrator to string these activities together. However the real power comes in now after using all the pieces from other steps to now, the ACTUAL Deployment. For the sake of simplicity, I am attaching a screenshot of the runbook. Please feel free to contact me (details below) should you want any additional information.

Most of the PowerShell within the Runbook is as a result of unique constraints within this environment, and most cannot be shared. However, like I said, should you want specifics, feel free to contact me and will provide what I can.

The runbook is attached as well, please use at your own discretion, PROVIDED AS IS. DeployVMRunbook

 

2014-07-31_14-11-46

(E-Mail me)

BlogEmailIcon

Follow me,

Twitter (Personal & System Centre)

 Twitter (System Centre Focused)

Advertisements

Hi All,

It has been a little while, i have been quite involved with an Integration Project. With this project there was a requirement to add comments to a Work Item. The information is passed on from “System A” to “System B” via XML. Using PowerShell, extracting the XML contents is not too difficult, if anyone would like to dive into that a little bit, please let me know with Comments.

I decided not to re-invent the wheel, so some searching was in order, and I found the following post, this post gave the basics. However every time I tried to add additional comments, the comments were over-written and NOT replaced. Not quite the desired effect. So after some more checking and research and tinkering within the Service Manager, I discovered the following about comments.

When adding a Comment, there is adding of a relationship class, already mentioned in this post, however it also uses a GUID.

2014-04-03_07-51-37

There is also another trick to adding comments within Orchestrator, this is discovered by trying to add a comment and then pulling all the available fields and looking at them. It is a small component which can be easily missed. The “Display Name” must also be the same GUID. So you might be asking how do we get the GUID?

Well, PowerShell can easily handle this for you.

$guid = [System.Guid]::NewGuid().ToString()

You simply use this a pre-cursor step and publish this data from “Run .Net Script”, so a sample would look like this.

2014-04-03_07-58-27

Get-Object Properties

I pass on the ID Value I want to modify from another Runbook

2014-04-03_07-58-58

Create Related Object Properties

I use an “Extended” class of comments needed for this project, principal remains the same.

2014-04-03_08-01-08

I hope this saves  you some time and add some value.

 

(E-Mail me)

 

Follow me,

 

Twitter (Personal & System Centre)

 Twitter (System Centre Focused)

So, let’s ay you have invested the time and gotten System Centre Orchestrator up and running in your environment and you have the product performing some day to day tasks and it is working well. However, now you want start using SCO (System Centre Orchestrator) to start performing end user focused tasks like Password Reset, add users to groups or even disabling of users or server testing as part of first line support.

All of these tasks can be completed within orchestrator, however exposing them to the end user can be a little tricky. It can be done, the “native way” of performing this within the System Centre Suite is to use System Centre Service Manager with the Service Manager Orchestrator Connector and then prompt the user for information and kick off runbooks. This particular scenario works well if you have System Centre Service Manager in place, and a future blog post will cover the idea of “adding a user to an Active Directory group” as part of a Service Request. There are a few challenges around this. Firstly, you need SCSM (System Centre Service Manager) and some time and patience to test the connectors and runbooks and to create the correct templates and ensure that Workflows with SCSM are configured correctly within SCSM. Like I have said previously, this solution works and it works well!!!

In reality though, not everyone has SCSM in place, many of my companies customers are in the progress of migrating to SCSM and these systems are still in testing or QA or UAT, whatever the case may be, they are NOT in production YET! However, these companies still want this the functionality listed above. Yes, there is a way!!!

Enter EUPSCO, the full name is End User Portal System Centre Orchestrator, and as the name suggests it creates an End User Portal for System Centre Orchestrator. This allows the IT Department to create the required runbooks, to for example, ping a server or reset a password or disable an account. This creates the “Menu”, called “Services” within the End User portal. Once this is completed, the end user can then order from this menu and get the required results without the need of having to contact the IT Department. This particular tool is very easy to install and the guide is easy to follow. The End User portal requires NO Silverlight and as such, it is compatible with most browsers. I have personally tested with the IE, Chrome, Safari and Firefox, all working without issue.

The application also reads from Active Directory, this helps with your reporting line allowing a Manager of staff members (Determined by “Manager” in Active Directory) to log requests on the behalf of his/her staff members, so now +a manager can log a request to reset the password of his/her staff member. The application also allows for approvals. So each service can have an approver, the service allows for a runbook to be triggered if an Approver’s input is needed, with mine, I simply kick off a runbook, which sends an email to the approver with a link to the End User Portal and his/her requests allowing him/her to approve or deny the request.

There are a few key variables which are passed onto the runbook to allow the automation to be easier. The How To’s on the EUPSCO page cover these nicely. This Forum Post also covers these options. Just to make it a little easier, the primary ones are as follow. (please note that these are case sensitive)

1. TargetUserId

2. ApproverUserId

3. ServiceName

This should help your organization adopt System Centre Orchestrator more easily.

A BIG thank you goes out to the People at ITQ for the System Centre Orchestrator End User Portal

(E-Mail me)

Follow me.

Facebook (Personal)

Twitter (Personal & System Centre)

Twitter (System Centre Focused)

Just recently in a test environment, a script or some such other gremlin caused some absolute havoc on my system. Before you ask, I had NO Backup in place of this system. This system was System Center Orchestrator. However, once a week, I do a “sort-of” backup. By this, I mean I export all my Runbooks and place a copy on my local machine and a file server and the SCORCH (System Center ORCHestrator) server.

I was planning to perform an upgrade to System Center 2012 Service Pack 1, and as it happens according to the Upgrade Sequencing for System Center 2012 SP1, SCORCH was the first Product that needed to be updated.

So, at this moment in time, I had a non-functioning SCORCH server and a backup of the Runbooks from the server WITHOUT a proper backup. Luckily the use of SCORCH at this moment in time was mainly for timed tasks and Runbooks triggered by folder changes.

So, I had to rebuild the server. These are the steps I followed and it worked out for me.

NB!!!! Please note that is NOT a replacement for a backup, having a proper backup plan is crucial to any environment. Once my SCORCH server was back up and running, I immediately implemented a proper backup procedure using Microsoft System Center Data Protection Manager in addition to the backup of Runbooks. I am currently working on a Runbook to backup my Runbooks, more to follow on that soon. To achieve this goal, I will be using an Orchestrator Codeplex runbook.

Anyways, back on topic. Lets “recover” System Center Orchestrator 2012.

1. Reset the computer account in Active Directory.

2. Re-join machine to domain using the same name.

3. Install SQL Server, I used a local instance for this.

4. Install System Center Orchestrator 2012 Service Pack 1. I decided to upgrade as well as part of the rebuild, previous version of Integration Packs are backwards compatible.

5. When installing, make sure to use the same port numbers and user accounts as previously used when installing (this should be documented as part of the original install)

6. Import Runbooks.

SNAGHTML377cebf

7. Once the Runbooks are imported. You will then need to check the Runbooks. You will need to re-register and re-deploy the integration packs.

8. Once all the Runbooks are registered and deployed, your environment will be backup and running.

9. If you have a Connector within System Center Service Manager, you will need to check and ensure that the Run As account is working as expected.

(E-Mail me)

image_thumb_thumb_thumb_thumb

Follow me.

facebook-small322252222 Facebook (Personal)

twitter-small322252222Twitter (Personal & System Center)

scsmlogo2523 Twitter (System Center Focused)

MCC11_Logo_Horizontal_2-color_thumb_

So what started this is actually quite simple. We have limited space on our virtual machines and the log files for IIS keeping filling up the drive on our Hub Transport Server (Exchange Server 2010). It is a little know fact, that a certain amount of free space on C: is needed on an Exchange Hub Transport Server, the magic number happens to be 15%. There are a few ways to solve the log file issue. I found this solution. This deletes all files older than 7 days. This can, of course, be modified to suit your needs, I personally have chosen 14 days. Some people choose more, it is basically a case of whatever works best for.

I could simple set this a scheduled task and allow this to run every few days and keep the log files to a reasonable size. However, I have orchestrator and was thinking that this would be a great chance to get my hands dirty and start to show the benefit of Orchestrator to some of the staff in our IT department. I know those that know Orchestrator, are saying “you have to convince them how good Orchestrator is?” and the answer is a resounding “YES”. Anyways, back onto topic here. Below is a diagram of the orchestration. I will go into more detail around my thinking for each step. Hopefully someone can learn from this and help drive the value of System Centre Orchestrator Smile

image

So, the first bit is simply a monitor allowing you specify how often you would like the Runbook to Run.

image

image

Next up, is a simple “Disk Space” monitor found under “Monitoring”

image

I have configured the parameters as needed.

image

I also tweaked the security parameters as needed to an account that has the required rights for checking Drive Space on the required server.

image

For the next step, I modified the “Link Properties” to match my needs of checking of the Disk Space to return a value that will allow the rest of the Runbook to run. It is simply a case of Clicking “Add” and then selecting the required values to check for. I chose “Percentage of Space Available” from Component Before “is less than” Desired percentage.

image

This is why I chose to create a runbook, my staff and Company like to be informed of any changes made on servers. So now I send an e-mail stating that the free space is low to the necessary recipients.

image

Now, I create a folder to allow for creation of text files for the logging of which files will be deleted. (more on this later)

image

I also use published data from earlier in the Databus to create unique folders based on date and time.

image

Now, I create a list of all the files to be deleted and read them into a “log file” and place them in the folder created above for “Auditing” purposes. I had to run this through a PowerShell script and there are some limitations with Orchestrator and Impersonating another account within PowerShell. I will continue to work on this to clean it up.

Please note that *subscribeddata* means data from earlier up the Databus, namely folder locations.

image

I run the below PowerShell script.

This reads the files to be deleted, older than 14 days, creates a log file, and reads the log file into the body of the e-mail.

net use H: *subsribeddata* /user:europcar\administrator &lt;password&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $files=get-childitem -Path \\ms-ec-exc01\C$\inetpub\logs\LogFiles -recurse | where-object {$_.lastwritetime -lt (get-date).addDays(-14)}| out-file -filepath "H:\logs.txt" -append<br>$body = (get-content *subscribeddata&gt;*logs.txt -encoding ASCII | out-string)<br>send-mailmessage -attachments &lt;subscribed data&gt;\logs.txt -body $body -to "fletcher.kelly@europcar.co.za" -from "orchestrator@europcar.co.za" -subject "Files to be deleted" -smtpserver 172.21.195.69<br>net use h: /delete

Now it is time to delete the actual files

image

net use H: *subsribeddata* /user:europcar\administrator *password*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $files=get-childitem -Path \\ms-ec-exc01\C$\inetpub\logs\LogFiles -recurse | where-object {$_.lastwritetime -lt (get-date).addDays(-14)}| remove-item –recurse<br>net use h: /delete

Now it is time to check the Disk Space is at an adequate level.

image

Modify the link Properties again to meet new requirements. So, I have tweaked the script to ensure that the free space is now above my threshold ( I have set mine to 15%)

image

image

And then finally send an e-mail stating that the free space is now adequate. Tweaked to meet my needs with Subscribed data in the body and subject.

image

Please note that this information is provided as is. I can assist as much as possible. Please TEST, TEST and TEST again.

Hope this helps,

Follow me.

facebook-small322252222twitter-small322252222

MCC11_Logo_Horizontal_2-color_thumb_