Stefan Stranger's Lifestream - tagged with powershell http://www.stranger.nl/feed en-us http://blogs.law.harvard.edu/tech/rss Sweetcron stefan@stranger.nl Using PowerWF for creating an OpsMgr MP http://www.stranger.nl/items/view/6509

Today I stumbled on this video about PowerWF (a visual PowerShell Development tool) creating an OpsMgr MP. The video shows how PowerWF can be used with PowerShell scripts and converts it to a workflow,and creating a MP with the data for OpsMgr.   Visual PowerShell Development with PowerWF Studio makes Microsoft’s PowerShell accessible to everyone. PowerWF Studio allows users to drag-and-drop PowerShell commands to create powerful workflows that are easier to understand and modify than conventional scripts.  

]]>
Sat, 24 Apr 2010 12:51:00 +0200 http://www.stranger.nl/items/view/6509
Bing Visual Search for PowerShell Cmdlets http://www.stranger.nl/items/view/6475

Did you know you can use Bing Visual Search for PowerShell Cmdlets? How cool is this? Want to know more check this interview with Jeffrey Snover by Tony Soper at MMS.

]]>
Wed, 21 Apr 2010 09:09:00 +0200 http://www.stranger.nl/items/view/6475
Windows PowerShell Quick Reference http://www.stranger.nl/items/view/6426

Just doing some PowerShell stuff to forget I could have been in Las Vegas for MMS 2010, I stumbled on this PowerShell Quick Reference. Quick reference guide to commonly-used Windows PowerShell commands. For best results, open the file in Microsoft Word, print the contents to legal-sized paper (8 inches by 14 inches), and fold the resulting printout in half, making a four-page booklet. Download here.

]]>
Tue, 20 Apr 2010 09:26:00 +0200 http://www.stranger.nl/items/view/6426
Using PSExec to troubleshoot OpsMgr issues http://www.stranger.nl/items/view/6169

As you probably know OpsMgr quite some people use the local system account as Action Account. And if things are not working as expected you sometimes want to run a script or other actions under the local system account. I used to use the Task Scheduler to have scripts running under the Local System Account, but now I learned you can easily use the PSExec tool of SysInternals to do the same:-) How does this work? You can download the tool and install it on the systems you want to do your troubleshooting or just use the live share on http://live.sysinternals.com/ I created a quick and dirty PowerShell script that writes the owner of the PowerShell process to the PowerShell eventlog.

######################################################################################## # Write Owner of PowerShell Process to PowerShell Eventlog # Authors: Stefan Stranger # ScriptName: UserAccountDebugging.ps1 # v1.000 - 24/03/2010 - stefstr - initial sstranger's release (quick & dirty version)
######################################################################################## #Function Write-EventLog($Description) # #Writes Owner of PowerShell process to PowerShell Eventlog. ############################################################################################## function Write-EventLog($Description) {     $source = "PowerShell(PowerShell)"     [string]$type = "Information"     [int]$eventid = 999         if(![System.Diagnostics.EventLog]::SourceExists($source))         {             [System.Diagnostics.EventLog]::CreateEventSource($source,'Windows PowerShell')         }         else          {                 $log = New-Object System.Diagnostics.EventLog                  $log.set_log("Windows PowerShell")                  $log.set_source($source)                 $log.WriteEntry($Description,$type,$eventid)         }

} $processes = Get-WmiObject Win32_Process -Filter "name='powershell.exe'" $appendedprocesses = foreach ($process in $processes) {Add-Member -MemberType NoteProperty -Name Owner  -Value ($process.GetOwner().User) -InputObject $process -PassThru} $owners = ($appendedprocesses | select owner) foreach ($owner in $owners) {     $evtdescription = "PowerShell process is being run under the next account: "  + $owner.Owner     Write-EventLog $evtdescription }

Do whatever you wanted to do in the PowerShell script for your OpsMgr environent

