I found this script and it is great, but I have a few issues when it runs. There is no contact information on the site so not sure who to turn to.
The issue is that I have to run it 3 times before it finishes without errors.
When I first run it, it installs SNMP.
Security Tab
Accept SNMP packets from these hosts:
You cannot call a method on a null-valued expression.
At line:63 char:1
- $objRegKeyPM = $objReg.OpenSubKey(“SYSTEM\CurrentControlSet\Service …
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:67 char:1
- $RegValue = $objRegKeyPM.GetValue($Values_counter.ToString())
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Adding 1 localhost to HKLM..\SNMP\Parameters\PermittedManagers
You cannot call a method on a null-valued expression.
At line:75 char:1
- $objRegKeyPM.SetValue($Values_counter.ToString(), $managers)
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:67 char:1
- $RegValue = $objRegKeyPM.GetValue($Values_counter.ToString())
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Adding 2 WS-TV-P01 to HKLM..\SNMP\Parameters\PermittedManagers
You cannot call a method on a null-valued expression.
At line:75 char:1
- $objRegKeyPM.SetValue($Values_counter.ToString(), $managers)
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Accepted Community Names:
Accepted Read Only Community Names:
You cannot call a method on a null-valued expression.
At line:83 char:1
- $objRegKeyVCRO = $objReg.OpenSubKey(“SYSTEM\CurrentControlSet\Servi …
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:87 char:1
- $RegValueRO = $objRegKeyVCRO.GetValueNames()
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Adding Read Only Community TMPC_Monitor to HKLM..\SNMP\Parameters\ValidCommunities
You cannot call a method on a null-valued expression.
At line:95 char:1
- $objRegKeyVCRO.SetValue($ReadOnlyCommunities, 4)
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Accepted Read Write Community Names:
You cannot call a method on a null-valued expression.
At line:101 char:1
- $objRegKeyVCRW = $objReg.OpenSubKey(“SYSTEM\CurrentControlSet\Servi …
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:106 char:1
- $RegValueRW = $objRegKeyVCRW.GetValueNames()
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Adding Read Write Community TMPC_MonitorW to HKLM..\SNMP\Parameters\ValidCommunities
You cannot call a method on a null-valued expression.
At line:114 char:1
- $objRegKeyVCRW.SetValue($ReadWriteCommunities, 8)
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Agent tab installs fine. At the Security Tab, I get “You cannot call a method on a null-valued expression”.
Traps Tab
Traps Tab
Community Name
Creating Subkey TrapConfiguration
You cannot call a method on a null-valued expression.
At line:140 char:1
- $TrapKey = $objReg.OpenSubKey(“SYSTEM\CurrentControlSet\Services\S …
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:141 char:1
- $devnull = $TrapKey.CreateSubKey(“TrapConfiguration”)
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Creating Subkey public
You cannot call a method on a null-valued expression.
At line:144 char:1
- $TrapKey1 = $objReg.OpenSubKey(“SYSTEM\CurrentControlSet\Services\ …
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:145 char:1
- $devnull = $TrapKey1.CreateSubKey($communityname)
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Trap destinations:
You cannot call a method on a null-valued expression.
At line:151 char:1
- $FinalTrapKey = $objReg.OpenSubKey($TrapKey2WCommunity,$true)
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:155 char:1
- $TrapvalueDest = $FinalTrapKey.GetValue($Values_counter).ToString()
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Adding 1 localhost to HKLM..\SNMP\Parameters\TrapConfiguration
You cannot call a method on a null-valued expression.
At line:164 char:1
- $FinalTrapKey.SetValue($Values_counter.ToString(), $trapdestination)
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:155 char:1
- $TrapvalueDest = $FinalTrapKey.GetValue($Values_counter).ToString()
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Adding 2 WS-TV-P01 to HKLM..\SNMP\Parameters\TrapConfiguration
You cannot call a method on a null-valued expression.
At line:164 char:1
- $FinalTrapKey.SetValue($Values_counter.ToString(), $trapdestination)
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
At his point, the Agent tab has the correct information, but the Traps and Security Tabs do not have anything.
Running the script again, the Trap and Security tab are filled in but the script ends with an error
Traps Tab
Community Name
Creating Subkey TrapConfiguration
Creating Subkey public
Trap destinations:
You cannot call a method on a null-valued expression.
At line:155 char:1
- $TrapvalueDest = $FinalTrapKey.GetValue($Values_counter).ToString()
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Adding 1 localhost to HKLM..\SNMP\Parameters\TrapConfiguration
You cannot call a method on a null-valued expression.
At line:155 char:1
- $TrapvalueDest = $FinalTrapKey.GetValue($Values_counter).ToString()
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Adding 2 WS-TV-P01 to HKLM..\SNMP\Parameters\TrapConfiguration
Running it a third time, there are no errors.
I have this set as a GPO to run under Computer Startup, but to restart it a couple times for the script to complete.
Is there someone that can help me figure out the problem?