Category PowerShell

Monitor Azure Stack Fabric with OMS

I wanted to monitor my Azure Stack environment with OMS. This would include only the Azure Stack fabric servers and the host. I did not want to manually install the OMS agent on all of these servers especially since the Azure Stack fabric is a set of known servers. So I decided to put together a quick PowerShell script to handle the install of the OMS agents including the workspace ID and key. Here are details for the script:


This script can be used to install OMS agents on all of the Azure Stack Fabric servers. This has been tested with TP2.

This script can be used to install OMS agents on all of the Azure Stack Fabric servers. This has been tested with TP2. This script can be run from PowerShell ISE or a PowerShell console. It is recommended to run this from an elevated window. This script should be run from the Azure Stack host. Ensure you are logged onto the Azure Stack host as azurestack\azurestackadmin. This script allows you to input your OMS workspace ID and key. The Azure Stack Fabric servers that this script will attempt to install on is:













Fabric servers can be added or removed from the array list if desired. The script will look for the OMS agent (MMASetup-AMD64.exe) in C:\OMS\ on the Azure Stack host. Ensure you create an OMS folder on your Azure Stack host and download the OMS agent to it. This script also copies the OMS agent to C:\Windows\Temp on each Fabric server. Ensure there is enough free space on the C drive on all of your fabric servers.

This is Guid ID for your OMS workspace, it can be found in the OMS portal at: >> Overview >> Settings >> Connected Sources >> Windows Servers

This is the OMS API key for your OMS workspace. You can use the primary or secondary key. These keys can be found in the OMS portal at: >> Overview >> Settings >> Connected Sources >> Windows Servers



Script Name: AzureStackFabrickOMSAgentInstall.ps1
Version: 1.0
Author: Cloud and Data Center Management MVP – Steve Buchanan
Creation Date: 1-1-2017
Purpose/Change: Install OMS agents on Azure Stack Fabric servers.
Updates: None

.\AzureStackFabricOMSAgentInstall.ps1 -OMSWorkSpaceID “20d4dd92-53cf-41ff-99b0-7acb6c84beedsr” -OMSKey “aazedscsjwh52834u510350423tjjwgogh9w34thg2ui==”

The script can be downloaded here:

To kick off the script run from PowerShell ISE or a PowerShell console. If you run from ISE you will be prompted for the workspace ID and the key. If you run from a PowerShell console run this syntax to kick it off:

.\AzureStackFabricOMSAgentInstall.ps1 -OMSWorkSpaceID “YOURWORKSPACEID” -OMSKey “YOUROMSKEY”

The script will kick off, building an array of the Azure Stack VM’s, looping through each of them to copy over the OMS agent, and then install the OMS agent setting the OMS workspace ID and key.

The script will detect if an OMS agent is already installed and will skip that server as shown in the following screenshot.

Otherwise the script will install the OMS agent as shown in the following screenshot.

The following screenshot shows the script running in a PowerShell console vs ISE.

You will be prompted when running the script for credentials. Use Azurestack\azurestackadmin as shown in the following screenshot.

After the OMS agent is installed you should be able to log onto any of the Azure Stack VM’s and see the OMS agent in control panel as shown in the following screenshots.

You can also log onto OMS and see your Azure Stack servers listed under connected computers.

Azure Stack fabric servers wire data:

My Azure Stack host in OMS Service Map:

Happy Stacking and OMS’ing!

Read More

Service Manager Discovery Report

I recently built a PowerShell script that creates a discovery report for System Center Service Manager. The idea behind the script was to have something that I could run to gather all of the information I would want about a Service Manager deployment. I searched online and could not find anything so that’s when I decided to put something together.

This report can be used by consultants doing assessments or SCSM admins as an easy way to document what you have in your environment. This is a first pass at the report so it is version 1.1. I plan to add more information/functionality to the report in the future. Keep in mind I am not a PowerShell expert so feel free to take the script tweak it and share your updates with the community.

When the script is run it will output a report of System Center Service Manager in HTML format. This script should be run on a management server within your Service Manager’s management group. The script should be run with an account that has administrative access to Service Manager and the local server it will be running on.

The script will run on Service Manager 2012 SP1 and above. It uses SCSM 2012 SP1/R2 CMDLETS along with SMLets. If you don’t have the SMLets installed you can download them here:

Discovered in the report:

