Avatar of alkin

by alkin

Part 2: Add Locations to OpsMgr Agents with PowerShell

March 25, 2014 at 1:50 pm in Powershell, SytemCenter, Uncategorized by alkin

In my previous post I explained how to do a bulk import of locations.

Now that we have all the locations we want into OpsMgr we can associate agent-managed computers, management servers, or resource pools with a location using teh set-scomlocation CMDLET.

The Set-SCOMLocation cmdlet associates one or more agent-managed computers, management servers, or resource pools with a location. This cmdlet removes a current association, if one exists. The Web Application Availability Monitoring Summary Map Dashboard displays state information for agents, management servers, and resource pools associated with a location. You can remove an association by using the Remove-SCOMLocation cmdlet.

The following script will add location coordinates to a list of servers retrieved from a CSV file. You can download the CSV file here.

# //***************************************************************************
# // ***** Script Header *****
# //
# // Solution:
# // File:      AddlocationstoAgents.ps1
# // Author:    Alexandre Verkinderen
# // Purpose:   Add locations to Agents from Excel
# //
# //
# // ***** End Header *****
# //***************************************************************************
# //----------------------------------------------------------------------------
#//
#//  Global constant and variable declarations
#/
#//----------------------------------------------------------------------------

$list = Import-Csv -Path "C:\temp\Servers.csv"

$MS = "MOM4"

Import-Module OperationsManager
#Connect to OpsMgr Management GroupStart-OperationsManagerClientShell -ManagementServerName: $MS -PersistConnection: $true -Interactive: $true

#//----------------------------------------------------------------------------
#//  Main routines
#//----------------------------------------------------------------------------

#Get all agents
$computers = get-scomagent

#Get all Locations
$Locations = Get-scomlocation

foreach ($entry in $list)
{

$name = $entry.Server
$Loc = $entry.Location

#Filter agents by name
$agent = $computers | where { $_.displayname -like "*$name*" }

#Filter agents by Location
$location = $Locations | where { $_.displayname -like "*$Loc*" }

#Set location
Set-SCOMLocation –Location $Location –Agent $agent

write-host server $name is in $loc

}

Hope this helps.

Alexandre Verkinderen

Avatar of alkin

by alkin

Part 1: Bulk import server locations with PowerShell

March 24, 2014 at 2:47 pm in Powershell, SytemCenter, Uncategorized by alkin

For a recent project I had to specify the longitude and latitude for all my  servers (about a 1000)  to be able to show them on a map.

In OpsMgr 2012 you can now use the the following new PowerShell CMDlets:

  1. The New-SCOMLocation cmdlet creates a location. You can associate agent-managed computers, management servers, or resource pools with a location by using the Set-SCOMLocation cmdlet. The Web Application Availability Monitoring Summary Map Dashboard displays the items that you associate with a location.
  2. The Set-SCOMLocation cmdlet associates one or more agent-managed computers, management servers, or resource pools with a location. This cmdlet removes a current association, if one exists. The Web Application Availability Monitoring Summary Map Dashboard displays state information for agents, management servers, and resource pools associated with a location.

So In part 1 of this blog series I’m going to create a PowerShell script to bulk import my  locations and then in part 2 a second script to bulk associate servers to a certain location. Lastly I’m going to utilize all those locations and GPS coordinates in a map.

The following PowerShell script will add the Longitude and Latitude coordinates of about 790 cities from a CSV file. You can download the CSV file from here.

# //***************************************************************************
# // ***** Script Header *****
# //
# // Solution:
# // File:      Addlocations.ps1
# // Author:    Alexandre Verkinderen
# // Purpose:   Add locations from excell
# //
# //
# // ***** End Header *****
# //***************************************************************************
# //----------------------------------------------------------------------------
#//
#//  Global constant and variable declarations
#/
#//----------------------------------------------------------------------------

$list = Import-Csv -Path "C:\temp\Locations.csv"

$MS = "SCOMSERVER4"

Import-Module OperationsManager
#Connect to OpsMgr Management GroupStart-OperationsManagerClientShell -ManagementServerName: $MS -PersistConnection: $true -Interactive: $true

#//----------------------------------------------------------------------------
#//  Main routines
#//----------------------------------------------------------------------------

foreach ($entry in $list)
{

$name = $entry.Name
$Long = $entry.Long
$Lat = $entry.Lat
#Set location
New-SCOMLocation –DisplayName $Name –Latitude $Lat –Longitude $Long

write-host Location $name added

}