Write-Host "Hello World" Save above script as UserAccountDebugging.ps1. If we run the above script with our logged on user account we get the next result:

Result in Eventviewer

    Now let’s start PSExec and run the PowerShell script with the local system account. Open Command prompt (as Administrator) and type: psexec –i –d –s powershell.exe

Now a new PowerShell Window will be opened as Local System Account.

Let’s now run the PowerShell script again and check the owner of the PowerShell process. Close all PowerShell sessions first ;-)

      Have fun using PSExec to debug OpsMgr Permissions issues with the local system account.

]]>
Wed, 24 Mar 2010 16:29:00 +0100 http://www.stranger.nl/items/view/6169
Anybody wants to test my OpsMgr MP Authoring PowerGUI PowerPack? http://www.stranger.nl/items/view/6134

I just created my first PowerGUI PowerPack which you can use together with the MP Authoring Console. Just like I blogged previously in my MP Authoring Helper PowerShell script here. Here a teaser screenshot of the PowerGUI PowerPack.   It’s just a first version I created and I would like to have it tested a little more before posting it on the PowerGUI PowerPack library. So if anybody is creating MP’s using the MP Authoring Console and wants to try to use the MP Authoring PowerPack within PowerGUI to help creating MP’s let me know via Twitter via a DM or use the contact form on my weblog and I’ll email my PowerPack for testing.

]]>
Mon, 15 Mar 2010 21:24:00 +0100 http://www.stranger.nl/items/view/6134
MP Authoring Helper http://www.stranger.nl/items/view/6110

