Installing SCOM 2012 Agent remotely through a script


    • Hi-

    A client of mine has a post build server script that they run on every new server. This installs all of the settings and agents and we were using the invoke-command cmdlet to install the SCOM 2007 R2 agent from the RMS server to the new server. I am trying to replicate the same process using SCOM 2012 but I am unable to remotely run the SCOM 2012 cmdlets.

    Here is the code that is run on the new server:

    $ScomMSServer1 = 'mommgt601.domain.corp'
    $comp = $Env:COMPUTERNAME
    $comp = $comp.ToUpper()
    $Agent = "$comp.domain.corp"
    Invoke-Command -ComputerName $ScomMSServer1 -scriptblock{param($arg1, $arg2) D:\Admin\Scripts\SCOM\SCOM-Agent-Install.ps1 -TargetMS $arg1 -TargetAgent $arg2} -ArgumentList $ScomMSServer1, $Agent

    Here is the code that is run from the management server:


    import-module OperationsManager -verbose
    $pms = Get-SCOMManagementServer -Name $TargetMS

    Install-SCOMAgent -DNSHostName $TargetAgent -PrimaryManagementServer $pms

    Everytime the invoke-command cmdlet runs, it installs the OperationsManager module fine but fails to run the SCOM cmdlets. Is there something that I am missing? Can they be run remotely?


    Wednesday, June 06, 2012 1:55 PM


  • Try to code some logging into your script so you can see where it's failing. Nothing super, just output the results to a text file. That will track down exactly where its failing. Then come back if you're still stuck.


    Friday, June 08, 2012 10:41 PM