Stay tuned for part 2.

Alexandre Verkinderen

Avatar of alkin

by alkin

part 2: Getting facebook status updates when something happens to my servers.

March 14, 2014 at 7:46 am in Azure, Powershell, SytemCenter by alkin

In my previous blogpost I explained how to install the powershell Facebook Module.

Today I’m going to show you how you can get Facebook status updates when something happens to your server. To simulate this I will create a new runbook that will shut down all the virtual machines in a certain cloud in Azure and then post a facebook status update with the name of the servers that have been shut downed.

To be able to do this I created the following Orchestrator runbook:

image

This workflow will get a list of the Cloud services running in Azure and then stop all the Virtual Machines in that Cloud. After that a status update will be posted on facebook saying which server has been turned off.

The first activity is the get Azure cloud service properties to retrieve cloud service properties

image

We can then use the output of the cloud service activity in the Virtual machine activity to stop all the VM’s in the discovered cloud.

image

The last activity is a .Net activity that will import the facebook module and post a new status update on facebook with the new-FBfeed command

image

The result will be something like this

image

Thanks,

Alexandre Verinderen

Avatar of alkin

by alkin

Part 1: How to manage your clouds with Facebook

March 13, 2014 at 6:18 am in Azure, Powershell, SytemCenter by alkin

At SystemCenter Universe Asia I showcased how you can manage your cloud from Facebook:

image

As I’m really a geek I’m following my servers as friends on Facebook.

So this will not be just one blogpost but will be a series of different posts covering the following:

  1. Part 1; Installing the Facebook Powershell module
  2. Part 2: Getting facebook status updates when something happens to my servers like a shutdown or start.
  3. Deploy a website in Azure from Facebook.
  4. Adding a new friend (or server) in the cloud
  5. Unfriending a “friend” (or server) from Azure

Let’s get started with installing the Facebook Powershell module!

First of all download the Facebook Powershell module from here: http://facebookpsmodule.codeplex.com/ . Facebook PowerShell Module is a PowerShell module for managing Facebook, developed in PowerShell script.

The most important functions are:

  • New-FBConnection: This command sets up the initial Facebook connection which you will need to use most other commands. You will only need to do this once, after that the connection will be cached in your Windows profile.
  • Get-FBFriend: This command retrieves the list of friends of the specified user. Note that default Facebook permissions do not permit Facebook applications to retrieve “friends of friends” lists, even though these are available from the Facebook GUI. This is a limitation of the Facebook API, not of FacebookPSModule.
  • Get-FBAlbum, Get-FBFeed, Get-FBGroup, Get-FBPhoto, Get-FBPost: These commands similarly retrieve other classes of information.
  • Get-FBEvent: This command retrieves the list of events of the specified user or group. Only “future” events will be retrieved, and only if the user has not explicitly responded “will not attend”.
  • Get-FBMember: Retrieves the list of members of a group.
  • Get-FBAssociation: This is a worker function for Get-FBFriends, Events and Feed, but it also provides access to other “Connections” offered by the Facebook Graph API for which specific commands are not yet available.
  • Get-FBObjectData: This retrieves data on a specific object. The object can be of any type. The –Fields parameter specifies the data to retrieve; if you do not specify this, Facebook will choose a default set of fields depending on the object type. Get-FBObjectData returns a single object with parameters corresponding to the requested fields. Individual fields may not be present on the return object if they are not specified for the Facebook object, or if you do not have permission to retrieve them. Note that most Get-FB* commands have a -Fields parameter; it is generally more efficient to retrieve them up front rather than make multiple calls to Get-FBObjectData.
  • Add-FBBulkPhotos: Copy multiple photos to a Facebook album
    *Read-FBBulkPhotos: Copy all the photos in a Facebook album to files, or all the photos in all Facebook albums.
  • New-FBPost: Creates a new post in the user or page feed.
  • New-FBEvent: This command creates a new Facebook event for the current user.
  • New-FBEventInvite: Invites users to an existing event.
  • New-FBPhoto: Upload a photo from your computer to a Facebook album.
  • Show-FBMessageDialog: This command helps send bulk Facebook messages. Facebook does not permit sending messages to be completely automated, but you can use this command to send messages with just a few clicks for each group of 50 recipients.

Once you have donwloaded the zip file run the “FacebookPsModule Aplha .msi”

A welcome window will be open “Click on Next”

The default folder to save the module file in “WindowsPowershell” located in My Document or Documents, Leave it as it is and click on “Next”