This week I’m having an internal MP Authoring Workshop from Brian Wren and I learned that it’s sometimes handy to have information available that’s not available when having the MP Authoring tool open. You can not switch to the Service Model when you have an other windows open. That’s why I created a PowerShell script that let’s you easily have a look at all the Classes, Discoveries, Relationships and Modules you already created in your Management Pack (if you have saved it). Just copy the script and save it to “MPAuthoringHelper_v1.003.ps1” ############################################################################### # Getting Classes from MP XML file and exporting it to csv for use in the # MP Authoring tool # Authors: Stefan Stranger # v1.001 - 27/01/2010 - sstranger - initial sstranger's release # v1.002 - 11/03/2010 - sstranger - added GetRelationshipTypes Function and changed GetClasTypes Function #                               - added GetDiscoveries Function # v1.003 - 11/03/2010 - sstranger - added GetModules Function ############################################################################### param ([string]$Path = $(read-host "Please enter MP XML path and file name")) $Path = "c:\TEMP\MPAuthoringWS\day4\StoreApp.stefstr.xml" #$Path = "C:\Users\stefstr\Documents\Customers\Rabobank\MPDumps\Microsoft.SQLServer.2008.Monitoring.xml" #$Path = "C:\Users\stefstr\Documents\Customers\Rabobank\MPDumps\Microsoft.Exchange.Server.2003.Monitoring.xml" #Globals $global:XmlMPFileDocument = new-object System.Xml.XmlDocument # Get MP XML file. # Make sure you saved your MP file to XML regularly. $XmlMPFileDocument.Load($Path) ############################################################################################## #Function GetClassTypes # #Get Class Types from MP XML file ############################################################################################# Function GetClassTypes {      $MyClassTypes = $XmlMPFileDocument.ManagementPack.TypeDefinitions.EntityTypes.ClassTypes.ClassType     $MyClassTypes | select @{n='Class Name';e='ID'},@{n='Base Class';e='Base'}, Abstract, Singleton } ############################################################################################## #Function GetRelationshipTypes # #Get RelationShip Types from MP XML file ############################################################################################# Function GetRelationshipTypes {     $myRelationshipTypes = $XmlMPFileDocument.ManagementPack.TypeDefinitions.EntityTypes.RelationshipTypes.RelationshipType     $myRelationshipTypes | select @{n='Name';e='ID'},@{n='Base Class';e='Base'}, Abstract, Source, Target } ############################################################################################## #Function GetDiscoveries # #Get Discoveries from MP XML file ############################################################################################# Function GetDiscoveries {      $myDiscoveries = @()     foreach ($Discovery in $XmlMPFileDocument.ManagementPack.Monitoring.Discoveries.Discovery)     {         $obj = new-object System.Management.Automation.PSObject         $obj = $obj | add-member -membertype NoteProperty -name "Name" -value $Discovery.ID -passthru         $obj = $obj | add-member -membertype NoteProperty -name "Target" -value $Discovery.Target -passthru         $obj = $obj | add-member -membertype NoteProperty -name "Discovery Class" -value $Discovery.DiscoveryTypes.DiscoveryClass.TypeID -passthru         $obj = $obj | add-member -membertype NoteProperty -name "DS TypeID" -value $Discovery.DataSource.TypeID -passthru         $myDiscoveries = $myDiscoveries + $obj     }     $myDiscoveries } ############################################################################################## #Function GetModules # #Get Modules from MP XML file ############################################################################################# Function GetModules {     $myModules = @()     if ($XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.ProbeActionModuleType)     {         foreach ($ProbeModule in $XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.ProbeActionModuleType)         {             $obj = new-object System.Management.Automation.PSObject             $obj = $obj | add-member -membertype NoteProperty -name "Module Type" -value "Probe" -passthru             $obj = $obj | add-member -membertype NoteProperty -name "Name" -value $ProbeModule.ID -passthru             $obj = $obj | add-member -membertype NoteProperty -name "Type ID" -value $ProbeModule.ModuleImplementation.Composite.MemberModules.ProbeAction.TypeID -passthru             $myModules = $myModules + $obj         }     }     if ($XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.DataSourceModuleType)     {         foreach ($DSModule in $XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.DataSourceModuleType)         {             $obj = new-object System.Management.Automation.PSObject             $obj = $obj | add-member -membertype NoteProperty -name "Module Type" -value "Data Source" -passthru             $obj = $obj | add-member -membertype NoteProperty -name "Name" -value $DSModule.ID -passthru             $obj = $obj | add-member -membertype NoteProperty -name "Type ID" -value $DSModule.ModuleImplementation.Composite.MemberModules.DataSource.TypeID -passthru             $myModules = $myModules + $obj         }     }     if ($XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.WriteActionModuleType)     {            foreach ($WAModule in $XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.WriteActionModuleType)         {             $obj = new-object System.Management.Automation.PSObject             $obj = $obj | add-member -membertype NoteProperty -name "Module Type" -value "Write Action" -passthru             $obj = $obj | add-member -membertype NoteProperty -name "Name" -value $WAModule.ID -passthru             $obj = $obj | add-member -membertype NoteProperty -name "Type ID" -value $WAModule.ModuleImplementation.Composite.MemberModules.WriteAction.TypeID -passthru             $myModules = $myModules + $obj         }     }     if ($XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.ConditionDetectionModuleType)     {            foreach ($ConditionModule in $XmlMPFileDocument.ManagementPack.TypeDefinitions.ModuleTypes.ConditionDetectionModuleType)         {             $obj = new-object System.Management.Automation.PSObject             $obj = $obj | add-member -membertype NoteProperty -name "Module Type" -value "Condition Dectection" -passthru             $obj = $obj | add-member -membertype NoteProperty -name "Name" -value $ConditionModule.ID -passthru             $obj = $obj | add-member -membertype NoteProperty -name "Type ID" -value "See XML for more info" -passthru             $myModules = $myModules + $obj         }     }     $myModules } #Call Functions GetClassTypes | Out-GridView GetRelationshipTypes | Out-GridView GetDiscoveries | Out-GridView GetModules | Out-GridView It only needs one parameter and that’s the path and filename of the MP xml file you are creating. Remember to save your MP xml file regularly. Have fun creating new MP’s!

]]>
Thu, 11 Mar 2010 19:18:00 +0100 http://www.stranger.nl/items/view/6110
Download OpsMgr Guides in one-click http://www.stranger.nl/items/view/5928

