Add OMS Admin Secure References

P2P.OMSAdministration.Tasks.AddOMSCertRef (Task)

Adds the OMS Access Certificate to the Run-As Profile for the OMS Administration MP

Element properties:

TargetMicrosoft.SystemCenter.RootManagementServer
AccessibilityInternal
CategoryMaintenance
EnabledTrue
RemotableFalse
Timeout300

Member Modules:

ID Module Type TypeId RunAs 
WA WriteAction Microsoft.Windows.PowerShellWriteAction P2P.OMSAdministration.SDKRunAs

Source Code:

<Task ID="P2P.OMSAdministration.Tasks.AddOMSCertRef" Accessibility="Internal" Target="SC!Microsoft.SystemCenter.RootManagementServer" Enabled="true" Timeout="300" Remotable="true">
<Category>Maintenance</Category>
<WriteAction ID="WA" TypeID="Windows!Microsoft.Windows.PowerShellWriteAction" RunAs="P2PAdmin!P2P.OMSAdministration.SDKRunAs">
<ScriptName>Add Secure Reference.ps1</ScriptName>
<ScriptBody><Script><![CDATA[if ($env:PSModulePath -notlike "*\PowerShell\OperationsManager*") {
$setupKey = Get-Item -Path "HKLM:\Software\Microsoft\Microsoft Operations Manager\3.0\Setup"
$installDirectory = $setupKey.GetValue("InstallDirectory") | Split-Path
$psmPath = $installdirectory + ‘\Powershell\OperationsManager\OperationsManager.psm1’
Import-Module $psmPath
}

$RAAccount = Get-SCOMRunAsAccount -Name 'Microsoft.SystemCenter.Advisor.RunAsAccount.Certificate'
$RAProfile = Get-SCOMRunAsProfile -Name 'P2P.OMSAdministration.CertificateRunAs'
Try
{
$TargetClass = Get-SCOMClass -Name 'P2P.OMSAdministration.Classes.OMSInstallation'
Set-SCOMRunAsProfile -Action "Add" -Profile $RAProfile -Account $RAAccount -Class $TargetClass
}
Catch
{
#we Already have this in our profile and there doesn't appear to be a way to detect it
}
Try
{
$TargetClass = Get-SCOMClass -Name 'P2P.OMSAdministration.Classes.OMSManagementPackBundle'
Set-SCOMRunAsProfile -Action "Add" -Profile $RAProfile -Account $RAAccount -Class $TargetClass
}
Catch
{
#we Already have this in our profile and there doesn't appear to be a way to detect it
}
Try
{
$TargetClass = Get-SCOMClass -Name 'P2P.OMSAdministration.Classes.OMSSolution'
Set-SCOMRunAsProfile -Action "Add" -Profile $RAProfile -Account $RAAccount -Class $TargetClass
}
Catch
{
#we Already have this in our profile and there doesn't appear to be a way to detect it
}
Try
{
$TargetClass = Get-SCOMClass -Name 'P2P.OMSAdministration.Classes.OMSManagementPack'
Set-SCOMRunAsProfile -Action "Add" -Profile $RAProfile -Account $RAAccount -Class $TargetClass
}
Catch
{
#we Already have this in our profile and there doesn't appear to be a way to detect it
}
Try
{
$TargetClass = Get-SCOMClass -Name 'Microsoft.SystemCenter.RootManagementServer'
Set-SCOMRunAsProfile -Action "Add" -Profile $RAProfile -Account $RAAccount -Class $TargetClass
}
Catch
{
#we Already have this in our profile and there doesn't appear to be a way to detect it
}]]></Script></ScriptBody>
<SnapIns/>
<Parameters/>
<TimeoutSeconds>300</TimeoutSeconds>
<StrictErrorHandling>true</StrictErrorHandling>
</WriteAction>
</Task>