Installation starts.

Installation Complete , click on “Close”

Next open up powershell and import the Facebook module

Connect to your Facebook by typing: New-FBConnection

image

when you run the New-FBConnection cmdlet a Facebook login windows will open.

Now provide your Email ID and password and make sure that you checked on “Keep me logged in” and then click on “Log In”. Facebook will ask you to approve the “external” application.

After you clicked on allow, all is done and you will see this . that means connection with your Facebook account is successful.

In the next blog post I’m going to show how to get a facebook status update if something happens to one of my servers.

Thanks,

Alexandre Verkinderen

I want to thank Cameron Fuller for brainstorming with me on how this could be achieved.

Avatar of alkin

by alkin

Install OpsMgr Agent-less remotely with Powershell

January 2, 2014 at 2:04 pm in Powershell, SytemCenter by alkin

In our previous post we installed the OpsMgr agent remotely with Poweshell and enabled agent proxying. Now we are going to monitor a server agentless via Powershell:


#=======================================================================
#
# NAME: Opsmgr 2012 Agent-less Install
#
# AUTHOR: Alexandre Verkinderen
# DATE  : 10/23/2013
#
#Requirements: The Operations Manager Powershell module needs to be installed
#
# COMMENT: This script is designed to install OpsMgr 2012 agent-less
# The following need agent-less installation using default options: Add-SCOMAgentlessManagedComputer <a href="http://technet.microsoft.com/en-us/library/hh918462.aspx">http://technet.microsoft.com/en-us/library/hh918462.aspx</a> : SCDPM01, SCCM01
#=======================================================================

#Variables
$MS = "SCOM01.contoso.com"

invoke-command -ComputerName $MS{
$AgentList = @("scdpm01.contoso.com","sccm01.contoso.com")
 $MS = "SCOM01.contoso.com"

#Import PowerShell Modules
import-module OperationsManager
#Connect to OpsMgr Management Group
New-SCOMManagementGroupConnection -ComputerName $MS

#--------------------------------------------------------------
#OpsMgr Agent Installation
#-----------------------------------

Foreach($Agent in $AgentList)
{

Add-SCOMAgentlessManagedComputer -Name $Agent -ManagedByManagementServer (Get-SCOMManagementserver -Name $MS)

}
}

Thanks,

Alexandre Verkinderen

Avatar of alkin

by alkin

Install OpsMgr Agent remotely with Powershell

December 30, 2013 at 1:59 pm in Powershell, SytemCenter by alkin

As you are aware by now I’m creating a series of Powershell automation activities to automate some System Center installation tasks. Below you can find a Powershell script that will connect to the Opsmgr server remotely (so you dont need the OpsMgr powershell snappin installed locally) deploy the scom agent and enable agent proxiyng on them.


#=======================================================================
#
# NAME: Opsmgr 2012 Agent Install
#
# AUTHOR: Alexandre Verkinderen
# DATE  : 10/23/2013
#
# Requirements: FIrewall needs to be disabled
#
# COMMENT: This script is designed to install OpsMgr 2012 agents.
# The following serfvers  need agents instaled using default options: Install-SCOMAgent <a href="http://technet.microsoft.com/en-us/library/hh920243.aspx:">http://technet.microsoft.com/en-us/library/hh920243.aspx:</a> DC01, SCVMM01
#=======================================================================

#Variables
$MS = "SCOM01.contoso.com"

#Connect remotely to the SCOM server
Invoke-Command -ComputerName $MS -ScriptBlock {

#Variables
$MS = "SCOM01.contoso.com"
$AgentList = @("dc01.contoso.com")
$Password = ConvertTo-SecureString "Passw0rd!" -AsPlainText -Force
$username = "contoso\administrator"
$InstallAccount = New-Object System.Management.Automation.PSCredential($username,$Password)

#Import PowerShell Modules
import-module OperationsManager

#Connect to OpsMgr Management Group
New-SCOMManagementGroupConnection -ComputerName $MS

#--------------------------------------------------------------
#OpsMgr Agent Installation
#-----------------------------------

Foreach($Agent in $AgentList)
{

Install-SCOMAgent -Name $Agent -PrimaryManagementServer (Get-SCOMManagementserver -Name $MS) -ActionAccount $InstallAccount
write-host $Agent "Installed"

}

#----------------------------------
#Sleep so the agent install can finish before enabling agent proxying
#-------------------------------------

Start-Sleep -s 60

#----------------------------------------------
#enabling agent proxying for vmm and AD management pack
#-------------------------------------------------

#Enable Agent Proxying
Get-ScomAgent | where{$_.ProxyingEnabled.Value -eq $False} | Enable-SCOMAgentProxy
}