Have you ever tried to download the files on the System Center Operations Manager 2007 R2 Documentation webpage? On this page you find all the technical documentation for Operations Manager 2007 R2. Pretty handy to have them downloaded on you workstation for offline reading. But as you see you need download each file separately :-( And if you are as lazy as me you don’t like that. That’s why I created a PowerShell script using BitsTransfer to do this in one-click. Cool? I think so. ############################################################################### # Download all OpsMgr Guides from # http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=19bd0eb5-7ca0-41be-8c0f-2d95fe7ec636 # in one-go using PowerShell and Bits. # Remark: Use PowerShell 2.0 because it makes use of the BitsTransfer Module # Author: Stefan Stranger # v1.001 - 19/02/2010 - stefstr - initial release ############################################################################### $global:path = "c:\Temp\" Import-Module BitsTransfer #Loads the BitsTransfer Module Write-Host "BitsTransfer Module is loaded" $OpsMgrGuides = @("http://download.microsoft.com/download/7/4/d/74deff5e-449f-4a6b-91dd-ffbc117869a2/Linked.Reporting.MP.xml", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007_AuthGuideXplat.exe", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007_ReportAuthoringGuide.docx", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007R2_CrossPlatformMPAuthoringGuide.docx", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007R2_CrossPlatformMPAuthoringGuide_Samples.zip", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007R2_CrossPlatformMPAuthoringGuide_Samples.zip", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007R2_DesignGuide.docx", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007R2_DeploymentGuide.docx", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007R2_MPAuthoringGuide.docx", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007R2_MPModuleReference.docx", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007R2_OperationsAdministratorsGuide.docx", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007R2_OperationsUsersGuide.docx", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007R2_SecurityGuide.docx", "http://download.microsoft.com/download/B/F/D/BFDD0F66-1637-4EA3-8E6E-8D03001E5E66/OM2007R2_UpgradeGuide.docx") Foreach ($OpsMgrGuide in $OpsMgrGuides) { Start-BitsTransfer $OpsMgrGuide $path} Write-Host "OpsMgr Guides are downloaded to $path" Just copy above script and save it to DownLoadOpsMgrGuides.ps1 and run it from PowerShell 2.0. Screenshots:   Have fun with the OpsMgr Guides and using PowerShell!

]]>
Fri, 19 Feb 2010 10:43:00 +0100 http://www.stranger.nl/items/view/5928
Reblog: Asset Management MP for Service Manager 2010 http://www.stranger.nl/items/view/5799

Source: Contoso.se Two weeks ago I had an System Center Service Manager training in the UK together with some Microsoft Partners. Maarten Goet from Inovativ held an small System Center Service Manager competition for the best System Center Service Manager extension. Although I was not on the same class as Anders Bengtsson and Patrik Sundqvist I also entered the competition with a PowerShell script that exported the Classes and Properties of the System Center Management Packs to a Visio Diagram. Kind like the OpsMgr Authoring Console Tool Visio MP Diagram Generator ;-)

But Patrik and Anders showed an Asset Management extension for Service Manager and they won fair and square. More info on their extension can be found here.

]]>
Mon, 08 Feb 2010 20:37:00 +0100 http://www.stranger.nl/items/view/5799
PowerShell: State Changes for a specified Monitor http://www.stranger.nl/items/view/5121