These are the sections of information in the report.

  • Management Server Name
  • Service Manager Version
  • Management Server HDD CPU Memory
  • Service Manager Management Group Name
  • Service Manager Data Warehouse Information
  • Users connected to Service Manager
  • Service Manager Run as accounts
  • Service Manager User Roles
  • Service Manager Notification Channels
  • Service Manager Connectors
  • Service Manager Email Templates
  • Service Manager Subscriptions
  • Service Manager Groups
  • Service Manager Queues
  • Service Manager Service Offerings
  • Published Service Manager Request Offerings
  • Draft Service Manager Request Offerings
  • Service Manager Views
  • Service Manager Tasks
  • Service Manager Un-sealed Management Packs
  • Websites local to the Service Manager Server
  • Last 10 Service Manager error event logs

Example Link:

This will take you to an online example of the report.

Example Output:

Here is a screenshot of the report.


Download It:

NOTE: The PowerShell report is provided AS-IS without warranty of any kind. It is recommended to run in a lab environment before running it in a production environment.

Read More

Service Manager PowerShell Extensions – SCSMPx

Recently a colleague of mine Rob Plank brought some new CMDLets for Service Manager to my attention. These are a part of a PowerShell module that can be installed on your Service Manager server. They are the System Center Service Manager PowerShell Extensions also known as SCSMPx. Here is the official description for them:

The ScsmPx module facilitates automation with Microsoft System Center Service Manager by auto-loading the native modules are included as part of that product and enabling automatic discovery of the commands that are contained within the native modules. It also includes dozens of complementary commands that are not available out of the box to allow you to do much more with your PowerShell automation efforts using the platform.

This module contains hundreds of new commands for Service Manager.

The module was built by Kirk Munro (@Poshoholic) and sponsored by Provance.

The System Center Service Manager PowerShell Extensions ( SCSMPx) module can be found here:

The module requires:

  • PowerShell 3.0
  • SnippetPx module

The module is very easy to install and can be done so by running this syntax from PowerShell on a Service Manager management server:

& ([scriptblock]::Create((iwr -uri -ModuleName ScsmPx,SnippetPx

Running that will download and install the SCSMPx and SnippetPx modules. This is for all users and requires being run from an elevated PowerShell console. This module will auto-load (PowerShell 3.0 and above) so there is no need to run Import-Module to load it.

Once this module is installed on a management server it also enables auto-loading of the native Service Manager CMDlets for Service Manager 2012 and later.

The commands included in the module are:


Read More

PowerShell script for Windows Server Activation

I recently was helping a client that needed to activate over 50+ servers after an OS upgrade. I did not want to do this one by one and they did not have a KMS. PowerShell to the rescue. I was able to put together a script that loops through an OU in Active Directory and activate all computers in that OU. This script will find only computers with “Windows Server” in the name. This script could be modified to find client operating systems instead.

When you run this script it will prompt you for the domain name, organizational unit, and Windows Server product key. I was able to use this in my new lab build as well. Here is the script:

Name: ActivateWinComputersfrAD.ps1
Author: System Center MVP – Steve Buchanan
Date: 2/15/2015
Version: 1.0

This script can be used to loop through an OU in Active Directory and activate all computers in that OU.
This script will find only computers with “Windows Server” in the name.
Run this script using: powershell.exe -executionpolicy unrestricted -command .\ActivateWinComputersfrAD.ps1

# Load the Active Directory PowerShell module
Import-Module -Name ActiveDirectory

# Prompt script runner for information to create variables
$domain = Read-host ‘Enter domain to be used. Format as such (DOMAINNAME)’
$computersou = Read-host ‘Enter the name of the OU to be searched.’
$Productkey = Read-host ‘Enter product key. Format as such (XXXXX-XXXXX-XXXXX-XXXXX-XXXXX)’

# Create a variable that holds all of the computers from Active Directory
$results = (Get-ADComputer -LDAPFilter “(OperatingSystem=*Windows Server*)” -SearchBase “OU=$computersou,DC=$domain,DC=com”)

# Loop through the results variable and activate all computers in that variable.
# NOTE: Dont forget to replace the $key variable with your own Windows key.

foreach ($i in $results)
$computer = gc env:computername
$service = get-wmiObject -query “select * from SoftwareLicensingService” -computername $i.Name

Write-Host “The following servers have been activated:” -ForegroundColor Green
$results | Format-Table DNSHostName -HideTableHeaders


It can be downloaded here:

Read More

Desired State Configuration (DSC) Training

On February 25th Microsoft will hold a free all day training on Desired State Configuration (DSC). This will be from 9AM to 5PM PST on Microsoft Virtual Academy.

Here us the

Course Outline:

Getting Ready for DSC
Performing a Push Deployment
Configuring Pull Servers for Deployment​
Deploying Configurations Using a Pull Server
Resource Roundup
Writing Better Configurations
DSC and Linux

Instructors are:

Jeffrey Snover | Microsoft Dist...

Read More