<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Phil Gibson's Cloud &amp; Datacenter Solutions Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/phillipgibson/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/phillipgibson/feed.xml</link>
    <description>Discussions on Solutions for Microsoft Azure, AWS, Google, DevOps, Datacenter, and Systems Management - Posts in this blog are provided &amp;quot;AS IS&amp;quot; with no warranties, and confers no rights as specified in the Terms of Use</description>
    <lastBuildDate>Tue, 16 Apr 2019 06:16:20 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Move and Store Operations Management Suite (OMS) Log Analytics Data to Azure SQL Data Warehouse using Azure Data Factory – Part 1</title>
      <link>https://docs.microsoft.com/archive/blogs/phillipgibson/move-and-store-operations-management-suite-oms-log-analytics-data-to-azure-sql-data-warehouse-using-azure-data-factory-part-1</link>
      <pubDate>Wed, 12 Oct 2016 23:16:41 GMT</pubDate>
      <dc:creator><![CDATA[Phil Gibson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/phillipgibson/?p=225</guid>
      <description><![CDATA[From time to time, having conversations with customers about OMS Log Analytics, some questions come...]]></description>
      <content:encoded><![CDATA[From time to time, having conversations with customers about OMS Log Analytics, some questions come up about long term storage of their data. If you’ve been utilizing OMS Log Analytics for a while you may remember the legacy three service tiers (Free, Standard, Premium) in which our Premium tier allowed for 1 year of data retention.

<img width="300" height="154" class="alignnone size-medium wp-image-235" alt="OMSLogsToAzureSQLDW-Part1-01" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part1-01-300x154.png" />

Those legacy tiers have since been replaced by Free, Standalone, and OMS.

<img width="300" height="146" class="alignnone size-medium wp-image-245" alt="OMSLogsToAzureSQLDW-Part1-02" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part1-02-300x146.png" />

In the new pricing tiers, it now lists 30 days of data retention for the Standalone and OMS tier. So the question is what happens on the 31st day of that data point metric? Well most likely it will stop showing up in your log search results and if you are looking to show operational trends that span more than 30 days, then unfortunately you might be out of luck. Now let me be clear before we move on. At the timing of this post I am not aware of any changes to the service tiers that will extend retention longer than the 30 days stated, so we’re going to proceed forward with the understanding that data points older than 30 days will no longer be available to you. I have not had time to speak with the Product Team, so if I get an update I will come back and update this post.

This post will show you how to capture OMS Log Analytics search data and move that data over to an Azure SQL Data Warehouse. With the following steps you will:
<ul>
 	<li>Create and save a OMS Log Analytics search result</li>
 	<li>Create an Azure Storage Blob Container</li>
 	<li>Create an Azure SQL Data Warehouse</li>
 	<li>Utilize Azure Automation to schedule the OMS Log Analytics search and upload data blob to storage container</li>
 	<li>Create and connect resources to Azure Data Factory</li>
 	<li>Create a ADF (Azure Data Factory) pipeline to move the OMS Log Analytics search data from Storage Blob to Azure SQL Data Warehouse</li>
</ul>
I will also mention that beyond using Azure SQL Data Warehouse to solve a data retention issue, you could also possibly utilize this solution as an additional option to filter and capture data to be presented outside of the OMS console. OMS Log Analytics already has native functionality to push data into <a target="_blank" href="https://powerbi.microsoft.com/en-us/">Microsoft PowerBI</a>, so this can be another tool you have in your toolbox to build a solution.
<h1><span style="color: #2e74b5;font-family: Calibri Light;font-size: x-large">Before you begin</span></h1>
<span style="color: #000000;font-family: Calibri">I would highly recommend that you become familiar with some key posts I utilized to formulate the solution in this post as well as some of the technology we will be talking through. I’ll be honest, if you’re new to some of the technologies listed in the previous bullets, I would highly encourage you to take your time and familiarize yourself with the following links:</span>

<a href="https://blogs.technet.microsoft.com/privatecloud/2016/04/05/using-the-oms-search-api-with-native-powershell-cmdlets/"><span style="color: #0563c1;font-family: Calibri">Using the OMS Search API with native PowerShell cmdlets</span></a>

<a href="https://azure.microsoft.com/en-us/documentation/articles/storage-powershell-guide-full/"><span style="color: #0563c1;font-family: Calibri">Using Azure PowerShell with Azure Storage</span></a>

<a href="https://azure.microsoft.com/en-us/documentation/articles/sql-data-warehouse-get-started-provision/"><span style="color: #0563c1;font-family: Calibri">Create an Azure SQL Data Warehouse</span></a>

<a href="https://azure.microsoft.com/en-us/documentation/articles/data-factory-introduction/"><span style="color: #0563c1;font-family: Calibri">Introduction to Azure Data Factory</span></a>

<a href="https://azure.microsoft.com/en-us/documentation/articles/sql-data-warehouse-load-from-azure-blob-storage-with-data-factory/"><span style="color: #0563c1;font-family: Calibri">Load data from Azure blob storage into Azure SQL Data Warehouse via Azure Data Factory</span></a>

<a href="https://azure.microsoft.com/en-us/documentation/articles/automation-intro/"><span style="color: #0563c1;font-family: Calibri">Azure Automation Overview</span></a>

<span style="color: #000000;font-family: Calibri">I’ve tried my best to sequence the activities needed in a logical order. If you find that something is missing or not making sense, please refer to one of the above links concerning the activity and/or technology. Those links are exactly what I used to build this solution.</span>
<h1><span style="color: #2e74b5;font-family: Calibri Light;font-size: x-large">Step 1: Build and save the search results of OMS Log Analytics query with data you want to move into the Azure SQL Data Warehouse</span></h1>
To start simple, the data I’m looking to archive into the Azure SQL Data Warehouse is all the Windows Security Events with ID 4625 for the past 24 hours. Event ID 4625 is an account failed to log on. This could be useful for forensic activities by the security team. My search query is:

<strong>Type=SecurityEvent EventID=4625 TimeGenerated&gt;=NOW-24HOURS</strong>

<img width="300" height="75" class="alignnone size-medium wp-image-255" alt="OMSLogsToAzureSQLDW-Part1-03" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part1-03-300x75.png" />

<span style="color: #000000;font-family: Calibri">Once you run your search query, hit the save button and name the search and put it under a category. I chose the Security and Audit category for this search.</span>

<img width="300" height="294" class="alignnone size-medium wp-image-265" alt="OMSLogsToAzureSQLDW-Part1-04" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part1-04-300x294.png" />

<span style="color: #000000;font-family: Calibri">You should now see your custom saved search query when you go back to Log Search and click on the Favorites star.</span>
<h1><span style="color: #2e74b5;font-family: Calibri Light;font-size: x-large">Step 2: Create an Azure Storage Account and a Blob Storage Container within the Storage Account</span></h1>
<span style="color: #000000;font-family: Calibri">Since we will be creating several Azure services to achieve this solution, it will be best to create an Azure Resource Group to house all of the Azure services. If you’re not familiar with the concept of a resource group, please check out this link </span><a href="https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-deploy-portal/#create-resource-group"><span style="color: #0563c1;font-family: Calibri">Create Resource Group</span></a><span style="color: #000000;font-family: Calibri">. I simply created a Resource Group called OMSLogsToAzureSQLDW to put all my Azure services into. </span>

<img width="300" height="270" class="alignnone size-medium wp-image-275" alt="OMSLogsToAzureSQLDW-Part1-05" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part1-05-300x270.png" />

<span style="color: #000000;font-family: Calibri">Once you have your Resource Group created, create a Storage Account in that resource group. For instruction on creating a Storage Account, please check out this link </span><a href="https://azure.microsoft.com/en-us/documentation/articles/storage-create-storage-account/#create-a-storage-account"><span style="color: #0563c1;font-family: Calibri">Create a Storage Account</span></a><span style="color: #000000;font-family: Calibri">.</span>

<span style="color: #000000;font-family: Calibri">Once your storage account is provisioned, add a Blob container to the Blob service.</span>

<img width="300" height="205" class="alignnone size-medium wp-image-276" alt="OMSLogsToAzureSQLDW-Part1-06" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part1-06-300x205.png" />

<span style="color: #000000;font-family: Calibri">You’ll want to make a note of the URI to your container as you’ll need it later for the automation. </span>

<img width="300" height="111" class="alignnone size-medium wp-image-285" alt="OMSLogsToAzureSQLDW-Part1-07" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part1-07-300x111.png" />

Oh and by the way you can hack it all you want. At the time of this posting I have since removed my Resource Group containing the container :-).
<h1><span style="color: #2e74b5;font-family: Calibri Light;font-size: x-large">Step 3: Create the Azure SQL Data Warehouse</span></h1>
Now we will need to create the Azure SQL Data Warehouse that will be the long term data store of our OMS Log Search Query data. To create the Azure SQL Data Warehouse, please follow the directions in this link <a href="https://microsoft.sharepoint.com/sites/infopedia/pages/my-Learning.aspxhttps:/azure.microsoft.com/en-us/documentation/articles/sql-data-warehouse-get-started-provision/">Create an Azure SQL Data Warehouse</a>. You’ll need to choose a server name and a database name. For the database name I chose “omslogs”. A couple of things to remember to configure with Azure SQL data warehouse server, remember to choose a <strong>Blank database </strong>when creating the database, allow Azure services to access the server, and don’t forget to create the firewall rule to allow your client IP to access the server. The firewall rule is important because if you don’t set your client IP address you will not be able to connect to your server via the SQL Management Studio.
<h1><span style="color: #2e74b5;font-family: Calibri Light;font-size: x-large">Step 4: Choose a Table Name and Populate the Table Schema</span></h1>
This is an extremely important step. The way the pipeline load process works with Azure Data Factory for this specific use is it will take the structure of the upcoming CSV file we’ll be creating and loading into our storage container, and moving that data right into the Azure SQL Data Warehouse. If the schema data structure of the CSV file is not the same as the table in Azure SQL Data Warehouse database, then the Azure Data Factory pipeline load operation will fail. So we have to do a couple of things here first on the data warehouse database before proceeding.

The first thing we need to come up with is the name of the table that will hold the CSV file data. Since the OMS Log Analytics search query is “An account failed to log on past 24 hours”, I figure I would call the database table “<strong>acctfailedlogonpast24hours</strong>”.

<span style="color: #000000;font-family: Calibri">Secondly, we have to understand the column structure of the CSV file. To do that, return to your OMS portal and run the saved search query “An account failed to log on past 24 hours”. When the search results are finished, click the export to Excel option and save the file to your computer.</span>

<img width="300" height="152" class="alignnone size-medium wp-image-295" alt="OMSLogsToAzureSQLDW-Part1-08" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part1-08-300x152.png" />

Now you can either open that saved file and record all the column names, or you can run this PowerShell code against the file to enumerate all the columns. I found this code snippet of code on <a href="https://stackoverflow.com/questions/25764366/how-to-get-the-value-of-header-in-csv">stackoverflow.com</a>.

$inFilePath = "C:\users\philg\downloads\SearchResults.csv"

$csvColumnNames = (Get-Content $inFilePath | Select-Object -First 1).Split(",")

$csvColumnNames

<span style="color: #000000;font-family: Calibri">Next we need to use SQL Management Studio and connect to your Azure SQL Data Warehouse server.</span>

<img width="300" height="228" class="alignnone size-medium wp-image-305" alt="OMSLogsToAzureSQLDW-Part1-09" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part1-09-300x228.png" />

<span style="color: #000000;font-family: Calibri">Once you’re connected, open a new query file, choose the “OMSLOGS” database (or whatever database you created during the data warehouse setup) and run the following T-SQL code. The columns should correspond to the columns in the CSV file.</span>

CREATE TABLE acctfailedlogonpast24hours
(
"TimeGenerated" nvarchar(1024),
"SourceSystem" nvarchar(1024),
"Account" nvarchar(1024),
"AccountType" nvarchar(1024),
"Computer" nvarchar(1024),
"EventSourceName" nvarchar(1024),
"Channel" nvarchar(1024),
"Task" nvarchar(1024),
"Level" nvarchar(1024),
"EventData" nvarchar(1024),
"EventID" nvarchar(1024),
"Activity" nvarchar(1024),
"MG" nvarchar(1024),
"TimeCollected" nvarchar(1024),
"ManagementGroupName" nvarchar(1024),
"AuthenticationPackageName" nvarchar(1024),
"FailureReason" nvarchar(1024),
"IpAddress" nvarchar(1024),
"IpPort" nvarchar(1024),
"KeyLength" nvarchar(1024),
"LmPackageName" nvarchar(1024),
"LogonProcessName" nvarchar(1024),
"LogonType" nvarchar(1024),
"LogonTypeName" nvarchar(1024),
"Process" nvarchar(1024),
"ProcessId" nvarchar(1024),
"ProcessName" nvarchar(1024),
"Status" nvarchar(1024),
"SubjectAccount" nvarchar(1024),
"SubjectDomainName" nvarchar(1024),
"SubjectLogonId" nvarchar(1024),
"SubjectUserName" nvarchar(1024),
"SubjectUserSid" nvarchar(1024),
"SubStatus" nvarchar(1024),
"TargetAccount" nvarchar(1024),
"TargetUserName" nvarchar(1024),
"TargetUserSid" nvarchar(1024),
"TransmittedServices" nvarchar(1024),
"WorkstationName" nvarchar(1024),
"id" nvarchar(1024),
"Type" nvarchar(1024),
"TargetDomainName" nvarchar(1024)
);

&nbsp;

Once that finishes you should have a completed successfully on the output. You can also run the T-SQL command <strong>SELECT * FROM acctfailedlogonpast24hours</strong> and verify the table and columns are listed.

<span style="color: #2e74b5;font-family: Calibri Light;font-size: x-large">Step 5: Use Azure Automation to Invoke OMS Search API to load search results as CVS and copy to Azure Blob Storage </span>

There’s no need for me to recreate the wheel on this one. Tiander Turpijn post <a href="https://blogs.technet.microsoft.com/privatecloud/2016/04/05/using-the-oms-search-api-with-native-powershell-cmdlets/">Using the OMS Search API with native PowerShell cmdlets</a> , that I referenced earlier, completely documents the process of using AzureRM.OperationalInsights PowerShell module to query the OMS Search API. I do make some slight additions to the code because I need to capture the search results as a CSV and then move that file to the Azure storage for the Azure Data Factory pipeline process to move into the Azure SQL Data Warehouse. My biggest addition is authenticating to the Azure storage to post the CSV file blob to the storage container.

If you are new to Azure Automation, please ensure you have updated your Azure Automation modules to the latest. This is called out in Tiander’s post, but it is buried in a couple of links. Go directly to Jakob Gottlieb Svendsen’s page <a href="https://blog.coretech.dk/jgs/azure-automation-script-for-downloading-and-preparing-azurerm-modules-for-azure-automation/">here</a> and follow his instructions. You’ll thank me later :-).

You can find my Azure Automation script for this posted at my GitHub repository here <a href="https://raw.githubusercontent.com/phillipgibson/OMS_Stuff/master/SaveOMSLogSearchCSVToBlobStorage.ps1">https://raw.githubusercontent.com/phillipgibson/OMS_Stuff/master/SaveOMSLogSearchCSVToBlobStorage.ps1</a>

&nbsp;

Let’s pause right here to end part 1 of this blog series. The key thing you’ll want to have been able to complete is the Azure Automation of running your OMS saved search query, capturing the data in a CSV file, and then loading the CSV to your blob storage. If all of that is complete then you’re in good shape to continue to part 2 below.

<a href="https://blogs.technet.microsoft.com/phillipgibson/2016/10/12/move-and-store-operations-management-suite-oms-log-analytics-data-to-azure-sql-data-warehouse-using-azure-data-factory-part-2/">https://blogs.technet.microsoft.com/phillipgibson/2016/10/12/move-and-store-operations-management-suite-oms-log-analytics-data-to-azure-sql-data-warehouse-using-azure-data-factory-part-2/</a>

&nbsp;

<strong>Phil Gibson</strong>

Cloud Solutions Specialist | MCSD: Azure Solutions Architect]]></content:encoded>
    </item>
    <item>
      <title>Move and Store Operations Management Suite (OMS) Log Analytics Data to Azure SQL Data Warehouse using Azure Data Factory – Part 2</title>
      <link>https://docs.microsoft.com/archive/blogs/phillipgibson/move-and-store-operations-management-suite-oms-log-analytics-data-to-azure-sql-data-warehouse-using-azure-data-factory-part-2</link>
      <pubDate>Wed, 12 Oct 2016 23:13:44 GMT</pubDate>
      <dc:creator><![CDATA[Phil Gibson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/phillipgibson/?p=306</guid>
      <description><![CDATA[So let’s pick up where we left of in part 1 of this series. If everything was done correctly, you...]]></description>
      <content:encoded><![CDATA[So let’s pick up where we left of in <a href="https://blogs.technet.microsoft.com/phillipgibson/2016/10/12/move-and-store-operations-management-suite-oms-log-analytics-data-to-azure-sql-data-warehouse-using-azure-data-factory-part-1/">part 1</a> of this series. If everything was done correctly, you should now have a CSV file in your storage container like I’m showing below. If you do not have your CSV file in your storage container, please do so before continuing.

<img width="300" height="123" class="alignnone size-medium wp-image-315" alt="OMSLogsToAzureSQLDW-Part2-01" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-01-300x123.png" />
<h1><span style="color: #2e74b5;font-family: Calibri Light;font-size: x-large">Step 6: Create an Azure Data Factory Service and Create Linked Services to Azure Storage Blob and Azure SQL Data Warehouse</span></h1>
Setting up the Azure Data Factory service is actually very simple to do. Follow this post <a href="https://azure.microsoft.com/en-us/documentation/articles/data-factory-build-your-first-pipeline-using-editor/">Build your first Azure data factory using Azure portal</a> and run through all 7 steps to set it up.

After you have the Azure Data Factory service up, now we just need to setup the connected resources to connect our Azure Storage account where the OMS Log Search CSV file is located, and the Azure SQL Data Warehouse database is located. Be sure to have your storage account name, storage account container name, storage account access key, data warehouse name, data warehouse user name and password, data warehouse table name created earlier, and the OMS log search csv name.

Go to your newly created Azure Data Factory service and click on the Author and deploy tile.

<img width="300" height="252" class="alignnone size-medium wp-image-325" alt="OMSLogsToAzureSQLDW-Part2-03" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-03-300x252.png" />

Select 'New Data Store', and then 'Azure SQL Data Warehouse'. Fill in the connectionstring property of the JSON file with the information for your Azure SQL Data Warehouse, then click 'Deploy'.

<img width="300" height="83" class="alignnone size-medium wp-image-356" alt="OMSLogsToAzureSQLDW-Part2-05" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-05-300x83.png" />

Select 'New Data Store', and then 'Azure Storage. Fill in the connectionstring property of the JSON file with the information for your Azure Storage Acouunt, then click 'Deploy'.

<img width="300" height="109" class="alignnone size-medium wp-image-365" alt="OMSLogsToAzureSQLDW-Part2-04" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-04-300x109.png" />
<h1><span style="color: #2e74b5;font-family: Calibri Light;font-size: x-large">Step 7: Use the Data Factory Copy Wizard to create a Pipeline from Azure Storage to Azure SQL Data Warehouse</span></h1>
The Azure Data Factory Copy Wizard will create a pipeline activity that will read our CSV file on Azure Storage, then move its data contents over to the Azure SQL Data Warehouse database table we created earlier. The beauty about the Azure Data Factory Copy Wizard is that there is essentially no code to create, and provides a wizard based approach. Once you use it you'll start to see how easy it can be utilized for other tasks of moving data around in your environment. One thing to note is I've created this solution many times and have different sets of screen shots that I'm using. So please ignore the fact that some of my naming conventions are not exact throughout these post. Just ensure yours are correct and the solution will work for you. For more detailed information on using the Data Factory Copy Wizard check out the following post for a tutorial and please refer to it if you find things not working correctly <a href="https://azure.microsoft.com/en-us/documentation/articles/data-factory-copy-data-wizard-tutorial/">https://azure.microsoft.com/en-us/documentation/articles/data-factory-copy-data-wizard-tutorial/</a>.

Go to your Azure Data Factory service and click on the 'Copy data (Preview)' tile.

<img width="300" height="132" class="alignnone size-medium wp-image-515" alt="OMSLogsToAzureSQLDW-Part2-06" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-06-300x132.png" />

This will launch the Data Factory Copy Data web page.

On the <strong>Properties</strong> page:
<ul>
 	<li>Enter a the task name like 'CopyOMSLogsToAzureSqlDw'.</li>
 	<li>Enter a description (optional)</li>
 	<li>Choose the task cadence to run regularly on schedule and choose Daily once a day.</li>
 	<li>Select a start time in the past and then set a stop time in the future. For testing I did put a value of yesterday and then ended it a year in the future. The key thing with the time is that you want to sync this to after your Azure Automation schedule will make the CSV file available. We'll discuss that in more detail later.</li>
 	<li>Click 'Next'.</li>
</ul>
<img width="300" height="219" class="alignnone size-medium wp-image-525" alt="OMSLogsToAzureSQLDW-Part2-07" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-07-300x219.png" />

On the <strong>Source data store</strong> page click on 'From Existing Connections', then select the Azure Storage linked service you created and click 'Next'.

<img width="300" height="145" class="alignnone size-medium wp-image-535" alt="OMSLogsToAzureSQLDW-Part2-07-5" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-07-5-300x145.png" />

On the <strong>Connection Properties</strong> page, just ensure the Azure storage service is set to Azure Blob and click 'Next'.

<img width="300" height="117" class="alignnone size-medium wp-image-536" alt="OMSLogsToAzureSQLDW-Part2-07-6" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-07-6-300x117.png" />

On the <strong>Choose the input file or folder</strong> page, double click on the storage container and then choose the CSV file from the OMS log search results. Click 'Choose' and click 'Next'.

<img width="300" height="175" class="alignnone size-medium wp-image-395" alt="OMSLogsToAzureSQLDW-Part2-10" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-10-300x175.png" />

On the <strong>File format settings</strong> page, most of the setting should be auto-detected. Make sure you enter 1 for the Skip line count. Also expand Advanced settings and enter a quote &lt;"&gt; in the Quote character field.. Click 'Next'.

<img width="237" height="300" class="alignnone size-medium wp-image-415" alt="OMSLogsToAzureSQLDW-Part2-12" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-12-237x300.png" />

On the <strong>Destination data store</strong> page, again choose 'From Existing Linked Services' and then select the Azure SQL Data Warehouse linked service you created and click 'Next'.

<img width="300" height="124" class="alignnone size-medium wp-image-545" alt="OMSLogsToAzureSQLDW-Part2-07-7" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-07-7-300x124.png" />

Click 'Next' on the <strong>Connection Properties</strong> page.

On the <strong>Table mapping</strong> page, choose the table we created in the database. Click 'Next'.

<img width="300" height="207" class="alignnone size-medium wp-image-455" alt="OMSLogsToAzureSQLDW-Part2-16" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-16-300x207.png" />

On the <strong>Schema mapping</strong> page, just ensure that the data type from the CSV file detected is the same data type being mapped over to the database table. You could experience errors when the pipeline runs if the data types do not match up. Click 'Next'.

<img width="300" height="143" class="alignnone size-medium wp-image-465" alt="OMSLogsToAzureSQLDW-Part2-17" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-17-300x143.png" />

On the <strong>Performance setting</strong> page, uncheck the 'Allow polybase'. For this test we will not need it. This is something you can revisit when you start building your production solution. Click 'Next'.

<img width="300" height="267" class="alignnone size-medium wp-image-475" alt="OMSLogsToAzureSQLDW-Part2-18" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-18-300x267.png" />

Click 'Finish' on the <strong>Summary</strong> page once everything looks correct. This will start the build of the pipeline.

<img width="300" height="147" class="alignnone size-medium wp-image-485" alt="OMSLogsToAzureSQLDW-Part2-19" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-19-300x147.png" />

Your deployment should now show complete.

<img width="300" height="147" class="alignnone size-medium wp-image-555" alt="OMSLogsToAzureSQLDW-Part2-20-5" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-20-5-300x147.png" />

<span style="color: #2e74b5;font-family: Calibri Light;font-size: x-large">Step 8: View Your Data in the Azure SQL Data Warehouse</span>

Finally we've made it to the final step. If everything went as planned, the pipeline should execute with no issues. You can view the pipeline status in the Azure console as well as using PowerShell cmdlets. You can now connect to your Azure SQL Data Warehouse and see the exact same data from the CSV file loaded into the database table like below.

<img width="300" height="192" class="alignnone size-medium wp-image-565" alt="OMSLogsToAzureSQLDW-Part2-22" src="https://msdnshared.blob.core.windows.net/media/2016/10/OMSLogsToAzureSQLDW-Part2-22-300x192.png" />

<span style="color: #2e74b5;font-family: Calibri Light;font-size: x-large">Final Thoughts</span>

So this was a quick tutorial on how to archive OMS Log Analytics data in a Azure SQL Data Warehouse leveraging Azure Data Factory. Hopefully this activity has sparked some solutions you could utilize OMS Log Analytics and Azure Data Factory for as it has done for me.

&nbsp;

<strong>Phil Gibson</strong>

Cloud Solutions Specialist | MCSD: Azure Solutions Architect

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Techniques for Tuning your Operations Management Suite (OMS) Log Analytics Ingestion</title>
      <link>https://docs.microsoft.com/archive/blogs/phillipgibson/techniques-for-tuning-your-operations-management-suite-oms-log-analytics-ingestion</link>
      <pubDate>Fri, 08 Jul 2016 18:00:31 GMT</pubDate>
      <dc:creator><![CDATA[Phil Gibson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/phillipgibson/?p=175</guid>
      <description><![CDATA[Lately I’ve been working with several customers on onboarding them to utilize the Log Analytics...]]></description>
      <content:encoded><![CDATA[Lately I’ve been working with several customers on onboarding them to utilize the Log Analytics service of OMS. Once the service is up and running and collecting logs based on the Solution Packs enabled, I consistently get two questions/statements. The first is “there’s a lot of data flowing into OMS”, and “how can I tune/filter the data?”.

The first thing I explain is about how the logs are collected, as this seems to be a point of confusion especially in environments that are currently running System Center Operations Manager. When the OMS agent (Microsoft Management Agent (MMA)) is enabled on a Windows and/or Linux system, we pull all of the logging events associated with the OMS Solution Packs. Now depending on some of the Solution Packs there could be certain things that are not logged, but for the majority we are gathering everything. For instance, the Security and Audit Solution Pack, we are pulling all of the Windows security events, Windows application events, and Windows firewall logs.

Unlike System Center Operations Manager, systems enabled for OMS Log Analytics do not participate in any OpsMgr workflows. Meaning you cannot create overrides to turn on or off alerts. The OpsMgr Management group is really just used as a consolidation point proxy for sending data to OMS.

Now let’s talk about some simple techniques you can utilize to discover what the most offending logs and events in your environment could be that is driving up the ingestion rate into OMS. The first thing to do is to navigate to the Log Search and run the following query to discover the top 10 log types in OMS.

&nbsp;

<strong>* | measure count() by Type | top 10</strong>

Below is the result of the query and I can see that my most offending Type is the SecurityEvent Type.

<a href="https://msdnshared.blob.core.windows.net/media/2016/07/OMS_SecurityEvent_Activity_Query_Result.png"><img class="alignnone wp-image-195" src="https://msdnshared.blob.core.windows.net/media/2016/07/OMS_SecurityEvent_Activity_Query_Result-300x122.png" alt="OMS_SecurityEvent_Activity_Query_Result" width="479" height="195" /></a>

Now that we know the most offending Type, let’s now see what is the most offending activity in the SecurityEvent Type by running the following query.

&nbsp;

<strong>Type=SecurityEvent | measu</strong><strong>re count() by Activity | top 10</strong>

I can now see that I have several event that have collected over one million events each, the top being Event ID 4624 – An account was successfully logged on.

<a href="https://msdnshared.blob.core.windows.net/media/2016/07/OMS_Type_Query_Result.png"><img class="alignnone wp-image-185" src="https://msdnshared.blob.core.windows.net/media/2016/07/OMS_Type_Query_Result-300x113.png" alt="OMS_Type_Query_Result" width="478" height="180" /></a>

Depending on the specific event data that you are looking to collect for analysis, you will need to go through your policies and processes to figure out what events are of value to your organization. If you are seeing a high level of events that are considered useless to your analysis, then the next steps for you are to edit the audit policies and stop logging those events.

So this was a simple technique to help you identify the events that are the most offending in your OMS workspace. Hopefully this will be of value as you continue to utilize the Log Analytics of OMS.]]></content:encoded>
    </item>
    <item>
      <title>Automating the Update of Baselines in System Center Virtual Machine Manager</title>
      <link>https://docs.microsoft.com/archive/blogs/phillipgibson/automating-the-update-of-baselines-in-system-center-virtual-machine-manager</link>
      <pubDate>Mon, 05 Aug 2013 20:39:01 GMT</pubDate>
      <dc:creator><![CDATA[Phil Gibson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/phillipgibson/2013/08/05/automating-the-update-of-baselines-in-system-center-virtual-machine-manager/</guid>
      <description><![CDATA[Recently I’ve seen a request that asked if there was a way to automate the update of a baseline in...]]></description>
      <content:encoded><![CDATA[<p>Recently I’ve seen a request that asked if there was a way to automate the update of a baseline in System Center Virtual Machine Manager. I then remembered that I actually did play around with this and wrote a PowerShell script a while back. Seeing that this might be a helpful to the community, I dug up the script to post on my blog. This specific script was in a SCVMM 2008 R2 environment. This has not been tested for SCVMM 2012, so I’m not exactly sure if this will port directly to SCVMM 2012. </p>  <p> As I try to recall the specifics of the environment that I used this script in, SCVMM had an update server specified, a baseline was configured, and the baseline was targeted to a specific host group. What this script does is gets the baseline and the host group and looks for the fifty (50) newest updates from the update server with classification of “Security Updates” and “Critical Updates” for Windows Server 2008 R2. These were the only classifications the customer was interested in and I chose to look up the newest 50 updates with the rational that there could never be more than 50 updates between each Patch Tuesday each month :-). Once I get the newest 50 updates, I then compare them to what is currently listed in the current baseline and then build an array with the difference. Which ever updates are not listed in the current baseline will get updated with the newest updates. </p>  <p> Try it out and let me know if there’s any questions. Again I developed this script a while ago and haven’t tested it recently. </p>  <p>&#160;</p>  <p>&#160;</p>  <p>Import-Module VirtualMachineManager </p>  <p>$ContosoBaseline = Get-SCBaseline | where { $_.Name -eq &quot;Contoso Baseline&quot; }    <br /> $ContosoHostGroup = Get-SCVMHostGroup | where { $_.Name -eq &quot;Contoso Host Group&quot; } </p>  <p>$baseline = Get-SCBaseline -ID $ContosoBaseline.ID </p>  <p>$addedUpdateList = @()    <br /> $scope = Get-SCVMHostGroup -Name $ContosoHostGroup.Name -ID $ContosoHostGroup.ID </p>  <p>$SCVMMJobGUID = [System.Guid]::NewGuid() </p>  <p>$ContosoLatestUpdates = Get-SCUpdate -Newest 50 | where { ($_.UpdateClassification -eq &quot;Security Updates&quot; -or $_.UpdateClassification -eq &quot;Critical Updates&quot;) -and $_.Products -eq &quot;Windows Server 2008 R2&quot; } </p>  <p># Nested For Loop needed to filter against existing updates to new updates and only add new updates to the $addedUpdateList    <br />ForEach ($Update in $ContosoLatestUpdates)     <br />&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ForEach ($ContosoUpdate in $ContosoBaseline)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If ($Update -eq $ContosoUpdate)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $UpdateExistsInBaseline = $True&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Else     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $UpdateExistsInBaseline = $False     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; } </p>  <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; If (!$UpdateExistsInBaseline)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $addedUpdateList += Get-SCUpdate -ID $Update.ID     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } </p>  <p>&#160;&#160;&#160;&#160;&#160; } </p>  <p>Set-SCBaseline -Baseline $baseline -AddAssignmentScope $scope -JobGroup $SCVMMJobGUID.ToString() -RunAsynchronously </p>  <p>Set-SCBaseline -Baseline $baseline -Name $ContosoBaseline.Name.ToString() -RunAsynchronously -AddUpdates $addedUpdateList -JobGroup $SCVMMJobGUID.ToString() -StartNow</p>]]></content:encoded>
    </item>
    <item>
      <title>System Center Orchestrator - How to use a complex type and/or collection on the databus when using the “Run VMM PowerShell Script” activity from the Virtual Machine Manager Integration Pack</title>
      <link>https://docs.microsoft.com/archive/blogs/phillipgibson/system-center-orchestrator-how-to-use-a-complex-type-andor-collection-on-the-databus-when-using-the-run-vmm-powershell-script-activity-from-the-virtual-machine-manager-integration-pac</link>
      <pubDate>Tue, 18 Jun 2013 14:19:31 GMT</pubDate>
      <dc:creator><![CDATA[]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/phillipgibson/2013/06/18/system-center-orchestrator-how-to-use-a-complex-type-andor-collection-on-the-databus-when-using-the-run-vmm-powershell-script-activity-from-the-virtual-machine-manager-integration-pac/</guid>
      <description><![CDATA[I’ve been working a lot of Cloud engagements lately focusing on extensive automation of service...]]></description>
      <content:encoded><![CDATA[<p>I’ve been working a lot of Cloud engagements lately focusing on extensive automation of service requests and custom automations to meet customers needs. Since we are using System Center Virtual Machine Manager to manage all the hypervisors I was doing a ton of PowerShell scripting to do my automations and that’s when I came across a road block when using the Run VMM PowerShell Script activity in System Center Orchestrator to pass data along the Orchestrator databus. What I was trying to do was something I’ve done all the time using the “Run .Net Script” activity, which was gather a collection and then publish it onto the Orchestrator databus for use in downstream activities. When I would do this using the Run VMM PowerShell Script activity I would get the following output of <strong>System.Object[]</strong> and ultimately my whole Orchestrator workflow would fail because my downstream activities are expecting certain string data that never gets published. For example take the PowerShell code example below.</p>  <p>&#160;</p>  <p>$myPublishedVMs = @() </p>  <p>$myVMs = Get-SCVirtualMachine </p>  <p>ForEach ($vm in $myVMs)    <br /> {     <br />&#160;&#160;&#160; $myPublishedVMs += $vm.Name.ToString()     <br /> }</p>  <p>If you build a simple Orchestrator runbook using the Run VMM PowerShell Script activity using the PowerShell code and publishing the $myPublishedVMs as Output Variable 01 and send it to a Send Platform Event for testing, you would expect the Send Platform Event to run as many times as the number of elements in the collection.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/2100.image_3F9154F7.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/2100.image_5F00_3F9154F7.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/6320.image_thumb_4CF767FD.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/6320.image_5F00_thumb_5F00_4CF767FD.png" width="214" height="169" /></a>&#160;&#160;&#160; </p>  <p>&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/0167.image_4C8B3508.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/0167.image_5F00_4C8B3508.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/0576.image_thumb_2C03F556.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/0576.image_5F00_thumb_5F00_2C03F556.png" width="492" height="340" /></a> </p>  <p>&#160;</p>  <p>But instead what you get is an output of <strong>System.Object[]</strong> in the details of the Send Platform Event as shown below.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/7041.image_324ACBE4.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/7041.image_5F00_324ACBE4.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/0435.image_thumb_4A6E363F.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/0435.image_5F00_thumb_5F00_4A6E363F.png" width="504" height="345" /></a> </p>  <p>&#160;</p>  <p>I immediately thought there was an issue until I started doing some digging, like reading the documentation :-), and there it was on the TechNet page saying that this is expected behavior for the Run VMM PowerShell Script activity if your “variable contains a complex type or a collection of objects”. </p>  <p><a title="https://technet.microsoft.com/en-us/library/hh830716.aspx" href="https://technet.microsoft.com/en-us/library/hh830716.aspx">https://technet.microsoft.com/en-us/library/hh830716.aspx</a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/4744.image_69B0DD12.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/4744.image_5F00_69B0DD12.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/5658.image_thumb_141D0E30.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/5658.image_5F00_thumb_5F00_141D0E30.png" width="502" height="177" /></a> </p>  <p>&#160;</p>  <p>Now knowing that I cannot use the Run VMM PowerShell Script activity to publish a collection out to the Orchestrator databus, I had to come up with a solution to make my runbooks work with all that rich data I was getting from the Run VMM PowerShell Script. At first thought I figured I would just substitute in my workflows the Run VMM PowerShell Script activity to the Run .Net Script activity. There’s pros and cons with this and I personally like the Run VMM PowerShell Script activity because it takes care of remoting to the VMM server and the importing of the VMM PowerShell module. When using the Run .Net Script activity I’ve found you have to instrument more error handling to account for the Invoke-Command and other things. </p>  <p>So understanding that I could pass a string as a variable, I figured I would do something I have done countless times in C#, which is to use the String Builder class and just append my string data to a string that I would just publish on the Orchestrator databus and on the next activity I would take the string and then do a split on it to get the items in a collection and then publish that collection onto the databus outside of using the Run VMM PowerShell script. It does add an extra step to your workflow, but the benefits of being able to utilize the built-in looping functionality of Orchestrator is well worth it. In using the same PowerShell code example you would make the following edits below.</p>  <p>$myPublishedVMs = new-object System.Text.StringBuilder</p>  <p>$myVMs = Get-SCVirtualMachine </p>  <p>ForEach ($vm in $myVMs)    <br />{     <br />&#160;&#160;&#160; $myPublishedVMs.append($vm.Name.ToString())     <br />&#160;&#160;&#160; $myPublishedVMs.append(',')     <br />}</p>  <p>$outputVariable01 = $myPublishedVMs.ToString()</p>  <p>Notice that I’m appending a comma as well and simply building a string that will look like “Server01,Server02,Server03,”. You can now output this string on the Orchestrator databus and use a split on the comma to create an array. One other thing that you want to be cautious of is the length of your string that you will put on the Orchestrator databus. Reading Robert Hearn’s blog post ( <a title="https://blogs.technet.com/b/orchestrator/archive/2012/05/08/orchestrator-quick-tip-what-s-the-maximum-size-of-parameters.aspx" href="https://blogs.technet.com/b/orchestrator/archive/2012/05/08/orchestrator-quick-tip-what-s-the-maximum-size-of-parameters.aspx">https://blogs.technet.com/b/orchestrator/archive/2012/05/08/orchestrator-quick-tip-what-s-the-maximum-size-of-parameters.aspx</a>) I would keep the character length of this string to under 2000 characters. So the final code will look like this below.</p>  <p>$myPublishedVMs = new-object System.Text.StringBuilder</p>  <p>$myVMs = Get-SCVirtualMachine </p>  <p>ForEach ($vm in $myVMs)    <br />{     <br />&#160;&#160;&#160; $myPublishedVMs.append($vm.Name.ToString())     <br />&#160;&#160;&#160; $myPublishedVMs.append(',')&#160;&#160; <br />}</p>  <p>$outputVariable01 = $myPublishedVMs.ToString()</p>  <p>$charCount = ($outputVariable01 | Measure-Object –Character).Characters</p>  <p> If ($charCount –gt 2000)    <br />{     <br />&#160;&#160;&#160; Throw [System.Exception]”The output string is more than 2000 characters.”     <br />}</p>  <p>In the following activity use the Run .Net Script activity to convert the $myPublishedVMs string into a collection object that you can then publish back to the Orchestrator databus. One thing to note is that the way I’m building my string in the Run VMM PowerShell Script will always leave an empty element do to the final append of a comma. I’m filtering out the empty element by simply checking if it is null or empty. That PowerShell script code will look similar to this below.</p>  <p>$myVMsArray = @()</p>  <p>$stringOutput = “&lt;Output Variable 01 from Run VMM PowerShell Script&gt;”</p>  <p>$splitVMsOnComma = $stringOutput.Split(“,”)</p>  <p>ForEach ($vm in $splitVMsOnComma)    <br /> {     <br />&#160;&#160;&#160; If (![string]::IsNullOrEmpty($vm))     <br />&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $myVMsArray += ,$vm     <br />&#160;&#160;&#160; }     <br /> }</p>  <p>$myVMsArray </p>  <p>The final test Orchestrator runbook will look like the following.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/8080.image_01681479.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/8080.image_5F00_01681479.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/0312.image_thumb_530E8ECB.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/0312.image_5F00_thumb_5F00_530E8ECB.png" width="313" height="177" /></a> </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/4213.image_0742B812.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/4213.image_5F00_0742B812.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/4478.image_thumb_51C9F5EC.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/4478.image_5F00_thumb_5F00_51C9F5EC.png" width="515" height="355" /></a> </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/3580.image_6D024EED.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/3580.image_5F00_6D024EED.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/4405.image_thumb_1E8DBC83.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/4405.image_5F00_thumb_5F00_1E8DBC83.png" width="523" height="361" /></a> </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/4034.image_2B879C94.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/4034.image_5F00_2B879C94.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/0654.image_thumb_23FC2D27.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/0654.image_5F00_thumb_5F00_23FC2D27.png" width="527" height="364" /></a> </p>  <p><strong>Notice there are double quotes around the Output Variable 01</strong></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/5811.image_08E35E19.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/5811.image_5F00_08E35E19.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/1638.image_thumb_59453F8C.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/1638.image_5F00_thumb_5F00_59453F8C.png" width="514" height="357" /></a> </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/5775.image_3E2C707E.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/5775.image_5F00_3E2C707E.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/1104.image_thumb_08B3AE59.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/1104.image_5F00_thumb_5F00_08B3AE59.png" width="518" height="357" /></a> </p>  <p>Once you check the Orchestrator runbook in and run it, you should see the following results.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/6708.image_5D02E45C.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/6708.image_5F00_5D02E45C.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/1121.image_thumb_4E583877.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/1121.image_5F00_thumb_5F00_4E583877.png" width="519" height="491" /></a> </p>  <p>On my Events tab I show two entries from the Send Platform Event and this correlates to what I have in my current lab, which is two virtual machines showing in Virtual Machine Manager.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/5658.image_1B883203.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/5658.image_5F00_1B883203.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/8420.image_thumb_73E1B5D8.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/8420.image_5F00_thumb_5F00_73E1B5D8.png" width="526" height="217" /></a> </p>  <p></p>  <p>And if I look at both of those events listed in Orchestrator I should see each individual virtual machine listed as an event, which I do shown below.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/3058.image_612CBC21.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/3058.image_5F00_612CBC21.png"><img title="image" style="display: inline;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/0434.image_thumb_0B98ED3F.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/0434.image_5F00_thumb_5F00_0B98ED3F.png" width="528" height="246" /></a> </p>  <p>So that’s all for this post. I hope you guys out there managing and developing solutions around Clouds can utilize this. I know for me being able to have this functionality was HUGE when working with Virtual Machine Manager and developing service requests. This can be very powerful when using the Run VMM PowerShell Script because that activity allows for up to 20 outputs on the Orchestrator databus. Have fun out there :-).</p>  <p>&#160;</p>  <p>Thanks,</p>  <p>Phil Gibson [MSFT]</p>]]></content:encoded>
    </item>
    <item>
      <title>Automating the Move of System Center Operations Manager 2012 Databases using Windows PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/phillipgibson/automating-the-move-of-system-center-operations-manager-2012-databases-using-windows-powershell</link>
      <pubDate>Wed, 24 Oct 2012 13:42:00 GMT</pubDate>
      <dc:creator><![CDATA[Phil Gibson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/phillipgibson/2012/10/24/automating-the-move-of-system-center-operations-manager-2012-databases-using-windows-powershell/</guid>
      <description><![CDATA[&nbsp;
In the case that you need to move your System Center Operations Manager 2012...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p>
<p>In the case that you need to move your System Center Operations Manager 2012 OperationsManager and/or OperationsManagerDW database(s) to a different back-end SQL server, we have documented those step-by-step procedures for you. You can actually find those step-by-step procedures located here for the OperationsManager database ( <a title="https://technet.microsoft.com/en-us/library/hh278848.aspx" href="https://technet.microsoft.com/en-us/library/hh278848.aspx">https://technet.microsoft.com/en-us/library/hh278848.aspx</a> ) and here for the OperationsManagerDW database ( <a title="https://technet.microsoft.com/en-us/library/hh268492.aspx" href="https://technet.microsoft.com/en-us/library/hh268492.aspx">https://technet.microsoft.com/en-us/library/hh268492.aspx</a> ).</p>
<p>What I have done is taken those procedures and coded it into a PowerShell script that you can run in a completely automated fashion. The reason for the development of this script was to provide a solution to a customer that actually needed to have a System Center Operations Manager 2012 infrastructure that could manage servers in multiple geo-located datacenters, and have that infrastructure able to survive a single datacenter outage. I&rsquo;m going to blog extensively on that solution later, but for now just understand that in this scenario both the OperationsManager and OperationsManagerDW are located on a mirrored SQL database back-end that is replicated throughout the geo-located datacenters. This PowerShell script will automate all of the procedures listed in the above step-by-step URLs. What I&rsquo;ve tried to do was to identify in the PowerShell script the step number it was listed as in documented steps. Because I was merging both the OperationsManager and OperationsManagerDW in one PowerShell script, the steps may not totally correlate back to the documentation, but if you are familiar with what the documentation is asking to do, the PowerShell script is following those procedures as serial as possible.</p>
<p><strong>A couple of preparation tips before you begin to utilize this script in your environment</strong></p>
<ol>
<li>Ensure that you are an administrator on all of the Management Servers as well as the SQL Servers</li>
<li>Ensure that the WS-Man protocol is enabled on all of the Management Servers as well as the SQL Servers. I&rsquo;m using PowerShell Invoke-Commands, so this PowerShell script will be initiating remote sessions on those computers. You may want to run &ldquo;winrm quickconfig&rdquo; to enable this.</li>
<li>Ensure that your PowerShell execution policy is set to RemoteSigned or lower for all of the Management Servers as well as the SQL Servers.</li>
<li>Ensure that the machine you plan on executing this PowerShell script has the SQL 2008 R2 client tools installed. When I first began developing this PowerShell script I was using the ADO COM objects to query and update SQL. I have found it much easier to add the SQLServerCmdLetSnapin100 snapin and utilize the Invoke-SQLCmd cmdlet. You&rsquo;ll want to test that you can add that snapin before running the script in automation.</li>
<li>Ensure that the SQL server that you are moving your database(s) to has the same SQL logins for the System Center Operations Manager 2012 accounts that you have defined during installation. Because we will be using a different SQL server, you must ensure that your SDK, DB Reader, and DB Writer accounts continue to have the same level of access from the previous SQL server used.</li>
</ol>
<p>&nbsp;</p>
<p>&nbsp;<strong>Automated OpsMgr 2012 DB Move PowerShell Script Breakdown</strong></p>
<p>I&rsquo;m going to highlight the PowerShell script key functions. You can download the complete script at the end of the post.</p>
<p><strong>Lines 11 &ndash; 34 &ndash; </strong>Here you will have to change the server names to the servers in your environment. You&rsquo;ll enter your Management server names, your current SQL Server(s) that host the OperationsManager and OperationsManagerDW, your new SQL Server(s) that will host the OperationsManager and OperationsManagerDW, your Operations Manager Reporting Server, and the path to ConfigService.config on each Management server. In my case the Management servers had the same standard build configuration, so the path was the same on all Management servers.</p>
<p><strong>Line 36 &ndash; </strong>Adding the SQL PowerShell snapin</p>
<p><strong>Lines 38 &ndash; 60 &ndash; </strong>Stopping all services on all Management Servers</p>
<p><strong>Lines 62 &ndash; 86 &ndash; </strong>Updating all Management Servers registry information to point to the new SQL Server</p>
<p><strong>Lines 88 &ndash; 107 &ndash; </strong>Updating the Operations Manager Report Server to point to the new SQL Server</p>
<p><strong>Lines 109 &ndash; 139 &ndash; </strong>Updating the ConfigService.config XML file on all Management Servers to point to the new SQL Server</p>
<p><strong>Lines 141 &ndash; 188 &ndash; </strong>Updating the OperationsManager and OperationsManagerDW with the new SQL Server name</p>
<p><strong>Lines 190 &ndash; 207 &ndash; </strong>Enabling the SQL Broker for the OperationsManager DB if needed</p>
<p><strong>Lines 210 &ndash; 231 &ndash; </strong>Starting all services on all Management Servers</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;">
<div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum1" style="color: #606060;"> 1:</span> &lt;#</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum2" style="color: #606060;"> 2:</span>   Purpose  : Automate the move of System Center Operations Manager 2012 Databases</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum3" style="color: #606060;"> 3:</span>             </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum4" style="color: #606060;"> 4:</span>   Author   : pgibson.online@hotmail.com [MSFT]</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum5" style="color: #606060;"> 5:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum6" style="color: #606060;"> 6:</span>   Disclaimer: THIS CODE AND INFORMATION IS PROVIDED <span style="color: #006080;">"AS IS"</span> WITHOUT WARRANTY OF ANY KIND, </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum7" style="color: #606060;"> 7:</span>               EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum8" style="color: #606060;"> 8:</span>               WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum9" style="color: #606060;"> 9:</span> #&gt;</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum10" style="color: #606060;"> 10:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum11" style="color: #606060;"> 11:</span> # ************ Set PS Script Environemnt Variables *************************</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum12" style="color: #606060;"> 12:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum13" style="color: #606060;"> 13:</span> # Management Servers Array</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum14" style="color: #606060;"> 14:</span> [Array]$MgmtServers =<span style="color: #006080;">"MGMTSRV01.contoso.com"</span>,<span style="color: #006080;">"MGMTSRV02.contoso.com"</span>,<span style="color: #006080;">"MGMTSRV03.contoso.com"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum15" style="color: #606060;"> 15:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum16" style="color: #606060;"> 16:</span> # Current SQL OperationsManager DB Server</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum17" style="color: #606060;"> 17:</span> $global:CurrentSQLOpsMgrDBSrv = <span style="color: #006080;">"SQLSRVOPSDB01.contoso.com"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum18" style="color: #606060;"> 18:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum19" style="color: #606060;"> 19:</span> # New SQL OperationsManager DB Server</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum20" style="color: #606060;"> 20:</span> $global:NewSQLOpsMgrDBSrv = <span style="color: #006080;">"SQLSRVOPSDB02.contoso.com"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum21" style="color: #606060;"> 21:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum22" style="color: #606060;"> 22:</span> # Current SQL OperationsManagerDW DB Server</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum23" style="color: #606060;"> 23:</span> $global:CurrentSQLOpsMgrDWSrv = <span style="color: #006080;">"SQLSRVDWDB01.contoso.com"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum24" style="color: #606060;"> 24:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum25" style="color: #606060;"> 25:</span> # New SQL OperationsManagerDW DB Server</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum26" style="color: #606060;"> 26:</span> $global:NewSQLOpsMgrDWSrv = <span style="color: #006080;">"SQLSRVDWDB02.contoso.com"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum27" style="color: #606060;"> 27:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum28" style="color: #606060;"> 28:</span> # Current OpsMgr Report Server</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum29" style="color: #606060;"> 29:</span> $global:CurrentOpsMgrRptSrv = <span style="color: #006080;">"OPSMGRRPTSRV01.contoso.com"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum30" style="color: #606060;"> 30:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum31" style="color: #606060;"> 31:</span> # Enter the path of the ConfigService.config file of all Management Servers</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum32" style="color: #606060;"> 32:</span> $global:CngSvcCfgFilePath = <span style="color: #006080;">"E:\Program Files\System Center 2012\Operations Manager\Server\ConfigService.config"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum33" style="color: #606060;"> 33:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum34" style="color: #606060;"> 34:</span> # ************ End PS Script Environemnt Variables *************************</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum35" style="color: #606060;"> 35:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum36" style="color: #606060;"> 36:</span> add-pssnapin SqlServerCmdLetSnapin100 -EA 0</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum37" style="color: #606060;"> 37:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum38" style="color: #606060;"> 38:</span> # Step 1 - Stop the Operations Manager services</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum39" style="color: #606060;"> 39:</span> write-host <span style="color: #006080;">"Stopping Management Server(s) services."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum40" style="color: #606060;"> 40:</span> Invoke-Command -ComputerName $MgmtServers -ScriptBlock {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum41" style="color: #606060;"> 41:</span>     $OpsMgr12MgmtSrvSvcArray = @(<span style="color: #006080;">"System Center Data Access Service"</span>, <span style="color: #006080;">"System Center Management"</span>, <span style="color: #006080;">"System Center Management Configuration"</span>)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum42" style="color: #606060;"> 42:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum43" style="color: #606060;"> 43:</span>     ForEach ($svc <span style="color: #0000ff;">in</span> $OpsMgr12MgmtSrvSvcArray)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum44" style="color: #606060;"> 44:</span>         {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum45" style="color: #606060;"> 45:</span>             write-host <span style="color: #006080;">"Stopping service $svc on $Env:ComputerName..."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum46" style="color: #606060;"> 46:</span>             $SCOpsMgrSvc = Get-Service | ? { $_.DisplayName -eq $svc}</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum47" style="color: #606060;"> 47:</span>             If ($SCOpsMgrSvc.Status -ne <span style="color: #006080;">"Stopped"</span>)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum48" style="color: #606060;"> 48:</span>                 {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum49" style="color: #606060;"> 49:</span>                     Stop-Service -DisplayName $svc</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum50" style="color: #606060;"> 50:</span>                     Do</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum51" style="color: #606060;"> 51:</span>                         { </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum52" style="color: #606060;"> 52:</span>                             Start-Sleep -s 15</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum53" style="color: #606060;"> 53:</span>                             $SCOpsMgrSvc = Get-Service | ? { $_.DisplayName -eq $svc}</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum54" style="color: #606060;"> 54:</span>                         } Until ($SCOpsMgrSvc.Status -eq <span style="color: #006080;">"Stopped"</span>)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum55" style="color: #606060;"> 55:</span>                 }</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum56" style="color: #606060;"> 56:</span>             write-host <span style="color: #006080;">"The service $svc is stopped on $Env:ComputerName."</span>            </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum57" style="color: #606060;"> 57:</span>         </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum58" style="color: #606060;"> 58:</span>         }</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum59" style="color: #606060;"> 59:</span>  } # End Invoke-Command <span style="color: #0000ff;">for</span> stopping Management Server services</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum60" style="color: #606060;"> 60:</span> write-host <span style="color: #006080;">"Finished stopping Management Server(s) services."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum61" style="color: #606060;"> 61:</span>         </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum62" style="color: #606060;"> 62:</span> # Step 6 - Update registry to refer to the <span style="color: #0000ff;">new</span> SQL Server-based computer</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum63" style="color: #606060;"> 63:</span> write-host <span style="color: #006080;">"Updating Management Server(s) registry to refer to new SQL Server."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum64" style="color: #606060;"> 64:</span> Invoke-Command -ComputerName $MgmtServers -ScriptBlock {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum65" style="color: #606060;"> 65:</span>     param(</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum66" style="color: #606060;"> 66:</span>         [Parameter(Position=0)]</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum67" style="color: #606060;"> 67:</span>         $LocalVarNewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum68" style="color: #606060;"> 68:</span>     )</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum69" style="color: #606060;"> 69:</span>  </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum70" style="color: #606060;"> 70:</span>     $RegKeyDatabaseServerName = Get-ItemProperty -Path <span style="color: #006080;">"HKLM:\SOFTWARE\Microsoft\System Center\2010\Common\Database"</span> -Name <span style="color: #006080;">"DatabaseServerName"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum71" style="color: #606060;"> 71:</span>     </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum72" style="color: #606060;"> 72:</span>     If ($RegKeyDatabaseServerName.DatabaseServerName -ne $LocalVarNewSQLOpsMgrDBSrv)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum73" style="color: #606060;"> 73:</span>         {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum74" style="color: #606060;"> 74:</span>             write-host <span style="color: #006080;">"Changing registry key HKLM:\SOFTWARE\Microsoft\System Center\2010\Common\Database\DatabaseServerName on $Env:ComputerName"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum75" style="color: #606060;"> 75:</span>             Set-ItemProperty -Path <span style="color: #006080;">"HKLM:\SOFTWARE\Microsoft\System Center\2010\Common\Database"</span> -Name <span style="color: #006080;">"DatabaseServerName"</span> -Value $LocalVarNewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum76" style="color: #606060;"> 76:</span>             write-host <span style="color: #006080;">"Completed registry key change HKLM:\SOFTWARE\Microsoft\System Center\2010\Common\Database\DatabaseServerName on $Env:ComputerName"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum77" style="color: #606060;"> 77:</span>         }</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum78" style="color: #606060;"> 78:</span>     Else</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum79" style="color: #606060;"> 79:</span>         {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum80" style="color: #606060;"> 80:</span>             write-host <span style="color: #006080;">"No modification to registry key HKLM:\SOFTWARE\Microsoft\System Center\2010\Common\Database\DatabaseServerName needed on $Env:ComputerName"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum81" style="color: #606060;"> 81:</span>         }</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum82" style="color: #606060;"> 82:</span>         </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum83" style="color: #606060;"> 83:</span>     </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum84" style="color: #606060;"> 84:</span> } -Argumentlist $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum85" style="color: #606060;"> 85:</span> # End Invoke-Command <span style="color: #0000ff;">for</span> changing management server registry keys  </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum86" style="color: #606060;"> 86:</span> write-host <span style="color: #006080;">"Completed updating Management Server(s) registry to refer to new SQL Server."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum87" style="color: #606060;"> 87:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum88" style="color: #606060;"> 88:</span> # Step 6.1 - Update registry on OpsMgr Report Server to refer to the <span style="color: #0000ff;">new</span> SQL Server-based computer</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum89" style="color: #606060;"> 89:</span> write-host <span style="color: #006080;">"Updating Management OpsMgr Report Server registry to refer to new SQL Server."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum90" style="color: #606060;"> 90:</span> Invoke-Command -ComputerName $CurrentOpsMgrRptSrv -ScriptBlock {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum91" style="color: #606060;"> 91:</span>     param(</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum92" style="color: #606060;"> 92:</span>         [Parameter(Position=0)]</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum93" style="color: #606060;"> 93:</span>         $LocalVarOpsMgrRptSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum94" style="color: #606060;"> 94:</span>     )</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum95" style="color: #606060;"> 95:</span>     </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum96" style="color: #606060;"> 96:</span>     #$RegKeyDefaultSDKServiceMachine = Get-ItemProperty -Path <span style="color: #006080;">"HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Reporting"</span> -Name <span style="color: #006080;">"DefaultSDKServiceMachine"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum97" style="color: #606060;"> 97:</span>     $RegKeyDWDBInstance = Get-ItemProperty -Path <span style="color: #006080;">"HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Reporting"</span> -Name <span style="color: #006080;">"DWDBInstance"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum98" style="color: #606060;"> 98:</span>     If ($RegKeyDWDBInstance.DWDBInstance -ne $LocalVarOpsMgrRptSrv)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum99" style="color: #606060;"> 99:</span>         {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum100" style="color: #606060;"> 100:</span>             write-host <span style="color: #006080;">"Changing registry key HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Reporting\DWDBInstance on $Env:ComputerName"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum101" style="color: #606060;"> 101:</span>             Set-ItemProperty -Path <span style="color: #006080;">"HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Reporting"</span> -Name <span style="color: #006080;">"DWDBInstance"</span> -Value $LocalVarOpsMgrRptSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum102" style="color: #606060;"> 102:</span>             write-host <span style="color: #006080;">"Completed registry key change HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Reporting\DWDBInstance on $Env:ComputerName"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum103" style="color: #606060;"> 103:</span>         }</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum104" style="color: #606060;"> 104:</span>  </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum105" style="color: #606060;"> 105:</span> } -ArgumentList $CurrentOpsMgrRptSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum106" style="color: #606060;"> 106:</span> # End Invoke-Command <span style="color: #0000ff;">for</span> changing OpsMgr Report Server registry keys  </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum107" style="color: #606060;"> 107:</span> write-host <span style="color: #006080;">"Completed updating OpsMgr Report Server registry to refer to new SQL Server."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum108" style="color: #606060;"> 108:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum109" style="color: #606060;"> 109:</span> # Step 7 - Edit the ConfigService.config file</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum110" style="color: #606060;"> 110:</span> write-host <span style="color: #006080;">"Editing Management Server(s) ConfigService.config file."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum111" style="color: #606060;"> 111:</span> Invoke-Command -ComputerName $MgmtServers -ScriptBlock {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum112" style="color: #606060;"> 112:</span>     param(</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum113" style="color: #606060;"> 113:</span>         [Parameter(Position=0)]</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum114" style="color: #606060;"> 114:</span>         $LocalVarCngSvcCfgFilePath</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum115" style="color: #606060;"> 115:</span>     ,</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum116" style="color: #606060;"> 116:</span>         [Parameter(Position=1)]</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum117" style="color: #606060;"> 117:</span>         $LocalVarNewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum118" style="color: #606060;"> 118:</span>     )</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum119" style="color: #606060;"> 119:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum120" style="color: #606060;"> 120:</span>     If (test-path $LocalVarCngSvcCfgFilePath)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum121" style="color: #606060;"> 121:</span>         {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum122" style="color: #606060;"> 122:</span>             $xmlConfigSvcCfg = [XML] (get-content $LocalVarCngSvcCfgFilePath)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum123" style="color: #606060;"> 123:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum124" style="color: #606060;"> 124:</span>             $CmdbServerName = $xmlConfigSvcCfg.SelectSingleNode(<span style="color: #006080;">"/Config/Component/Instance/Category[@Name='Cmdb']/Setting[@Name='ServerName']"</span>)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum125" style="color: #606060;"> 125:</span>             $CmdbServerName.Value = $LocalVarNewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum126" style="color: #606060;"> 126:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum127" style="color: #606060;"> 127:</span>             $ConfigStoreServerName = $xmlConfigSvcCfg.SelectSingleNode(<span style="color: #006080;">"/Config/Component/Instance/Category[@Name='ConfigStore']/Setting[@Name='ServerName']"</span>)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum128" style="color: #606060;"> 128:</span>             $ConfigStoreServerName.Value = $LocalVarNewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum129" style="color: #606060;"> 129:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum130" style="color: #606060;"> 130:</span>             $xmlConfigSvcCfg.Save($LocalVarCngSvcCfgFilePath)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum131" style="color: #606060;"> 131:</span>         }</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum132" style="color: #606060;"> 132:</span>     Else</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum133" style="color: #606060;"> 133:</span>         {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum134" style="color: #606060;"> 134:</span>             write-host <span style="color: #006080;">"File not found at $LocalVarCngSvcCfgFilePath"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum135" style="color: #606060;"> 135:</span>         }</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum136" style="color: #606060;"> 136:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum137" style="color: #606060;"> 137:</span> } -ArgumentList $CngSvcCfgFilePath, $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum138" style="color: #606060;"> 138:</span> # End Invoke-Command <span style="color: #0000ff;">for</span> editing management server ConfigService.config file</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum139" style="color: #606060;"> 139:</span> write-host <span style="color: #006080;">"Finished editing Management Server(s) ConfigService.config file."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum140" style="color: #606060;"> 140:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum141" style="color: #606060;"> 141:</span> write-host <span style="color: #006080;">"Updating SQL tables with new SQL Server name."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum142" style="color: #606060;"> 142:</span> # Step 8 - Udpate Operational Database with <span style="color: #0000ff;">new</span> SQL Server name</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum143" style="color: #606060;"> 143:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum144" style="color: #606060;"> 144:</span> # Translate tables name which has <span style="color: #006080;">"$"</span> <span style="color: #0000ff;">in</span> name</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum145" style="color: #606060;"> 145:</span> $MT_MSFTSysCntrMgmtGrpTbl = <span style="color: #006080;">"dbo.MT_Microsoft`$SystemCenter`$ManagementGroup"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum146" style="color: #606060;"> 146:</span> $MT_MSFTSysCntrDWTbl = <span style="color: #006080;">"dbo.MT_Microsoft`$SystemCenter`$DataWarehouse"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum147" style="color: #606060;"> 147:</span> $MT_MSFTSysCntrDWAppMonTbl = <span style="color: #006080;">"dbo.MT_Microsoft`$SystemCenter`$DataWarehouse`$AppMonitoring"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum148" style="color: #606060;"> 148:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum149" style="color: #606060;"> 149:</span> # Because the SQLServerName_GUID column <span style="color: #0000ff;">is</span> dynamic, we need to find <span style="color: #0000ff;">out</span> the column name <span style="color: #0000ff;">for</span> <span style="color: #0000ff;">this</span> installation instance</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum150" style="color: #606060;"> 150:</span> $GetMgmtGroupSrvNameColumn = invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"Select top 1 * from sys.syscolumns where name like 'SQLServerName_%'"</span> -ServerInstance $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum151" style="color: #606060;"> 151:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum152" style="color: #606060;"> 152:</span> # Translate $GetMgmtGroupSrvNameColumn result to <span style="color: #0000ff;">string</span> data type</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum153" style="color: #606060;"> 153:</span> $MgmtGrpSrvNameColumn = $GetMgmtGroupSrvNameColumn.Name.ToString()</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum154" style="color: #606060;"> 154:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum155" style="color: #606060;"> 155:</span> # Update Opertional Database server name</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum156" style="color: #606060;"> 156:</span> write-host <span style="color: #006080;">"Updating SQL table $MT_MSFTSysCntrMgmtGrpTbl column $MgmtGrpSrvNameColumn on SQL Server $NewSQLOpsMgrDBSrv..."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum157" style="color: #606060;"> 157:</span> invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"UPDATE $MT_MSFTSysCntrMgmtGrpTbl SET $MgmtGrpSrvNameColumn = '$NewSQLOpsMgrDBSrv'"</span> -ServerInstance $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum158" style="color: #606060;"> 158:</span> write-host <span style="color: #006080;">"Completed updating SQL table $MT_MSFTSysCntrMgmtGrpTbl column $MgmtGrpSrvNameColumn on SQL Server $NewSQLOpsMgrDBSrv."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum159" style="color: #606060;"> 159:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum160" style="color: #606060;"> 160:</span> # Step 9 - Udpate Operational Database with <span style="color: #0000ff;">new</span> SQL Server name <span style="color: #0000ff;">for</span> APM tables</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum161" style="color: #606060;"> 161:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum162" style="color: #606060;"> 162:</span> # Translate table name which has <span style="color: #006080;">"$"</span> <span style="color: #0000ff;">in</span> name</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum163" style="color: #606060;"> 163:</span> $MT_MSFTSysCntrOpsMgrDBAppMonTbl = <span style="color: #006080;">"dbo.MT_Microsoft`$SystemCenter`$OpsMgrDB`$AppMonitoring"</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum164" style="color: #606060;"> 164:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum165" style="color: #606060;"> 165:</span> # Update Opertional Database server name</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum166" style="color: #606060;"> 166:</span> write-host <span style="color: #006080;">"Updating database OperationsManager, SQL table $MT_MSFTSysCntrOpsMgrDBAppMonTbl, column MainDatabaseServerName_5C00C79B_6B71_6EEE_4ADE_80C11F84527A on SQL Server $NewSQLOpsMgrDBSrv..."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum167" style="color: #606060;"> 167:</span> invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"UPDATE $MT_MSFTSysCntrOpsMgrDBAppMonTbl SET MainDatabaseServerName_5C00C79B_6B71_6EEE_4ADE_80C11F84527A = '$NewSQLOpsMgrDBSrv'"</span> -ServerInstance $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum168" style="color: #606060;"> 168:</span> write-host <span style="color: #006080;">"Completed updating database OperationsManager, SQL table $MT_MSFTSysCntrOpsMgrDBAppMonTbl, column MainDatabaseServerName_5C00C79B_6B71_6EEE_4ADE_80C11F84527A on SQL Server $NewSQLOpsMgrDBSrv."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum169" style="color: #606060;"> 169:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum170" style="color: #606060;"> 170:</span> write-host <span style="color: #006080;">"Updating database OperationsManager, SQL table $MT_MSFTSysCntrDWTbl, column MainDatabaseServerName_2C77AA48_DB0A_5D69_F8FF_20E48F3AED0F on SQL Server $NewSQLOpsMgrDBSrv..."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum171" style="color: #606060;"> 171:</span> invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"UPDATE $MT_MSFTSysCntrDWTbl SET MainDatabaseServerName_2C77AA48_DB0A_5D69_F8FF_20E48F3AED0F = '$NewSQLOpsMgrDBSrv'"</span> -ServerInstance $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum172" style="color: #606060;"> 172:</span> write-host <span style="color: #006080;">"Completed updating database OperationsManager, SQL table $MT_MSFTSysCntrDWTbl, column MainDatabaseServerName_2C77AA48_DB0A_5D69_F8FF_20E48F3AED0F on SQL Server $NewSQLOpsMgrDBSrv."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum173" style="color: #606060;"> 173:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum174" style="color: #606060;"> 174:</span> write-host <span style="color: #006080;">"Updating database OperationsManager, SQL table $MT_MSFTSysCntrDWAppMonTbl, column MainDatabaseServerName_5C00C79B_6B71_6EEE_4ADE_80C11F84527A on SQL Server $NewSQLOpsMgrDBSrv..."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum175" style="color: #606060;"> 175:</span> invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"UPDATE $MT_MSFTSysCntrDWAppMonTbl SET MainDatabaseServerName_5C00C79B_6B71_6EEE_4ADE_80C11F84527A = '$NewSQLOpsMgrDBSrv'"</span> -ServerInstance $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum176" style="color: #606060;"> 176:</span> write-host <span style="color: #006080;">"Completed updating database OperationsManager, SQL table $MT_MSFTSysCntrDWAppMonTbl, column MainDatabaseServerName_5C00C79B_6B71_6EEE_4ADE_80C11F84527A on SQL Server $NewSQLOpsMgrDBSrv."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum177" style="color: #606060;"> 177:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum178" style="color: #606060;"> 178:</span> write-host <span style="color: #006080;">"Updating database OperationsManagerDW, SQL table dbo.MemberDatabase, column ServerName on SQL Server $NewSQLOpsMgrDWSrv..."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum179" style="color: #606060;"> 179:</span> invoke-sqlcmd -Database OperationsManagerDW -Query <span style="color: #006080;">"UPDATE dbo.MemberDatabase SET ServerName = '$NewSQLOpsMgrDBSrv'"</span> -ServerInstance $NewSQLOpsMgrDWSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum180" style="color: #606060;"> 180:</span> write-host <span style="color: #006080;">"Completed updating database OperationsManagerDW, SQL table dbo.MemberDatabase, column ServerName on SQL Server $NewSQLOpsMgrDWSrv."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum181" style="color: #606060;"> 181:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum182" style="color: #606060;"> 182:</span> # Step 14 - Execute SQL commands on <span style="color: #0000ff;">new</span> Operations database</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum183" style="color: #606060;"> 183:</span> write-host <span style="color: #006080;">"Executing sp_configure and reconfigure on database OperationsManager on SQL Server $NewSQLOpsMgrDWSrv..."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum184" style="color: #606060;"> 184:</span> invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"sp_configure 'show advanced options', 0"</span> -ServerInstance $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum185" style="color: #606060;"> 185:</span> invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"reconfigure"</span> -ServerInstance $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum186" style="color: #606060;"> 186:</span> invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"sp_configure 'clr enabled',1"</span> -ServerInstance $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum187" style="color: #606060;"> 187:</span> invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"reconfigure"</span> -ServerInstance $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum188" style="color: #606060;"> 188:</span> write-host <span style="color: #006080;">"Completed executing sp_configure and reconfigure on database OperationsManager on SQL Server $NewSQLOpsMgrDWSrv."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum189" style="color: #606060;"> 189:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum190" style="color: #606060;"> 190:</span> # Step 15 &amp; 16 - Check <span style="color: #0000ff;">if</span> OperationsManager DB broker <span style="color: #0000ff;">is</span> enabled</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum191" style="color: #606060;"> 191:</span> write-host <span style="color: #006080;">"Checking to see if the DB broker is enabled on database OperationsManager on SQL Server $NewSQLOpsMgrDWSrv..."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum192" style="color: #606060;"> 192:</span> $BrokerEnabled = invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"SELECT is_broker_enabled FROM sys.databases WHERE name='OperationsManager'"</span> -ServerInstance $NewSQLOpsMgrDBSrvA</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum193" style="color: #606060;"> 193:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum194" style="color: #606060;"> 194:</span> If (!$BrokerEnabled.is_broker_enabled)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum195" style="color: #606060;"> 195:</span>     {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum196" style="color: #606060;"> 196:</span>         # Step 16 - Alter Operations Manager DB</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum197" style="color: #606060;"> 197:</span>         write-host <span style="color: #006080;">"The DB broker is not enabled on database OperationsManager on SQL Server $NewSQLOpsMgrDWSrv."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum198" style="color: #606060;"> 198:</span>         write-host <span style="color: #006080;">"Altering database OperationsManager on SQL Server $NewSQLOpsMgrDWSrv to enable the DB broker..."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum199" style="color: #606060;"> 199:</span>         invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"ALTER DATABASE OperationsManager SET SINGLE_USER WITH ROLLBACK IMMEDIATE"</span> -ServerInstance $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum200" style="color: #606060;"> 200:</span>         invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"ALTER DATABASE OperationsManager SET ENABLE_BROKER"</span> -ServerInstance $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum201" style="color: #606060;"> 201:</span>         invoke-sqlcmd -Database OperationsManager -Query <span style="color: #006080;">"ALTER DATABASE OperationsManager SET MULTI_USER"</span> -ServerInstance $NewSQLOpsMgrDBSrv</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum202" style="color: #606060;"> 202:</span>         write-host <span style="color: #006080;">"Completed altering database OperationsManager on SQL Server $NewSQLOpsMgrDWSrv to enable the DB broker."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum203" style="color: #606060;"> 203:</span>     }</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum204" style="color: #606060;"> 204:</span> Else</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum205" style="color: #606060;"> 205:</span>     {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum206" style="color: #606060;"> 206:</span>         write-host <span style="color: #006080;">"DB broker for database OperationsManager is enabled. No DB altering needed."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum207" style="color: #606060;"> 207:</span>     }</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum208" style="color: #606060;"> 208:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum209" style="color: #606060;"> 209:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum210" style="color: #606060;"> 210:</span> # Step 17 - Start the Operations Manager services</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum211" style="color: #606060;"> 211:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum212" style="color: #606060;"> 212:</span> Invoke-Command -ComputerName $MgmtServers -ScriptBlock {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum213" style="color: #606060;"> 213:</span>     $OpsMgr12MgmtSrvSvcArray = @(<span style="color: #006080;">"System Center Data Access Service"</span>, <span style="color: #006080;">"System Center Management"</span>, <span style="color: #006080;">"System Center Management Configuration"</span>)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum214" style="color: #606060;"> 214:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum215" style="color: #606060;"> 215:</span>     ForEach ($svc <span style="color: #0000ff;">in</span> $OpsMgr12MgmtSrvSvcArray)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum216" style="color: #606060;"> 216:</span>         {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum217" style="color: #606060;"> 217:</span>             write-host <span style="color: #006080;">"Starting service $svc on $Env:ComputerName..."</span></pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum218" style="color: #606060;"> 218:</span>             $SCOpsMgrSvc = Get-Service | ? { $_.DisplayName -eq $svc}</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum219" style="color: #606060;"> 219:</span>             If ($SCOpsMgrSvc.Status -ne <span style="color: #006080;">"Running"</span>)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum220" style="color: #606060;"> 220:</span>                 {</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum221" style="color: #606060;"> 221:</span>                     Start-Service -DisplayName $svc</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum222" style="color: #606060;"> 222:</span>                     Do</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum223" style="color: #606060;"> 223:</span>                         { </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum224" style="color: #606060;"> 224:</span>                             Start-Sleep -s 15</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum225" style="color: #606060;"> 225:</span>                             $SCOpsMgrSvc = Get-Service | ? { $_.DisplayName -eq $svc}</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum226" style="color: #606060;"> 226:</span>                         } Until ($SCOpsMgrSvc.Status -eq <span style="color: #006080;">"Running"</span>)</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum227" style="color: #606060;"> 227:</span>                 }</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum228" style="color: #606060;"> 228:</span>             write-host <span style="color: #006080;">"The service $svc is started on $Env:ComputerName."</span>             </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum229" style="color: #606060;"> 229:</span>         </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum230" style="color: #606060;"> 230:</span>         }</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum231" style="color: #606060;"> 231:</span>  } # End Invoke-Command <span style="color: #0000ff;">for</span> starting Management Server services</pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum232" style="color: #606060;"> 232:</span>&nbsp; </pre>
<!--CRLF-->
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span id="lnum233" style="color: #606060;"> 233:</span>  write-host <span style="color: #006080;">"Script Complete."</span></pre>
<!--CRLF--></div>
</div>
<p>One thing that is not automated in this script is the reconfiguration of the Operations Manager Report Server SQL Reporting Services configuration. If the SSRS ReportServer and ReportServerTemp is being moved as well to a different SQL Server, you will have to manually go into the SQL Reporting Services Configuration Manager and attach that instance of SSRS to the correct SQL Server.</p>
<p>This is a version 1.0 development effort provided to the community. If you have any additions to include and/or questions feel free to email me.</p>
<p>&nbsp;</p>
<p>Thanks,</p>
<p>Phil Gibson</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/01/8467/00/00/03/52/84/89/OpsMgr2012-AutoMoveDBs.ps1" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/telligent-evolution-components-attachments/01-8467-00-00-03-52-84-89/OpsMgr2012_2D00_AutoMoveDBs.ps1">OpsMgr2012-AutoMoveDBs.ps1</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Installing System Center Operations Manager 2012 in Offline Mode (No Internet Connection) and receiving Exception Error Code: 0x80131509, Exception.Message: Cannot start service OMSDK on computer</title>
      <link>https://docs.microsoft.com/archive/blogs/phillipgibson/installing-system-center-operations-manager-2012-in-offline-mode-no-internet-connection-and-receiving-exception-error-code-0x80131509-exception-message-cannot-start-service-omsdk-on-computer</link>
      <pubDate>Wed, 24 Oct 2012 09:47:00 GMT</pubDate>
      <dc:creator><![CDATA[Phil Gibson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/phillipgibson/2012/10/24/installing-system-center-operations-manager-2012-in-offline-mode-no-internet-connection-and-receiving-exception-error-code-0x80131509-exception-message-cannot-start-service-omsdk-on-computer/</guid>
      <description><![CDATA[&#160;  Recently I’ve been doing a lot of work in highly secure environments containing extremely...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>Recently I’ve been doing a lot of work in highly secure environments containing extremely hardened GPOs and isolated networks. As I was working with a customer to deploy System Center Operations Manager 2012 to monitor some highly critical machines, I noticed that the installation was giving us an error and would not complete. </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/1067.SCOMInstall9_1C63D2F3.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/1067.SCOMInstall9_5F00_1C63D2F3.jpg"><img title="SCOM-Install-9" style="display: inline;" border="0" alt="SCOM-Install-9" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/5277.SCOMInstall9_thumb_22AAA981.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/5277.SCOMInstall9_5F00_thumb_5F00_22AAA981.jpg" width="495" height="371" /></a> </p>  <p>&#160;</p>  <p>After further investigation I looked into the OpsMgrSetupWizard.log and noticed the following lines:</p>  <p>&#160;</p>  <p><strong>Debug:&#160;&#160;&#160; :StartService: attempting to start service OMSDK      <br />Error:&#160;&#160;&#160;&#160;&#160;&#160; :StartService: Could not get service status.: Threw Exception.Type: System.InvalidOperationException, Exception Error Code: 0x80131509, Exception.Message: Cannot start service OMSDK on computer '.'.</strong></p>  <p>and</p>  <p><strong>Info:trying to connect with server &lt;Your Server&gt;</strong><strong>      <br />Info:Error while connecting to management server: The Data Access service is either not running or not yet initialized.&#160;&#160;&#160; </strong></p>  <p><strong></strong></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/1376.SCOMInstall10_5AE92099.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/1376.SCOMInstall10_5F00_5AE92099.jpg"><img title="SCOM-Install-10" style="display: inline;" border="0" alt="SCOM-Install-10" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/1070.SCOMInstall10_thumb_4114EA6A.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/1070.SCOMInstall10_5F00_thumb_5F00_4114EA6A.jpg" width="514" height="179" /></a> </p>  <p><strong></strong></p>  <p>After some additional further investigation of the errors I came across KB2730040 ( <a title="https://support.microsoft.com/kb/2730040" href="https://support.microsoft.com/kb/2730040">https://support.microsoft.com/kb/2730040</a> ) that spoke about the System Center Data Access service (OMSDK) failing to start with a TimeOut error due to applying the KB2677070 patch to the server. I double checked the server to see if the patch had indeed been installed, but it was not listed and I wasn’t sure if it had been superseded in another patch. In the more information section of KB2730040 it spoke about URLs being changed to contact Windows Update to download trusted and untrusted CTLs. Knowing that I was in a isolated network, I went ahead and disabled the CRL checking as described in the KB and it resolved the issue. There’s some timing that has to take place to get through this smoothly so I documented my steps to get a successful installation of System Center Operations Manager 2012 in a completely offline and/or isolated network environment that doesn’t have access to the internet.</p>  <p>&#160;</p>  <p><strong>NOTE: Since I already had a failed installation I was able to copy the Microsoft.Mom.Sdk.ServiceHost.exe.config file and make the required edits, discussed in KB2730040, to it for use for my next installation. If this will be a fresh install for you, I’ve attached the modified version of the file to use. This file is not installation or machine specific, so you should not have any issues utilizing my file for your installations.</strong></p>  <p><strong></strong></p>  <p>&#160;</p>  <p><strong>Step 1:</strong> Start your installation as normal</p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/2047.SCOMInstall12_4B660ECA.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/2047.SCOMInstall12_5F00_4B660ECA.jpg"><img title="SCOM-Install-1-2" style="display: inline;" border="0" alt="SCOM-Install-1-2" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/2538.SCOMInstall12_thumb_51ACE558.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/2538.SCOMInstall12_5F00_thumb_5F00_51ACE558.jpg" width="485" height="365" /></a> </p>  <p>&#160;</p>  <p><strong>Step 2: </strong>At the point when the installation gets to the Management server task, either copy the edited version of&#160; Microsoft.Mom.Sdk.ServiceHost.exe.config to your clipboard or be prepared to open the file and make the edits during the installation.</p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/8715.SCOMInstall22_110A98E9.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/8715.SCOMInstall22_5F00_110A98E9.jpg"><img title="SCOM-Install-2-2" style="display: inline;" border="0" alt="SCOM-Install-2-2" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/6747.SCOMInstall22_thumb_7E559F31.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/6747.SCOMInstall22_5F00_thumb_5F00_7E559F31.jpg" width="491" height="365" /></a></p>  <p>&#160;</p>  <p><strong>Step 3: </strong>Open the path to the Microsoft.Mom.Sdk.ServiceHost.exe.config. In my test lab installation this was C:\Programs Files\System Center 2012\Operations Manager\Server. If you have taken the default path during installation the only difference should be your drive letter. Make sure that you allow the installation to create this file first so that you can overwrite it with the modified version.</p>  <p>&#160;</p>  <p><strong>Step 4:</strong>&#160; Overwrite the Microsoft.Mom.Sdk.ServiceHost.exe.config or edit it like the following examples:</p>  <blockquote>   <p><strong>Overwrite</strong></p>    <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/4113.SCOMInstall14_56AF2307.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/4113.SCOMInstall14_5F00_56AF2307.jpg"><img title="SCOM-Install-14" style="display: inline;" border="0" alt="SCOM-Install-14" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/1055.SCOMInstall14_thumb_3CDAECD8.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/1055.SCOMInstall14_5F00_thumb_5F00_3CDAECD8.jpg" width="425" height="421" /></a> </p> </blockquote>  <p>&#160;</p>  <blockquote>   <p><strong>Edit Microsoft.Mom.Sdk.ServiceHost.exe.config</strong> </p>    <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/2538.SCOMInstall11_0E153436.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/2538.SCOMInstall11_5F00_0E153436.jpg"><img title="SCOM-Install-11" style="display: inline;" border="0" alt="SCOM-Install-11" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/6266.SCOMInstall11_thumb_13EFD7CF.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/6266.SCOMInstall11_5F00_thumb_5F00_13EFD7CF.jpg" width="422" height="286" /></a> </p>    <p>&#160;</p> </blockquote>  <blockquote>   <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/8715.SCOMInstall12_013ADE18.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/8715.SCOMInstall12_5F00_013ADE18.jpg"><img title="SCOM-Install-12" style="display: inline;" border="0" alt="SCOM-Install-12" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/1462.SCOMInstall12_thumb_31EDE5C3.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/1462.SCOMInstall12_5F00_thumb_5F00_31EDE5C3.jpg" width="421" height="287" /></a> </p> </blockquote>  <p>&#160;</p>  <p><strong>Step 5: </strong>You should now be able to observe the OpsMgrSetupWizard.log file showing the OMSDK service started</p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/6232.SCOMInstall15_1F38EC0C.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/6232.SCOMInstall15_5F00_1F38EC0C.jpg"><img title="SCOM-Install-15" style="display: inline;" border="0" alt="SCOM-Install-15" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/4682.SCOMInstall15_thumb_505826AC.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/4682.SCOMInstall15_5F00_thumb_5F00_505826AC.jpg" width="526" height="289" /></a> </p>  <p>&#160;</p>  <p>You should now have a successful installation of System Center Operations Manager 2012 in a offline environment that does not connect to the internet.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/8473.SCOMInstall16_687B9107.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/8473.SCOMInstall16_5F00_687B9107.jpg"><img title="SCOM-Install-16" style="display: inline;" border="0" alt="SCOM-Install-16" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/1121.SCOMInstall16_thumb_6EC26795.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/1121.SCOMInstall16_5F00_thumb_5F00_6EC26795.jpg" width="532" height="400" /></a></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/01/8467/00/00/03/52/84/29/Microsoft.Mom.Sdk.ServiceHost.exe.config" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/telligent-evolution-components-attachments/01-8467-00-00-03-52-84-29/Microsoft.Mom.Sdk.ServiceHost.exe.config">Microsoft.Mom.Sdk.ServiceHost.exe.config</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Using System Center 2012 for Host Cluster Remediation (Patching) and Host Cluster VM Rebalancing for Private Cloud – Part 2 of Many (VM Rebalancing)</title>
      <link>https://docs.microsoft.com/archive/blogs/phillipgibson/using-system-center-2012-for-host-cluster-remediation-patching-and-host-cluster-vm-rebalancing-for-private-cloud-part-2-of-many-vm-rebalancing</link>
      <pubDate>Fri, 11 May 2012 14:31:00 GMT</pubDate>
      <dc:creator><![CDATA[Phil Gibson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/phillipgibson/2012/05/11/using-system-center-2012-for-host-cluster-remediation-patching-and-host-cluster-vm-rebalancing-for-private-cloud-part-2-of-many-vm-rebalancing/</guid>
      <description><![CDATA[&nbsp;
&nbsp;
This is Part 2 in my series &ldquo;Using System Center 2012 for Host Cluster...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p>
<p>&nbsp;</p>
<p>This is Part 2 in my series &ldquo;Using System Center 2012 for Host Cluster Remediation (Patching) and Host Cluster VM Rebalancing&rdquo;, and this post will focus on rebalancing your VMs to their original host after you have done a Host Remediation to your Microsoft Private Cloud infrastructure using System Center Virtual Machine Manager 2012. Again this solution involves using System Center products Virtual Machine Manager 2012, System Center Operations Manager 2012, and System Center Orchestrator 2012. The script in this post, just as in Part 1, are intended to run in a System Center Orchestrator 2012 runbook, but you can alter the script to run it in your environment without Orchestrator, but you will need System Center Virtual Machine Manager 2012.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h4>Prerequisites</h4>
<p>The following script assumes that you have utilized the SCVMMClusterRemediation.ps1 Windows PowerShell script from the Part 1 post of this series to automate your Microsoft Private Cloud Host Remediation. If you have not utilized that script, or a variation of that script, to populate the Custom Fields of your VM with the VM Host name then this script will not be able to rebalance the VMs back to running on their original VM Host they were prior to the System Center Virtual Machine Manager 2012 Host Remediation job. To prepare your Microsoft Private Cloud VMs to utilize the following script please see the Part 1 post in this series at <a title="https://blogs.technet.com/b/phillipgibson/archive/2012/05/09/using-system-center-2012-for-host-cluster-remediation-patching-and-host-cluster-vm-rebalancing-part-1-of-many.aspx" href="https://blogs.technet.com/b/phillipgibson/archive/2012/05/09/using-system-center-2012-for-host-cluster-remediation-patching-and-host-cluster-vm-rebalancing-part-1-of-many.aspx">https://blogs.technet.com/b/phillipgibson/archive/2012/05/09/using-system-center-2012-for-host-cluster-remediation-patching-and-host-cluster-vm-rebalancing-part-1-of-many.aspx</a>.</p>
<p>&nbsp;</p>
<h4>The VM Rebalancing Script Breakdown</h4>
<p>Below is the VM rebalancing script that you can run against your Microsoft Private Cloud Hyper-V host clusters in your System Center Virtual Machine Manager 2012 environment after the VMs have been tagged with their VM Host server in their Custom Field 1 property. Prior to running this script you should check the properties of your VMs to ensure they have their original VM Host name populated in the Custom1 field they were running on prior to the host cluster remediation. The properties of the VM should look similar to the picture below.&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/7607.image_7F048293.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/7607.image_5F00_7F048293.png"><img width="718" height="445" title="image" style="display: inline; background-image: none;" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/2705.image_thumb_63134D9B.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/2705.image_5F00_thumb_5F00_63134D9B.png" border="0" />&nbsp;</a></p>
<p>Unlike the Windows PowerShell script in Part 1 of the series (SCVMMClusterRemediation.ps1) the SCVMMClusterVMRebalance.ps1 is much less involved and doing less so I will not document it so thoroughly as I&rsquo;ve done for the previous script. Overall this script is just running against the VM Host Clusters you filter on, enumerating all VMs on each node of the Host Cluster, and running the SCVMM PowerShell cmdlet Move-SCVirtualMachine to the Host Cluster node listed in the Custom1 field of the VM. That activity is specifically happening from <strong>Lines 68-90 </strong>and when this script runs you should see SCVMM job activity similar to the picture below. I&rsquo;ve removed private data out of the picture such as the VM name and the Host Cluster Nodes.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/1185.VM-Move-Job---Edited_79804A31.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/1185.VM_2D00_Move_2D00_Job_2D002D002D00_Edited_5F00_79804A31.jpg"><img width="730" height="397" title="VM Move Job - Edited" style="display: inline; background-image: none;" alt="VM Move Job - Edited" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/2744.VM-Move-Job---Edited_thumb_26556173.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/2744.VM_2D00_Move_2D00_Job_2D002D002D00_Edited_5F00_thumb_5F00_26556173.jpg" border="0" /></a></p>
<p>Another key thing the script is doing is writing the Move-SCVirtualMachine SCVMM Job GUID to the event log (<strong>Line 85</strong>). Again, that SCVMM Job GUID will be used in the total solution to monitor the result of the SCVMM Job, with a runbook that get initiated when that event is written.</p>
<p>The next post in this series (Part 3) will focus on automating these scripts utilizing System Center Orchestrator 2012 runbooks. The runbooks will detail how the solution is scheduled, how the SCVMM Job GUIDs are captured for monitoring, and how I use the VM Host time zone properties to ensure that Host Clusters are patched during a specific time local to the Host Cluster.</p>
<p>&nbsp;</p>
<p>As always feel free to post your comments or questions. You can also email me too.</p>
<p>Phil Gibson | Senior Consultant | Microsoft | System Center &amp; Private Cloud Infrastructure &amp; Development</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:453a8b69-dd74-4654-bd06-79e62bf2dc7f" style="margin: 0px; padding: 0px; float: none; display: inline;">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;">SCVMMClusterVMRebalance.ps1</div>
<div style="background: #ddd; max-height: 500px; overflow: auto;"><ol style="background: #ffffff; margin: 0 0 0 3em; padding: 0 0 0 5px; white-space: nowrap;" start="1">
<li><span style="color: #006400;">&lt;#</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;<span style="color: #006400;">Purpose&nbsp;&nbsp;: Rebalance VMs on Hyper-V Clusters using SCVMM 2012</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;"></span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;<span style="color: #006400;">Author&nbsp;&nbsp;&nbsp;: <a href="mailto:pgibson.online@hotmail.com">pgibson.online@hotmail.com</a> [MSFT]</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;"><span style="color: #006400;"> Disclaimer: THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, </span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED </span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;"><span style="color: #006400;">#&gt;</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;"><span style="color: #006400;">#######&nbsp;&nbsp;Functions ###############</span></li>
<li><span style="color: #00008b;">Function</span> <span style="color: #8a2be2;">global:WriteEvent</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">&lt;#</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">Purpose&nbsp;&nbsp;: Write events into the eventlog of the executing machine.</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">Setup&nbsp;&nbsp;&nbsp;&nbsp;: Please edit the $EventSoure variable to the EventLog source you want your script to utilize as default. Ex. $EventSource = "MyLogSource"</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">Example 1: WriteEvent -EventSource "TEST" -EventID 101 -EventType "Warning" -EventMessage "This is really a test."</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">Example 2: WriteEvent -Source "TEST" -ID 101 -Type "Warning" -Message "This is really a test."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">**NOTE** : This function will default the EventLog source you supplied with a "Information" event to the "Application" log if the parameters are not used/overridden</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">Author&nbsp;&nbsp;&nbsp;: pgibson.online@live.com [MSFT]</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">#&gt;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">param</span> (</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$false</span><span style="color: #a9a9a9;">,</span>Helpmessage<span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"Please enter the source of the Eventlog entry. Example: -Source ""MyLogSource"""</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">alias</span>(<span style="color: #8b0000;">"Source"</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[string]</span><span style="color: #ff4500;">$EventSource</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"SCVMMHostRemediation"</span><span style="color: #a9a9a9;">,</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span>Helpmessage<span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"Please enter the event ID of the Eventlog entry. Example: -ID 101"</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">alias</span>(<span style="color: #8b0000;">"ID"</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[int]</span><span style="color: #ff4500;">$EventID</span><span style="color: #a9a9a9;">,</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$false</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">alias</span>(<span style="color: #8b0000;">"Type"</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">ValidateSet</span>(<span style="color: #8b0000;">"Error"</span><span style="color: #a9a9a9;">,</span> <span style="color: #8b0000;">"Information"</span><span style="color: #a9a9a9;">,</span> <span style="color: #8b0000;">"Warning"</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[string]</span><span style="color: #ff4500;">$EventType</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"Information"</span><span style="color: #a9a9a9;">,</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span>Helpmessage<span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"Please enter the event description of the Eventlog entry. Example: -Message ""This is a test."""</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">alias</span>(<span style="color: #8b0000;">"Message"</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[string]</span><span style="color: #ff4500;">$EventMessage</span><span style="color: #a9a9a9;">,</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$false</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">alias</span>(<span style="color: #8b0000;">"Log"</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">ValidateSet</span>(<span style="color: #8b0000;">"Application"</span><span style="color: #a9a9a9;">,</span> <span style="color: #8b0000;">"Security"</span><span style="color: #a9a9a9;">,</span> <span style="color: #8b0000;">"System"</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[string]</span><span style="color: #ff4500;">$EventLog</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"Application"</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;"># Create event source if it does not exist</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">If</span> (<span style="color: #a9a9a9;">!</span><span style="color: #008080;">[System.Diagnostics.EventLog]</span><span style="color: #a9a9a9;">::</span>SourceExists(<span style="color: #ff4500;">$EventSource</span>))</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008080;">[System.Diagnostics.EventLog]</span><span style="color: #a9a9a9;">::</span>CreateEventSource(<span style="color: #ff4500;">$EventSource</span><span style="color: #a9a9a9;">,</span> <span style="color: #ff4500;">$EventLog</span>)</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">write-eventlog</span> <span style="color: #000080;">-logname</span> <span style="color: #ff4500;">$EventLog</span> <span style="color: #000080;">-Source</span> <span style="color: #ff4500;">$EventSource</span> <span style="color: #000080;">-eventid</span> <span style="color: #ff4500;">$EventID</span> <span style="color: #000080;">-entrytype</span> <span style="color: #ff4500;">$EventType</span> <span style="color: #000080;">-message</span> <span style="color: #ff4500;">$EventMessage</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">Else</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">write-eventlog</span> <span style="color: #000080;">-logname</span> <span style="color: #ff4500;">$EventLog</span> <span style="color: #000080;">-Source</span> <span style="color: #ff4500;">$EventSource</span> <span style="color: #000080;">-eventid</span> <span style="color: #ff4500;">$EventID</span> <span style="color: #000080;">-entrytype</span> <span style="color: #ff4500;">$EventType</span> <span style="color: #000080;">-message</span> <span style="color: #ff4500;">$EventMessage</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li><span style="color: #006400;">#######&nbsp;&nbsp;End Functions #############</span></li>
<li style="background: #f3f3f3;">&nbsp;</li>
<li><span style="color: #006400;">######## Start Main ###########</span></li>
<li style="background: #f3f3f3;"><span style="color: #ff4500;">$ErrorActionPreference</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"Stop"</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;"><span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Start VM Cluster Rebalancing Process."</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;"><span style="color: #00008b;">Try</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$HostClusters</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCVMHostCluster</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span> { (<span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span>ClusterName <span style="color: #a9a9a9;">-eq</span> <span style="color: #8b0000;">"HVCLSRV01"</span>)}</li>
<li style="background: #f3f3f3;">&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">ForEach</span> (<span style="color: #ff4500;">$HostCluster</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$HostClusters</span>)</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Processing Host Cluster $HostCluster."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$Cluster</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCVMHostCluster</span> <span style="color: #000080;">-Name</span> <span style="color: #ff4500;">$HostCluster</span><span style="color: #a9a9a9;">.</span>ToString()</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">#Get all Nodes in Cluster</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$HostClusterNodes</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$HostCluster</span><span style="color: #a9a9a9;">.</span>Nodes</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">ForEach</span> (<span style="color: #ff4500;">$Node</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$HostClusterNodes</span>)</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$VMHost</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCVMHost</span> <span style="color: #000080;">-ComputerName</span> <span style="color: #ff4500;">$Node</span> <span style="color: #000080;">-VMHostCluster</span> <span style="color: #ff4500;">$Cluster</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Processing Node $VMHost of Host Cluster $HostCluster."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">##### - Start VM to VMHost Rebalancing Sequence - ###### # This will move the VM to the VMHost listed in the Custom1 field property of the VM.</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">ForEach</span> (<span style="color: #ff4500;">$VM</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$VMHost</span><span style="color: #a9a9a9;">.</span>VMs)</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Processing VM $VM on Node $VMHost of Host Cluster $HostCluster."</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">#Generate Remediation JobGroup SCJob GUID</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$JobGroupGUID</span> <span style="color: #a9a9a9;">=</span> <span style="color: #008080;">[System.Guid]</span><span style="color: #a9a9a9;">::</span>NewGuid()</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"The SCVMM VM Move Job GUID for VM $VM on Node $VMHost of Host Cluster $HostCluster is $JobGroupGUID."</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$VMCustomProperty1</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCCustomProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8b0000;">"Custom1"</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$VMCustomProperty1Value</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCCustomPropertyValue</span> <span style="color: #000080;">-InputObject</span> <span style="color: #ff4500;">$VM</span> <span style="color: #000080;">-CustomProperty</span> <span style="color: #ff4500;">$VMCustomProperty1</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Checking the Custom Field 1 VM Host Value for VM $VM on Node $VMHost of Host Cluster $HostCluster."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">If</span> (<span style="color: #ff4500;">$VMHost</span><span style="color: #a9a9a9;">.</span>Name <span style="color: #a9a9a9;">-ne</span> <span style="color: #ff4500;">$VMCustomProperty1Value</span><span style="color: #a9a9a9;">.</span>Value<span style="color: #a9a9a9;">.</span>ToString())</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Moving VM $VM on Node $VMHost of Host Cluster $HostCluster to $VMCustomProperty1Value.Value."</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$NewVMHost</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-VMHost</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span> {<span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span>Name <span style="color: #a9a9a9;">-eq</span> <span style="color: #ff4500;">$VMCustomProperty1Value</span><span style="color: #a9a9a9;">.</span>Value<span style="color: #a9a9a9;">.</span>ToString()}</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">Move-SCVirtualMachine</span> <span style="color: #000080;">-VM</span> <span style="color: #ff4500;">$VM</span> <span style="color: #000080;">-VMHost</span> <span style="color: #ff4500;">$NewVMHost</span> <span style="color: #000080;">-HighlyAvailable</span> <span style="color: #ff4500;">$true</span> <span style="color: #000080;">-RunAsynchronously</span> <span style="color: #000080;">-JobGroup</span> <span style="color: #ff4500;">$JobGroupGUID</span><span style="color: #a9a9a9;">.</span>ToString()</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">101</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #ff4500;">$JobGroupGUID</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">#Clear JobGroupGUID variable</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">Clear-Variable</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">JobGroupGUID</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">##### - End VM to VMHost Rebalancing Sequence - ######</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;"><span style="color: #00008b;">Catch</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">Throw</span> <span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span>Exception</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">200</span> <span style="color: #000080;">-Type</span> <span style="color: #8b0000;">"Error"</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"VM Cluster Rebalancing Process Failed. Error message: $_.Exception.Message"</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li><span style="color: #00008b;">Finally</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Completed VM Cluster Rebalancing Process."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;}</li>
</ol></div>
</div>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Using System Center 2012 for Host Cluster Remediation (Patching) and Host Cluster VM Rebalancing for Private Cloud – Part 1 of Many (Host Remediation)</title>
      <link>https://docs.microsoft.com/archive/blogs/phillipgibson/using-system-center-2012-for-host-cluster-remediation-patching-and-host-cluster-vm-rebalancing-for-private-cloud-part-1-of-many-host-remediation</link>
      <pubDate>Fri, 11 May 2012 14:30:00 GMT</pubDate>
      <dc:creator><![CDATA[Phil Gibson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/phillipgibson/2012/05/11/using-system-center-2012-for-host-cluster-remediation-patching-and-host-cluster-vm-rebalancing-for-private-cloud-part-1-of-many-host-remediation/</guid>
      <description><![CDATA[So I&rsquo;ve been working on Microsoft Private Cloud implementations for various customers. One of...]]></description>
      <content:encoded><![CDATA[<p>So I&rsquo;ve been working on Microsoft Private Cloud implementations for various customers. One of the common themes I run into deals with patching the fabric of the Private Cloud, meaning the actual virtual machine hosts. Using System Center 2012 Virtual Machine Manager you can easily orchestrate host remediation with built in functionality. This means that Virtual Machine Manager 2012 has an automated process to move virtual machines from each VM Host node being patched, installing the updates, and rebooting the VM Host machine. One scenario that I&rsquo;m finding customers are looking for is keeping thier virtual machines on the actual VM Host it was prior to the host cluster remediation. Even thought Virtual Machine Manager will automate this sequence, often virtual machines are left on a single VM Host node in the cluster or on a different VM Host from when the host remediation started. In this first post of the series I will detail a solution that will automate host cluster remediation and prepare the virtual machines to be rebalanced to their VM Hosts they were running on prior to the System Center Virtual Machine Manager 2012 remediation job. The solution also takes in account using the local time zone of the VM host machines. This is used for environments using System Center Virtual Machine Manager 2012 that manage clusters in different time zones, but need host remediation to happen at a specific time local to the host cluster. You will see in later posts how I use System Center Orchestrator 2012 to determine the time zones of each host cluster and only remediate host clusters belonging to a particular time zone at a specified time. A few other things the script takes in account is ensuring the host clusters are assigned to an update baseline, has a compliance scan status, and that all of the guest virtual machine hosted in the cluster do not have DVD drives mounted with a local path. All of those situations mentioned can prohibit host remediation from being successful. I will provide guidance on all the Windows PowerShell scripts and System Center Orchestrator runbooks I developed to automate this process. The full automated end-to-end solution utilizes System Center products Virtual Machine Manager 2012, Operations Manager 2012, and Orchestrator 2012. Let&rsquo;s begin managing your Microsoft Private Cloud.</p>
<p>&nbsp;</p>
<h2>Prerequisites</h2>
<p>The following script assumes that you have already configured your System Center Virtual Machine Manager 2012 server with an Update Server. If you have not done this, please follow the guidance on managing fabric updates for System Center Virtual Machine Manager 2012 <a title="https://technet.microsoft.com/en-us/library/gg675084.aspx" href="https://technet.microsoft.com/en-us/library/gg675084.aspx">https://technet.microsoft.com/en-us/library/gg675084.aspx</a>.</p>
<p>&nbsp;</p>
<h2>The Remediation Script Breakdown</h2>
<p>Below is the remediation script that you can run against your Hyper-V host clusters in your System Center Virtual Machine Manager 2012 environment. One thing to note is that this script is intended to run as a runbook in System Center Orchestrator 2012 using the SCVMM 2012 Integration Pack. When using the run SCVMM script object you do not need to import the VirtualMachineManager module for Virtual Machine Manager 2012 because the object configuration does this for you. If you do want to utilized this script outside of Orchestrator 2012 you will have to add the Import-Module VirtualMachineManager to the script. The script itself is somewhat busy, but it will automate all the key activities needed to make the process 100% completely automated using System Center Orchestrator 2012. I will detail out the major parts in the script so that you can feel comfortable and confident using it in your Microsoft Private Cloud environments. Because the script is well documented, I will only explain the major parts. The script will also be available to download as a zip file.</p>
<p>&nbsp;</p>
<p><span style="font-weight: bold;">Lines 12 &ndash; 97&nbsp; - </span>The script contains four globally declared functions WriteEvent, VMHostTimeZone, VMHostComplianceStatus, and UpdateRemediationBaseline. The functions are well documented and I will discuss them in more detail when the script uses them. For a quick description of the functions the WriteEvent function is used for tracing the script activity and logging to the event log. The VMHostTimeZone function will translate the VMHost time zone metric to the configured three letter time zone. The VMHostComplianceStatus function will initiate a compliancy status against VM Host Cluster. The UpdateRemediationBaseline function will add the VM Host Cluster to the approved baseline.</p>
<p><span style="font-weight: bold;">Lines 100 &ndash; 107&nbsp; - </span>Setting the error action setting for the PowerShell script. There are also two global variable being declared for the time zone and the baseline. These are static entries now, but when we move the script into System Center Orchestrator they will be variables using published data in the data bus.</p>
<p><span style="font-weight: bold;">Line 112 - </span>Starts the Try,Catch in the scripts and does the search Where clause for the Host Clusters you are looking to target. You will have to edit this for your environment.</p>
<p><strong>Line 125 &ndash; </strong>Ensures the Host Cluster is assigned to a baseline</p>
<p><strong>Line 137 &ndash; </strong>Verifying the Nodes in the Host Cluster are in the required time zone.</p>
<p><strong>Line 142</strong> &ndash; Checking to see if the VM Host is not compliant. If compliant it is skipped and not added to the Job Group</p>
<p><strong>Line 147 &ndash; 152</strong> &ndash; This is a ForEach loop that will got through all the VMs on the VM Host and add the VM Host information to the Custom Field 1 property of the VM. This will be used in a later script to return the VM to the host it was running on prior to remediation. After the script runs through remediation, you will notice the Custom1 Property of the VM listed with the VM Host name that the VM is currently running on.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/5700.VM-Custom-Field-1-Property_2E3FC4DC.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/5700.VM_2D00_Custom_2D00_Field_2D00_1_2D00_Property_5F00_2E3FC4DC.jpg"><img width="707" height="446" title="VM Custom Field 1 Property" style="display: inline; background-image: none;" alt="VM Custom Field 1 Property" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/3225.VM-Custom-Field-1-Property_thumb_475B1F14.jpg" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/3225.VM_2D00_Custom_2D00_Field_2D00_1_2D00_Property_5F00_thumb_5F00_475B1F14.jpg" border="0" /></a></p>
<p>&nbsp;</p>
<p><strong>Line 158 &ndash; 170</strong> &ndash; This is a sequence to determine if the VM has the DVD drive mounted and then unmounts the the DVD drive if mounted on the VMs</p>
<p><strong>Line 177</strong> &ndash; Add the VM Host node of the VM Host Cluster to the Job Group if found not compliant.</p>
<p><strong>Line 196</strong> &ndash; Initiate the VM Host Cluster Remediation Job in SCVMM</p>
<p><strong>Line 197</strong> &ndash; Writing out the SCVMM Job GUID to the event log for System Center Operations Manager to monitor and execute a System Center Orchestrator runbook that will monitor the SCVMM Job until complete and report status. You will see this detailed out in later posts on this series.</p>
<p><strong>Line 213</strong> &ndash; Script Complete <img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/84/67/metablogapi/2502.wlEmoticon-smile_53E129CD.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-67-metablogapi/2502.wlEmoticon_2D00_smile_5F00_53E129CD.png" /></p>
<p>&nbsp;</p>
<p>Feel free to post your comments or questions. You can also email me too.</p>
<p>Phil Gibson | Senior Consultant | Microsoft | System Center &amp; Private Cloud Infrastructure &amp; Development</p>
<p>&nbsp;</p>
<div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:acc4bf14-c66e-4f41-bda5-0ee072c5405b" style="margin: 0px; padding: 0px; float: none; display: inline;">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;">SCVMMClusterRemediation.ps1</div>
<div style="background: #ddd; max-height: 500px; overflow: auto;"><ol style="background: #ffffff; margin: 0 0 0 3em; padding: 0 0 0 5px; white-space: nowrap;" start="1">
<li><span style="color: #006400;">&lt;#</span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;Purpose&nbsp;&nbsp;: Remediate Hyper-V Clusters using SCVMM 2012</span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;Author&nbsp;&nbsp;&nbsp;: <a href="mailto:pgibson.online@hotmail.com">pgibson.online@hotmail.com</a> [MSFT]</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;"><span style="color: #006400;"> Disclaimer: THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, </span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED </span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&gt;</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;"><span style="color: #006400;">#######&nbsp;&nbsp;Functions ###############</span></li>
<li><span style="color: #00008b;">Function</span> <span style="color: #8a2be2;">global:WriteEvent</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">&lt;#</span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Purpose&nbsp;&nbsp;: Write events into the eventlog of the executing machine.</span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Setup&nbsp;&nbsp;&nbsp;&nbsp;: Please edit the $EventSoure variable to the EventLog source you want your script to utilize as default. Ex. $EventSource = "MyLogSource"</span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Example 1: WriteEvent -EventSource "TEST" -EventID 101 -EventType "Warning" -EventMessage "This is really a test."</span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Example 2: WriteEvent -Source "TEST" -ID 101 -Type "Warning" -Message "This is really a test."</span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**NOTE** : This function will default the EventLog source you supplied with a "Information" event to the "Application" log if the parameters are not used/overridden</span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Author&nbsp;&nbsp;&nbsp;: pgibson.online@live.com [MSFT]</span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&gt;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">param</span> (</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$false</span><span style="color: #a9a9a9;">,</span>Helpmessage<span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"Please enter the source of the Eventlog entry. Example: -Source ""MyLogSource"""</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">alias</span>(<span style="color: #8b0000;">"Source"</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[string]</span><span style="color: #ff4500;">$EventSource</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"SCVMMHostRemediation"</span><span style="color: #a9a9a9;">,</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span>Helpmessage<span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"Please enter the event ID of the Eventlog entry. Example: -ID 101"</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">alias</span>(<span style="color: #8b0000;">"ID"</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[int]</span><span style="color: #ff4500;">$EventID</span><span style="color: #a9a9a9;">,</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$false</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">alias</span>(<span style="color: #8b0000;">"Type"</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">ValidateSet</span>(<span style="color: #8b0000;">"Error"</span><span style="color: #a9a9a9;">,</span> <span style="color: #8b0000;">"Information"</span><span style="color: #a9a9a9;">,</span> <span style="color: #8b0000;">"Warning"</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[string]</span><span style="color: #ff4500;">$EventType</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"Information"</span><span style="color: #a9a9a9;">,</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span>Helpmessage<span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"Please enter the event description of the Eventlog entry. Example: -Message ""This is a test."""</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">alias</span>(<span style="color: #8b0000;">"Message"</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[string]</span><span style="color: #ff4500;">$EventMessage</span><span style="color: #a9a9a9;">,</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$false</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">alias</span>(<span style="color: #8b0000;">"Log"</span>)<span style="color: #a9a9a9;">][</span><span style="color: #00bfff;">ValidateSet</span>(<span style="color: #8b0000;">"Application"</span><span style="color: #a9a9a9;">,</span> <span style="color: #8b0000;">"Security"</span><span style="color: #a9a9a9;">,</span> <span style="color: #8b0000;">"System"</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[string]</span><span style="color: #ff4500;">$EventLog</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"Application"</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;"># Create event source if it does not exist</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">If</span> (<span style="color: #a9a9a9;">!</span><span style="color: #008080;">[System.Diagnostics.EventLog]</span><span style="color: #a9a9a9;">::</span>SourceExists(<span style="color: #ff4500;">$EventSource</span>))</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008080;">[System.Diagnostics.EventLog]</span><span style="color: #a9a9a9;">::</span>CreateEventSource(<span style="color: #ff4500;">$EventSource</span><span style="color: #a9a9a9;">,</span> <span style="color: #ff4500;">$EventLog</span>)</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">write-eventlog</span> <span style="color: #000080;">-logname</span> <span style="color: #ff4500;">$EventLog</span> <span style="color: #000080;">-Source</span> <span style="color: #ff4500;">$EventSource</span> <span style="color: #000080;">-eventid</span> <span style="color: #ff4500;">$EventID</span> <span style="color: #000080;">-entrytype</span> <span style="color: #ff4500;">$EventType</span> <span style="color: #000080;">-message</span> <span style="color: #ff4500;">$EventMessage</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">Else</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">write-eventlog</span> <span style="color: #000080;">-logname</span> <span style="color: #ff4500;">$EventLog</span> <span style="color: #000080;">-Source</span> <span style="color: #ff4500;">$EventSource</span> <span style="color: #000080;">-eventid</span> <span style="color: #ff4500;">$EventID</span> <span style="color: #000080;">-entrytype</span> <span style="color: #ff4500;">$EventType</span> <span style="color: #000080;">-message</span> <span style="color: #ff4500;">$EventMessage</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;"><span style="color: #00008b;">Function</span> <span style="color: #8a2be2;">global:VMHostTimeZone</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">&lt;#</span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Purpose&nbsp;&nbsp;: Detects Time Zone of VMHost machine. Returns three letter time zone. </span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Example 1: VMHostTimeZone -TimeZone </span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**NOTE** : You MUST configure this function with additonal timezone if needed. Only EST,CST,MST, and PST are configured. Time Zone is represented in minutes minus GMT</span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Author&nbsp;&nbsp;&nbsp;: <a href="mailto:pgibson.online@hotmail.com">pgibson.online@hotmail.com</a> [MSFT]</span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&gt;</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">param</span> (</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span>Helpmessage<span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"Please enter the VMHost Time Zone Property. Example: -VMHostTimeZone -240"</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[int]</span><span style="color: #ff4500;">$TimeZone</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">Switch</span> (<span style="color: #ff4500;">$TimeZone</span>)</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #8a2be2;">-240</span> { <span style="color: #00008b;">return</span> <span style="color: #8b0000;">"EST"</span> }</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #8a2be2;">-300</span> { <span style="color: #00008b;">return</span> <span style="color: #8b0000;">"CST"</span> }</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #8a2be2;">-360</span> { <span style="color: #00008b;">return</span> <span style="color: #8b0000;">"MST"</span> }</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #8a2be2;">-420</span> { <span style="color: #00008b;">return</span> <span style="color: #8b0000;">"PST"</span> }</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #8a2be2;">default</span> { <span style="color: #00008b;">return</span> <span style="color: #ff4500;">$Null</span> }</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;"><span style="color: #00008b;">Function</span> <span style="color: #8a2be2;">global:VMHostComplianceStatus</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">&lt;#</span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Purpose&nbsp;&nbsp;: Detects the Compliance Status of a VMHost machine. Returns OverallComplianceState. Tested known status results are "NonCompliant", "Unknown", and "Compliant".</span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Example 1: VMHostComplianceStatus -VMHostName "MyVMHost"</span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**NOTE** : </span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Author&nbsp;&nbsp;&nbsp;: <a href="mailto:pgibson.online@hotmail.com">pgibson.online@hotmail.com</a> [MSFT]</span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&gt;</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">param</span> (</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span>Helpmessage<span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"Please enter the VMHost Name as string. Example: VMHostComplianceStatus -VMHostName ""MyVMHost"""</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[string]</span><span style="color: #ff4500;">$VMHostName</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$VMHost</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCVMHost</span> <span style="color: #000080;">-ComputerName</span> <span style="color: #ff4500;">$VMHostName</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$Compliance</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCComplianceStatus</span> <span style="color: #000080;">-VMMManagedComputer</span> <span style="color: #ff4500;">$VMHost</span><span style="color: #a9a9a9;">.</span>ManagedComputer</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">return</span> <span style="color: #ff4500;">$Compliance</span><span style="color: #a9a9a9;">.</span>OverallComplianceState<span style="color: #a9a9a9;">.</span>ToString()</li>
<li style="background: #f3f3f3;">&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;">&nbsp;</li>
<li><span style="color: #00008b;">Function</span> <span style="color: #8a2be2;">global:UpdateRemediationBaseline</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">&lt;#</span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Purpose&nbsp;&nbsp;: Updates a Baseline with a VMHost machine. </span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Example 1: UpdateRemediationBaseline -VMHostName "MyVMHost" -Baseline "MyBaseline"</span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**NOTE** : </span></li>
<li><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Author&nbsp;&nbsp;&nbsp;: pgibson.online@live.com [MSFT]</span></li>
<li style="background: #f3f3f3;"><span style="color: #006400;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&gt;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">param</span> (</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span>Helpmessage<span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"Please enter the Cluster Host Name as string. Example: UpdateRemediationBaseline -VMHostName ""MyVMHost"" -Baseline ""MyBaseline"""</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[string]</span><span style="color: #ff4500;">$ClusterName</span><span style="color: #a9a9a9;">,</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #a9a9a9;">[</span><span style="color: #00bfff;">parameter</span>(Mandatory<span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span>Helpmessage<span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"Please enter the Remediation Baseline Name as string. Example: UpdateRemediationBaseline -VMHostName ""MyVMHost"" -Baseline ""MyBaseline"""</span>)<span style="color: #a9a9a9;">]</span><span style="color: #008080;">[string]</span><span style="color: #ff4500;">$Baseline</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$Cluster</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCVMHostCluster</span> <span style="color: #000080;">-Name</span> <span style="color: #ff4500;">$ClusterName</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$RemediationBaseline</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCBaseline</span> <span style="color: #000080;">-Name</span> <span style="color: #ff4500;">$Baseline</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">Set-SCBaseline</span> <span style="color: #000080;">-Baseline</span> <span style="color: #ff4500;">$RemediationBaseline</span> <span style="color: #000080;">-AddAssignmentScope</span> <span style="color: #ff4500;">$Cluster -EA 0</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li><span style="color: #006400;">#######&nbsp;&nbsp;End Functions ###############</span></li>
<li style="background: #f3f3f3;">&nbsp;</li>
<li><span style="color: #006400;">######## Start Main ###########</span></li>
<li style="background: #f3f3f3;"><span style="color: #ff4500;">$ErrorActionPreference</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"Stop"</span></li>
<li><span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Start Host Cluster Remediation Process."</span></li>
<li style="background: #f3f3f3;">&nbsp;</li>
<li><span style="color: #006400;"># Set the Approved Time Zone property for the Host Cluster to be Remediated</span></li>
<li style="background: #f3f3f3;"><span style="color: #ff4500;">$global:ApprovedTimeZone</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"EST"</span></li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;"><span style="color: #006400;"># Set Baseline for Compliance Scan</span></li>
<li><span style="color: #ff4500;">$global:ApprovedBaseline</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"Pilot"</span></li>
<li style="background: #f3f3f3;">&nbsp;</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3;"><span style="color: #00008b;">Try</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$HostClusters</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCVMHostCluster</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span> { (<span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span>ClusterName <span style="color: #a9a9a9;">-eq</span> <span style="color: #8b0000;">"HVCLSRV01"</span>)}</li>
<li>&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">ForEach</span> (<span style="color: #ff4500;">$HostCluster</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$HostClusters</span>)</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Processing Host Cluster $HostCluster."</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">#Generate Remediation JobGroup SCJob GUID</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$JobGroupGUID</span> <span style="color: #a9a9a9;">=</span> <span style="color: #008080;">[System.Guid]</span><span style="color: #a9a9a9;">::</span>NewGuid()</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"The SCVMM Host Cluster Remediation Job GUID for Host Cluster $HostCluster is $JobGroupGUID."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$Cluster</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCVMHostCluster</span> <span style="color: #000080;">-Name</span> <span style="color: #ff4500;">$HostCluster</span><span style="color: #a9a9a9;">.</span>ToString()</li>
<li style="background: #f3f3f3;">&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Setting Baseline Assignment on Host Cluster $HostCluster to ensure Baseline is set for possible Remediation."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">### NOTE: THIS WILL CREATE A JOB ERROR IS THE CLUSTER IS ALREADY ASSIGNED TO THE BASELINE. NO HARM DONE IF CLUSTER ALREADY EXISTS, BUT A FAILED JOB STATUS WILL BE PRODUCED ###</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">UpdateRemediationBaseline</span> <span style="color: #000080;">-ClusterName</span> <span style="color: #ff4500;">$HostCluster</span><span style="color: #a9a9a9;">.</span>ToString() <span style="color: #000080;">-Baseline</span> <span style="color: #ff4500;">$ApprovedBaseline</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">#Get all Nodes in Cluster</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$HostClusterNodes</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$HostCluster</span><span style="color: #a9a9a9;">.</span>Nodes</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">ForEach</span> (<span style="color: #ff4500;">$Node</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$HostClusterNodes</span>)</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$VMHost</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCVMHost</span> <span style="color: #000080;">-ComputerName</span> <span style="color: #ff4500;">$Node</span> <span style="color: #000080;">-VMHostCluster</span> <span style="color: #ff4500;">$Cluster</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Processing Node $VMHost of Host Cluster $HostCluster."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Verifying time zone of Node $VMHost of Host Cluster $HostCluster."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">#Detect TimeZone of $VMHost</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">If</span> ((<span style="color: #0000ff;">VMHostTimeZone</span> <span style="color: #000080;">-TimeZone</span> <span style="color: #ff4500;">$VMHost</span><span style="color: #a9a9a9;">.</span>TimeZone) <span style="color: #a9a9a9;">-eq</span> <span style="color: #ff4500;">$ApprovedTimeZone</span>)</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Node $VMHost of Host Cluster $HostCluster is in the correct time zone for remediation."</span></li>
<li style="background: #f3f3f3;">&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Detecting Compliance Status of Node $VMHost of Host Cluster $HostCluster."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">If</span> ((<span style="color: #0000ff;">VMHostComplianceStatus</span> <span style="color: #000080;">-VMHostName</span> <span style="color: #ff4500;">$VMHost</span><span style="color: #a9a9a9;">.</span>Name<span style="color: #a9a9a9;">.</span>ToString()) <span style="color: #a9a9a9;">-ne</span> <span style="color: #8b0000;">"Compliant"</span>)</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Begin VM to VMHost pairing on Node $VMHost of Host Cluster $HostCluster."</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">##### - Start VM to VMHost Pairing Sequence - ###### # This will write the VMHost name in the Custom1 field property of the VM.</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;"># This is used in a later process to rebalance the Host Cluster after remediation has taken place.</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">ForEach</span> (<span style="color: #ff4500;">$VM</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$VMHost</span><span style="color: #a9a9a9;">.</span>VMs)</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Setting Custom Field 1 on VM $VM on Node $VMHost of Host Cluster $HostCluster"</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$CustomProperty1</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCCustomProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8b0000;">"Custom1"</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">Set-SCCustomPropertyValue</span> <span style="color: #000080;">-InputObject</span> <span style="color: #ff4500;">$VM</span> <span style="color: #000080;">-CustomProperty</span> <span style="color: #ff4500;">$CustomProperty1</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$VMHost</span><span style="color: #a9a9a9;">.</span>Name<span style="color: #a9a9a9;">.</span>ToString()</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">##### - End VM to VMHost Pairing Sequence - ######</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Completed VM to VMHost pairing for Node $VMHost of Host Cluster $HostCluster"</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Begin VM DVD Drive Unmount Sequence for each VM on Node $VMHost of Host Cluster $HostCluster"</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">##### - Start VM DVD Drive Unmount Sequence - ###### # Remediation will fail if VMs have a local path ISO mounted. ex. C:\Windows\System32\vmguest.iso </span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$VMsWithDVDMounted</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-VMHost</span> <span style="color: #ff4500;">$VMHost</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Get-VM</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Get-VirtualDVDDrive</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span> {<span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span>ISO <span style="color: #a9a9a9;">-ne</span> <span style="color: #ff4500;">$null}</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">If</span> (<span style="color: #ff4500;">$VMsWithDVDMounted</span><span style="color: #a9a9a9;">.</span>Count <span style="color: #a9a9a9;">-gt</span> <span style="color: #800080;">0</span>)</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">ForEach</span> (<span style="color: #ff4500;">$VM</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$VMsWithDVDMounted</span>)</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">#$VM = Get-SCVirtualMachine -Name $strVMName</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Unmounting DVD drive on VM $VM.Name"</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff4500;">$DVDDrive</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-SCVirtualDVDDrive</span> <span style="color: #000080;">-VM</span> <span style="color: #ff4500;">$VM</span><span style="color: #a9a9a9;">.</span>Name<span style="color: #a9a9a9;">.</span>ToString() <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span> { <span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span>Bus <span style="color: #a9a9a9;">-eq</span> <span style="color: #800080;">1</span> <span style="color: #a9a9a9;">-and</span> <span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span>LUN <span style="color: #a9a9a9;">-eq</span> <span style="color: #800080;">0</span> }</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">Set-SCVirtualDVDDrive</span> <span style="color: #000080;">-VirtualDVDDrive</span> <span style="color: #ff4500;">$DVDDrive</span> <span style="color: #000080;">-NoMedia</span> <span style="color: #000080;">-EA</span> <span style="color: #800080;">0</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Completed Unmounting DVD drive on VM $VM.Name"</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">##### - End VM DVD Drive Unmount Sequence - ###### </span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Completed VM DVD Drive Unmount Sequence for each VM on Node $VMHost of Host Cluster $HostCluster"</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Adding Cluster Node Job Task for Node $VMHost of Host Cluster $HostCluster."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">#Add Cluster Node Job Tasks to Job Group</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">Start-SCUpdateRemediation</span> <span style="color: #000080;">-JobGroup</span> <span style="color: #ff4500;">$JobGroupGUID</span><span style="color: #a9a9a9;">.</span>ToString() <span style="color: #000080;">-VMHost</span> <span style="color: #ff4500;">$VMHost</span> <span style="color: #000080;">-VMHostCluster</span> <span style="color: #ff4500;">$Cluster</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Finished Adding Cluster Node Job Task for Node $VMHost of Host Cluster $HostCluster."</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">Else</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Node $VMHost of Host Cluster $HostCluster is currently Compliant. No Remediation will be done at this time."</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">Else</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Node $VMHost of Host Cluster $HostCluster is NOT in the correct time zone for remediation. No Remediation will be done at this time."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Starting SCJob Remediation for Host Cluster $HostCluster."</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">Start-SCUpdateRemediation</span> <span style="color: #000080;">-BypassMaintenanceModeCheck</span> <span style="color: #000080;">-JobGroup</span> <span style="color: #ff4500;">$JobGroupGUID</span><span style="color: #a9a9a9;">.</span>ToString() <span style="color: #000080;">-RunAsynchronously</span> <span style="color: #000080;">-StartNow</span> <span style="color: #000080;">-UseLiveMigration</span> <span style="color: #000080;">-VMHostCluster</span> <span style="color: #ff4500;">$Cluster</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">101</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #ff4500;">$JobGroupGUID</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006400;">#Clear JobGroupGUID variable</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Clearing Job Group GUID variable for Host Cluster $HostCluster."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">Clear-Variable</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">JobGroupGUID</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Cleared Job Group GUID variable for Host Cluster $HostCluster."</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li><span style="color: #00008b;">Catch</span></li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #00008b;">Throw</span> <span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span>Exception</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">200</span> <span style="color: #000080;">-Type</span> <span style="color: #8b0000;">"Error"</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Host Cluster Remediation Process Failed. Error message: $_.Exception.Message"</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background: #f3f3f3;"><span style="color: #00008b;">Finally</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background: #f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">WriteEvent</span> <span style="color: #000080;">-EventID</span> <span style="color: #800080;">100</span> <span style="color: #000080;">-EventMessage</span> <span style="color: #8b0000;">"Completed Host Cluster Remediation Process."</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;}</li>
</ol></div>
</div>
</div>]]></content:encoded>
    </item>
    <item>
      <title>How to use .NET managed code in a Management Pack for Operations Manager 2007 R2 - Part 1 - The Overview</title>
      <link>https://docs.microsoft.com/archive/blogs/phillipgibson/how-to-use-net-managed-code-in-a-management-pack-for-operations-manager-2007-r2-part-1-the-overview</link>
      <pubDate>Tue, 12 Apr 2011 20:22:00 GMT</pubDate>
      <dc:creator><![CDATA[Phil Gibson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/phillipgibson/2011/04/12/how-to-use-net-managed-code-in-a-management-pack-for-operations-manager-2007-r2-part-1-the-overview/</guid>
      <description><![CDATA[How to use .NET managed code in a Management Pack for Operations Manager 2007 R2 - Part 1 - The...]]></description>
      <content:encoded><![CDATA[<h1>How to use .NET managed code in a Management Pack for Operations Manager 2007 R2 - Part 1 - The Overview</h1>
<p>&nbsp;</p>
<p>I recently attended and participated in the Microsoft Management Summit 2011 (MMS 2011) in Las Vegas, NV. While I was working at the Datacenter Services booth I was approached by a guy that asked me a question "Hey is there any way to use .NET code in a management pack?" I responded and told him that there's nothing native that supports using .NET code, but since the arrival of R2 there is a native PowerShell provider that will allow you to do pretty much everything in .NET in PowerShell. After a lengthy conversation I was then left with the curiosity of can it be done? Is there an easy supportable and efficient way to implement .NET code in a management pack? The answer is YES! This post will provide an overview of how I accomplished the task.</p>
<h2>The PowerShell Add-Type Cmdlet (The secret sauce)</h2>
<p>&nbsp;</p>
<p>When I started to research this possibility, I discussed this with a co-worker Don and he led me to the PowerShell Add-Type cmdlet ( <a href="https://technet.microsoft.com/en-us/library/dd315241.aspx">https://technet.microsoft.com/en-us/library/dd315241.aspx</a>) . This cmdlet allows you to define a .NET class in your PowerShell script. As you can see from the TechNet example below, you simply create a variable and encapsulate your .NET code within the @" &lt;.NET code here&gt; ". You can then instantiate your class for use.</p>
<p>&nbsp;</p>
<p>C:\PS&gt;$source = @"</p>
<p>public class BasicTest</p>
<p>{</p>
<p>&nbsp;&nbsp;&nbsp; public static int Add(int a, int b)</p>
<p>&nbsp;&nbsp;&nbsp; {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (a + b);</p>
<p>&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp; public int Multiply(int a, int b)</p>
<p>&nbsp;&nbsp;&nbsp; {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;return (a * b);</p>
<p>&nbsp;&nbsp;&nbsp; }</p>
<p>}</p>
<p>"@</p>
<p>&nbsp;</p>
<p>C:\PS&gt; Add-Type -TypeDefinition $source</p>
<p>&nbsp;</p>
<p>C:\PS&gt; [BasicTest]::Add(4, 3)</p>
<p>&nbsp;</p>
<p>C:\PS&gt; $basicTestObject = New-Object BasicTest </p>
<p>C:\PS&gt; $basicTestObject.Multiply(5, 2)</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>Creating the PowerShell Script</h2>
<p>&nbsp;</p>
<p>Now that I have an understanding of how to encapsulate .NET code in a PowerShell script, I now need to come up with an example to use. I've found this to be the most challenging part because everything I could code in .NET I could do in PowerShell and in most cases with much less lines of code. So I decided to go with a common example in the management pack documentation, I will return the number of files in a folder. &nbsp;This is the C# class I will use below.</p>
<p>public static int FileCount(string FolderName)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string s = FolderName;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int files;</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.IO.DirectoryInfo f = new System.IO.DirectoryInfo(FolderName);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; files = f.GetFiles().Length;</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return files;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;</p>
<p>So from looking at the C# class, it is roughly 8 lines of code. Compared to doing the functionality in PowerShell in one line of code like this (Get-ChildItem C:\Temp).Count . Again if it was me I would just write a PowerShell script and use the native script module provider in R2, but since this post is about using .NET code in a management pack we will continue on. Also one thing to note is I had to fully qualify my method calls such as System.IO.DirectoryInfo whereas if you are using a directive such as "using System.IO;" I could just call DirectoryInfo instead of System.IO.DirectoryInfo. I'm sure there's a way to utilize directives, but I just did not investigate all the Add-Type cmdlet options and in my testing the script didn't work when using it.</p>
<p>Now that I know what I want to monitor and have my .NET C# class, I now need to put it in a script for Operations Manager to consume. &nbsp;Below is the PowerShell script containing the .NET C# class that I will use when creating the management pack.</p>
<p>param([string]$MonitoredFolder)</p>
<p>&nbsp;</p>
<p>$api = New-Object -comObject 'MOM.ScriptAPI'</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p>$api.LogScriptEvent("CheckFolderFileCount.ps1",101,4,"Script started.")</p>
<p>$api.LogScriptEvent("CheckFolderFileCount.ps1",101,4,"The monitored folder is $MonitoredFolder")</p>
<p>&nbsp;</p>
<p>$bag = $api.CreatePropertyBag()</p>
<p>&nbsp;</p>
<p>$CSharpCode = @"</p>
<p>&nbsp;</p>
<p>public class Folder</p>
<p>{</p>
<p>&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp; public static int FileCount(string FolderName)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string s = FolderName;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int files;</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.IO.DirectoryInfo f = new System.IO.DirectoryInfo(FolderName);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; files = f.GetFiles().Length;</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return files;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; </p>
<p>}</p>
<p>"@</p>
<p>&nbsp;</p>
<p>Add-Type -TypeDefinition $CSharpCode</p>
<p>&nbsp;</p>
<p>$api.LogScriptEvent("CheckFolderFileCount.ps1",101,4,"The amount of files in $MonitoredFolder is {0}" -f [Folder]::FileCount($MonitoredFolder))</p>
<p>&nbsp;</p>
<p>$bag.AddValue('FolderFileCount', '[Folder]::FileCount($MonitoredFolder)')</p>
<p>&nbsp;</p>
<p>$bag</p>
<p>&nbsp;</p>
<p>$api.LogScriptEvent("CheckFolderFileCount.ps1",101,4,"Script complete.")</p>
<p>&nbsp;</p>
<p>Part 2 of this post will discuss implementing the script into a custom management pack.</p>]]></content:encoded>
    </item>
  </channel>
</rss>