This week a got a question from a customer about ‘flapping’ taking place from a Monitor. I found out that they meant the State Changes that took place for a newly created Monitor. They found out that for a certain machine the State changed quite often and this was caused by a Recovery Task that was part of this monitor. So they wanted to know if there was a way to see quickly if a Monitor caused a lot of State Changes. There are quite some SQL queries you can use to have a look at the State Changes taken place in your OpsMgr environment. Just take a look at some of the SQL queries on the weblog of my colleague Jonathan Almquist. But what if you only want to know the State Changes that took place for a specific Monitor? Again you can use one of Jonathan’s SQL queries and change them to fit your needs. And this is exactly what I’ve done but I also wanted to run the query from the OpsMgr Command Shell. The reason for this was that I easily wanted to retrieve the Monitor Name using the OpsMgr Get-Monitor Cmdlet.   So here is the PowerShell script I created. You can change the SQL query if you want, to fit your own needs ;-) Result screenshot: Have fun with OpsMgr and PowerShell!

]]>
Wed, 09 Dec 2009 14:51:00 +0100 http://www.stranger.nl/items/view/5121
Have these servers an OpsMgr agent installed? http://www.stranger.nl/items/view/5057

Today I got a question from a customer if I would check if a number of servers had an OpsMgr agent installed? Because this was a large list and the number of servers being monitored by OpsMgr was also a very large list I didn’t wanted to to copy and paste all the server names for the text file and check them in the OpsMgr Console. So I created a PowerShell script to check if an OpsMgr Agent was installed for each of the servers in the file list. The first script I created was not very fast because it did a get-agent for each of the servers in the list and that takes quite some time in a large environment ;-) So I created a new one that’s much faster. Let’s start with the slow script: First you need to put all the servers you want to check in a file, like this:

servername1 servername2 servername3 servername4 servername5 servername6 servername7 servername8 servername9 servername10 servername11 dc8

Save this list in a text file like d:\temp\servers.txt Now run the next script in the OpsMgr Command shell:

$servers = get-content d:\temp\servers.txt foreach ($server in $servers) {get-agent | where {$_.ComputerName -eq $server} | select Name} As you can see it takes almost 12 seconds to do this the slow way.

And now the fast way.

$Servers = get-content c:\temp\servers.txt $Agents = get-agent | select ComputerName Foreach ($agent in $Agents) {if ($servers –contains $agent.ComputerName) {$agent | select ComputerName}}

So the next time someone is asking you if an OpsMgr agent is installed on their servers you now it in seconds. Have fun using PowerShell!

]]>
Thu, 03 Dec 2009 22:31:00 +0100 http://www.stranger.nl/items/view/5057
Securing OpsMgr Reports in OpsMgr 2007 SP1 http://www.stranger.nl/items/view/4541

Today I got a question about retrieving the GUID for a newly created OpsMgr  Report Operator User Role in OpsMgr 2007 SP1. When I asked why they wanted to know the GUID for this new Report Operator User Role they answered they needed this GUID on the Report Server for configuring permissions to certain reports. There used to be a Securing Reports pdf on the System Center Forum website but I cannot find it anywhere else anymore. So I’m not sure if this describes all the steps to Secure an OpsMgr Report in OpsMgr 2007 SP1 so I though it would be handy to publish the steps here if you are looking for them. Back to the original question about retrieving the GUID for a Report Operator Role. The easiest way is using PowerShell. I used the next command to retrieve the GUID: Get-Userrole | where {$.Name –match “Test Report Operator Role”} or Get-Userrole | format-List Name, ID Here are all the steps to Secure an OpsMgr Report for a newly created Report Operator Role: 1. Create a Report :-) 2. Create new Report User Role using PowerShell So here is a script to create a new Report Operator user role using Command Shell: $mg = (get-item .).ManagementGroup $reportOperator = $mg.GetMonitoringProfiles() | where {$.Name -eq "ReportOperator"} $obj = new-object Microsoft.EnterpriseManagement.Monitoring.Security.MonitoringUserRole $obj.Name = "TestReportOperatorRole" $obj.DisplayName = "Test Report Operator Role" $obj.Description = "Test Report Operator Role" $obj.MonitoringProfile = $reportOperator $mg.InsertMonitoringUserRole($obj) After you execute this script “Test Report Operator Role” appears in UI and you would be able to add users to it using User Role Properties dialog. From: http://blogs.msdn.com/eugenebykov/archive/2007/10/13/creating-new-report-operator-user-role.aspx 3. Go to Report Server (http://servername/reports) 4. Click on Show Details from the Report you want to configure access to. 5. Click on Edit 6. Click on Security 7. Click on New Role Assignment 8. Insert GUID from New Report Operator Role. GUID can be found using the next PS command: get-userrole | where {$_.Name –match “Test Report Operator Role”}

]]>
Wed, 07 Oct 2009 00:32:00 +0200 http://www.stranger.nl/items/view/4541
Securing OpsMgr Reports in OpsMgr 2007 SP1 http://www.stranger.nl/items/view/4494

