I am trying to write a script that retrieves the SCOM Name, Version Number, and Build on a SCOM Management Server.
$scomRegistryPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup"
$scomDisplayName = (Get-Item -Path $scomRegistryPath).GetValue("DisplayName")
$scomVersion = (Get-Item -Path $scomRegistryPath).GetValue("DisplayVersion")
$scomBuild = (Get-Item -Path $scomRegistryPath).GetValue("BuildNumber")
Write-Host "SCOM Name: $($scomDisplayName)"
Write-Host "SCOM Version Number: $($scomVersion)"
Write-Host "SCOM Build Number: $($scomBuild)"
When I run it, I get the following errors:
Get-Item : Cannot find path 'C:\Users\UserName\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup' because it does not exist.
At line:3 char:21
+ $scomDisplayName = (Get-Item -Path $scomRegistryPath).GetValue("DisplayName")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\UserName...nager\3.0\Setup:String) [Get-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand
You cannot call a method on a null-valued expression.
At line:3 char:1
+ $scomDisplayName = (Get-Item -Path $scomRegistryPath).GetValue("DisplayName")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Get-Item : Cannot find path 'C:\Users\UserName\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup' because it does not exist.
At line:4 char:17
+ $scomVersion = (Get-Item -Path $scomRegistryPath).GetValue("DisplayVersion")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\UserName...nager\3.0\Setup:String) [Get-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand
You cannot call a method on a null-valued expression.
At line:4 char:1
+ $scomVersion = (Get-Item -Path $scomRegistryPath).GetValue("DisplayVersion")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Get-Item : Cannot find path 'C:\Users\UserName\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup' because it does not exist.
At line:5 char:15
+ $scomBuild = (Get-Item -Path $scomRegistryPath).GetValue("BuildNumber")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\UserName...nager\3.0\Setup:String) [Get-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand
You cannot call a method on a null-valued expression.
At line:5 char:1
+ $scomBuild = (Get-Item -Path $scomRegistryPath).GetValue("BuildNumber")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
The HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup
registry key is accessible and readable from the account using regedit
, so I am confused as to why this script isn't working.