thanks,

Alexandre Verkinderen

Avatar of alkin

by alkin

Configure users and Roles in App Controller with Powershell

December 26, 2013 at 12:41 pm in Powershell, SytemCenter by alkin

I had to configure remotely some users and Roles in App controller with Powershell.  You can find a lot of all App Controller CMDLets here http://technet.microsoft.com/en-us/library/jj899760(v=sc.20).aspx.

Below you can find the Powershell Script used to connect remotely to the app controller server and add users to the appropriate User Roles:


#=======================================================================
 #
 # NAME: Configure App Controller
 #
 # AUTHOR: Alexandre Verkinderen
 # DATE  : 10/29/2013
 #
 # Requirements:
 #
 # COMMENT:
 #=======================================================================

#Variables
 $APPC = "SCVMM01.contoso.com"

Invoke-Command -ComputerName $APPC -ScriptBlock {

#import App Controller module
 Import-Module -Name AppController

#Variables
 $APPC = "<a href="https://scvmm01.contoso.com&quot;">https://scvmm01.contoso.com"</a>
 $User1 = "contoso\developer"
 $User2 = "contoso\endsuer"
 $Password = ConvertTo-SecureString "Passw0rd!" -AsPlainText -Force
 $username = "contoso\administrator"
 $Credentials = New-Object System.Management.Automation.PSCredential($username,$Password)

#Connect to App Controller
 Get-SCACServer -ServerName $APPC -Credential $Credentials

#Retrieve Userroles
 $UserRole = Get-SCACUserRole –Managed | where { $_.Name –eq "Administrators" }

#Add users to Administrator User Role

Set-SCACUserRole -UserRole $UserRole -AddMembers $User1,$User2
 Write-Host $User1 " and " $User2 " added to App Controller" -foregroundcolor green

}

Avatar of alkin

by alkin

SCSM The report server cannot process the report or shared dataset

December 8, 2013 at 7:33 am in SytemCenter by alkin

 

I encountered the following issue while trying to run a report from the Service Manager console:

scsm

This was a total new installation (done by the Power Depoloyment Toolkit) and everything was installed fine without any errors so I doubled check my SQL, my datawarehouse server, my SQL reporting Service and by digging deeper and deeper into the reports themself on the SQL report I discovered the following error:

 

image

So that was the culprit!  To solve this issue, open the configuration of each report, go to data sources and select the DWDataMart Data source:

image

 

click OK and now you will be able to run reports again!

 

Thanks,

Alexandre Verkinderen

Avatar of alkin

by alkin

Powershell Deployment Toolkit and WAP

December 3, 2013 at 2:50 pm in Azure, SytemCenter by alkin

The latest publicly available PDT version 2.5.270 now includes besides System Center 2012 R2 also Windows Azure Pack.

You can find the new WAP roles in the Variable.xml as shown below:

clip_image002

You will notice that a few roles are missing like the SMA role. You can easily include the SMA Roles

  • System Center 2012 R2 Service Management Automation Web Service Server
  • System Center 2012 R2 Service Management Automation PowerShell Module
  • System Center 2012 R2 Service Management Automation Runbook Worker Server

by just copying the missing roles from the workflow.xml into your variable.xm like this:

<Role Name="System Center 2012 R2 Service Management Automation Runbook Worker Server" Component="System Center 2012 R2 Service Management Automation">

image

Thanks to Rob Willis for pointing this out to me.

Alexandre Verkinderen

Avatar of alkin

by alkin

Poweshell Deployment Toolkit fails for SCCM

December 2, 2013 at 6:05 am in Uncategorized by alkin

 

I kept getting errors on the automatic deployment of SCCM with the PDT toolkit. The thing is that SCCM cannot work with Dynamic ports as described here:

So to fix this just change the SQL port in the to a fix port like shown below:

image

Normally PDT is going to verify if all the SQL settings are defined correctly during the pre-install validation except for this one. So if you want PDT to verify that the SCCM instance is not set to a dynamic port you can add:

<SQL>
<Port>True</Port>
</SQL>

…to the <Validation> section of the SC DB role in the variable.xml file

Thanks for Rob Willis to help me with this.

Alex

Visit Us On TwitterVisit Us On Linkedin