Today I got a question about retrieving the GUID for a newly created OpsMgr  Report Operator User Role in OpsMgr 2007 SP1. When I asked why they wanted to know the GUID for this new Report Operator User Role they answered they needed this GUID on the Report Server for configuring permissions to certain reports. There used to be a Securing Reports pdf on the System Center Forum website but I cannot find it anywhere else anymore. So I’m not sure if this describes all the steps to Secure an OpsMgr Report in OpsMgr 2007 SP1 so I though it would be handy to publish the steps here if you are looking for them. Back to the original question about retrieving the GUID for a Report Operator Role. The easiest way is using PowerShell. I used the next command to retrieve the GUID: Get-Userrole | where {$.Name –match “Test Report Operator Role”} or Get-Userrole | format-List Name, ID Here are all the steps to Secure an OpsMgr Report for a newly created Report Operator Role: 1. Create a Report :-) 2. Create new Report User Role using PowerShell So here is a script to create a new Report Operator user role using Command Shell: $mg = (get-item .).ManagementGroup $reportOperator = $mg.GetMonitoringProfiles() | where {$.Name -eq "ReportOperator"} $obj = new-object Microsoft.EnterpriseManagement.Monitoring.Security.MonitoringUserRole $obj.Name = "TestReportOperatorRole" $obj.DisplayName = "Test Report Operator Role" $obj.Description = "Test Report Operator Role" $obj.MonitoringProfile = $reportOperator $mg.InsertMonitoringUserRole($obj) After you execute this script “Test Report Operator Role” appears in UI and you would be able to add users to it using User Role Properties dialog. From: http://blogs.msdn.com/eugenebykov/archive/2007/10/13/creating-new-report-operator-user-role.aspx 3. Go to Report Server (http://servername/reports) 4. Click on Show Details from the Report you want to configure access to. 5. Click on Edit 6. Click on Security 7. Click on New Role Assignment 8. Insert GUID from New Report Operator Role. GUID can be found using the next PS command: get-userrole | where {$_.Name –match “Test Report Operator Role”}

]]>
Tue, 06 Oct 2009 21:32:00 +0200 http://www.stranger.nl/items/view/4494
Reblog: READY: Should you care about Windows PowerShell? http://www.stranger.nl/items/view/4545

Source: get-powershellblog Marco Shaw posted this article on his weblog. “I’m going to start blogging on the System Center Central web site.  The site is dedicated to Microsoft’s System Center product line, which covers a wide-range of products.  I’m starting a series of blogs posts there to talk about using PowerShell while focusing on its use with System Center products. I’m going to title the series: “READY”, “SET”, “GO”. “Ready” is already posted HERE where I talk about why you should learn PowerShell. The “Set” post will probably cover some PowerShell terminology you should really know, and may want to refer back to at any time, and finally the “Go” posts will be a potentially indefinite number of posts where I’m actually going to use PowerShell to try to do something productive to show you how you can use PowerShell. The integration these System Center products have with PowerShell also greatly varies, and I plan to discuss this in future posts in the series.  I would expect them to have better integration in the future though. Please feel free to leave comments at any time if you want me to cover anything in particular. My next post  in that series should appear in the next 2 weeks...” Go and learn PowerShell.   Sorry for not posting lately, but I’ve been pretty busy. Currently learning about MP Authoring and today I finally created my first PowerShell Discovery MP for OpsMgr 2007 R2. Hope to post some lessons learned soon on my weblog. Always wanted to be a developer and creating MP’s from the Authoring Console and editing the XML feels like being a developer ;-)

]]>
Tue, 08 Sep 2009 00:40:00 +0200 http://www.stranger.nl/items/view/4545
Reblog: READY: Should you care about Windows PowerShell? http://www.stranger.nl/items/view/4239

Source: get-powershellblog Marco Shaw posted this article on his weblog. “I’m going to start blogging on the System Center Central web site.  The site is dedicated to Microsoft’s System Center product line, which covers a wide-range of products.  I’m starting a series of blogs posts there to talk about using PowerShell while focusing on its use with System Center products. I’m going to title the series: “READY”, “SET”, “GO”. “Ready” is already posted HERE where I talk about why you should learn PowerShell. The “Set” post will probably cover some PowerShell terminology you should really know, and may want to refer back to at any time, and finally the “Go” posts will be a potentially indefinite number of posts where I’m actually going to use PowerShell to try to do something productive to show you how you can use PowerShell. The integration these System Center products have with PowerShell also greatly varies, and I plan to discuss this in future posts in the series.  I would expect them to have better integration in the future though. Please feel free to leave comments at any time if you want me to cover anything in particular. My next post  in that series should appear in the next 2 weeks...” Go and learn PowerShell.   Sorry for not posting lately, but I’ve been pretty busy. Currently learning about MP Authoring and today I finally created my first PowerShell Discovery MP for OpsMgr 2007 R2. Hope to post some lessons learned soon on my weblog. Always wanted to be a developer and creating MP’s from the Authoring Console and editing the XML feels like being a developer ;-)

]]>
Mon, 07 Sep 2009 21:40:00 +0200 http://www.stranger.nl/items/view/4239
When does my OpsMgr 2007 R2 Eval versions ends? http://www.stranger.nl/items/view/4552

Today I am at a customer who has installed the OpsMgr 2007 R2 Evaluation version and wanted to know when the evaluation periods ends. I thought the easiest way would be look at the install date of the RMS and add 180 days. So I created a PowerShell script to do that for me. $InstallDate = get-managementserver | where {$_.IsRootManagementServer -eq "True"} | select InstallTime Write-host "RMS is installed on: " $InstallDate.InstallTime $InstallDate2 = $InstallDate.InstallTime Write-host "OpsMgr Eval ends on: " $InstallDate2.AddDays(180) Just copy the above lines and run them from the OpsMgr Command Shell.

]]>
Wed, 24 Jun 2009 16:10:00 +0200 http://www.stranger.nl/items/view/4552
When does my OpsMgr 2007 R2 Eval versions ends? http://www.stranger.nl/items/view/3461

Today I am at a customer who has installed the OpsMgr 2007 R2 Evaluation version and wanted to know when the evaluation periods ends. I thought the easiest way would be look at the install date of the RMS and add 180 days. So I created a PowerShell script to do that for me. $InstallDate = get-managementserver | where {$_.IsRootManagementServer -eq "True"} | select InstallTime Write-host "RMS is installed on: " $InstallDate.InstallTime $InstallDate2 = $InstallDate.InstallTime Write-host "OpsMgr Eval ends on: " $InstallDate2.AddDays(180) Just copy the above lines and run them from the OpsMgr Command Shell.

]]>
Wed, 24 Jun 2009 13:10:00 +0200 http://www.stranger.nl/items/view/3461
When will there be WSDL for the MP Catalog Webservice? http://www.stranger.nl/items/view/2990

Did you know that in PowerShell V2 using a Web service is very easy with the new Cmdlet New-WebServiceProxy? This would become very handy if the ManagementPackCatalogWebservice had a WSDL ;-) Then we could do some very cool stuff with the ManagementPack Catalog Webservice… Now we have to wait if there will be a WSDL implemented. Let’s hope.. For more info on Using PowerShell to get info from the ManagementPack Catalog go to Daniele Muscetta’s weblog. He’s the OpsMgr PowerShell guru ;-)

]]>
Fri, 15 May 2009 21:39:00 +0200 http://www.stranger.nl/items/view/2990
Yet another Maintenance Mode GUI http://www.stranger.nl/items/view/2427

Today I got an email from Mark Wolzak with the question if I could give some exposure to his newly created Maintenance Mode GUI based on PowerShell and Windows Forms. At his company there are several people who have to perform maintenance tasks in the monitored environment. Not all of them are familiar with powershell or the operationsmanager console. And there will be probably more people who have the same issues at their company ;-) That’s why he combined the agent maintenance mode script and the group maintenance mode scripts in a graphical UI so that people no longer need to be familiar with powershell or the operations manager console. And now he is giving his solution to the community. So if you are interested. Take  a look at his website and download this new Maintenance Mode GUI based on PowerShell. And in case you want to create a Shortcut to this script you can take a look at the Windows Scripting Guys how to do that.

]]>
Thu, 26 Mar 2009 10:50:00 +0100 http://www.stranger.nl/items/view/2427
Response: What’s the diff? Or – how to see exactly what is new with an updated MP http://www.stranger.nl/items/view/2293

Source: Kevin Holman’s OpsMgr Blog Kevin blogged about ways to find the differences between different versions of a MP. After converting the MP’s to XML files he showed you could use XML Notepad or Beyond Compare to show the differences between the two MP’s. He ends with the question if you have some better/cooler XML diff tools to let him know. I found another ways of finding the differences but I don’t think these are any better, because they still doe not provide the summary in the context of OpsMgr. Ok, how could you find the differences between a MP? First you could PowerShell. PowerShell has a Cmdlet called Compare-Object. This Cmdlet takes two resultsets and automatically analyzes them. It then outputs only those items present in either one of the result sets. Steps: Export the MP’s to XML files Get the contents of the to XML converted MP files Run Compare-Object Cmdlet Complete PowerShell script $version1 = get-content C:\temp\Compare\version1\System.Mom.BackwardCompatibility.Library.xml $version2 = get-content C:\Temp\Compare\Version2\System.Mom.BackwardCompatibility.Library.XML Compare-Object $version1 $version2 But as said before I don’t think this would really be an improvement above the ways Kevin mentions. The second method is using Compare Sheets in Excel. First export the MP’s to Excel with the MPViewer tool from Boris and doing the comparison within Excel. I’ve found some great Excel tools from JMT Excel Consulting which have a Compare Sheets macro you could use to do the comparison. Only problem with this Macro is you have to select each Worksheet manually before you can do the comparison. So the question still remains do you better ways of finding the differences between MP’s with some OpsMgr context?

]]>
Sun, 15 Mar 2009 15:46:00 +0100 http://www.stranger.nl/items/view/2293
How to cheat on Twitbrain using PowerShell http://www.stranger.nl/items/view/2160

The last couple of weeks I’m trying to be the fastest on @twitbrain. Twitbrain is a challenge to answer calculation questions like How much is? 713 – 63 * 3 Example:

But the more people following @twitbrain on Twitter the more difficult it becomes to be the first who answers the question correct. So I thought of a way to cheat on Twitbrain. Call me evil, but I only cheated 3 times, and it was just for the PowerShell learning experience. I won’t do it again. I hope you all can forgive me ;-) So how did I cheat? I used PowerShell to do the math for me and post the result on Twitter as soon as there was a new challenge on the Twitbrain website. For those interested you can find the PowerShell script on Poshcode. But please don’t use it anymore because that would spoil Twitbrain for all those who want to play it fair! You could easily use the example for other websites where you want to find info and post it on Twitter.

]]>
Sat, 07 Mar 2009 16:22:00 +0100 http://www.stranger.nl/items/view/2160