ChiefsPlanet

ChiefsPlanet (https://www.chiefsplanet.com/BB/index.php)
-   Media Center (https://www.chiefsplanet.com/BB/forumdisplay.php?f=2)
-   -   Computers Any PowerShell gurus out there? (https://www.chiefsplanet.com/BB/showthread.php?t=269824)

QuikSsurfer 02-08-2013 09:23 AM

Any PowerShell gurus out there?
 
I've got over 400 windows 2008 R2 servers and I need to install SNMP services and then set the community string and host for it to accept packets from.
Now a few of these servers already have SNMP services installed.. I've put together a PS script to check if SNMP services (a windows feature essentially) is installed -- if it's not, install it - if it is, skip installation and go to deleting the existing strings and creating the new ones.
I've got two local servers here that I'm testing on (both do not have SNMP services installed) and I'm getting the script to run but it fails (says it fails but it actually does install the SNMP services) and doesn't set the community strings UNLESS you run the script a second time. After running the script a second time, all is well..... I've been looking at this for far too long and need another pair of eyes.

And all execution policies are set to RemoteSigned.

Quote:

#Powershell Script To Install SNMP Services (SNMP Service, SNMP WMI Provider)

cls
echo "This script installs and configures SNMP to accept packets from NTOMEAPP and Community Names"
echo "-------------------------------------------------------------------------------------------------------------------------- "

import-module servermanager

#Variables
$pmanagers = "172.17.66.206"
$commstring = '0m$aGr0p3r'

#Import ServerManger Module
Import-Module ServerManager

#Check If SNMP Services Are Already Installed
$check = Get-WindowsFeature | Where-Object {$_.Name -eq "SNMP-Services"}
If ($check.Installed -ne "True") {
#Install/Enable SNMP Services
echo "SNMP not installed"
echo "Installing . ."
Add-WindowsFeature SNMP-Services | Out-Null
}

##Verify Windows Servcies Are Enabled
If ($check.Installed -eq "True"){
# Delete existing values
echo "Deleting existing permitted hosts"
reg DELETE "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers" /va /f

#Set SNMP Permitted Manager(s)
Foreach ($manager in $pmanagers){
echo "Setting permitted managers"
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers" /v 1 /t REG_SZ /d 172.17.66.206 /f | Out-Null

}
#Set SNMP Community String(s)- *Read Only*
Foreach ( $string in $commstring){
echo "Setting READ ONLY PUBLIC as Accepted Community Names"
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities" /v $string /t REG_DWORD /d 4 /f | Out-Null
}
echo "Restarting/starting SNMP service"
Restart-Service "snmp service"
echo " "
echo "Done!"
}
Else {Write-Host "Error: SNMP Services Not Installed (and failed trying to install)."}

QuikSsurfer 02-08-2013 10:09 AM

I see...

Saulbadguy 02-09-2013 02:55 PM

That's stupid.

Just get SCOM 2012.

BigRedChief 02-09-2013 03:19 PM

Powershell is a powerful tool. but, in this case there are better ways to accomplish your goals.

QuikSsurfer 02-09-2013 05:18 PM

Quote:

Originally Posted by Saulbadguy (Post 9389651)
That's stupid.

Just get SCOM 2012.

**** SCOM. We just moved from SCOM to solarwinds.
SCOM may be the chattiest shitsoftware I've used. It also has nothing to do with what I'm trying to accomplish.. Did you mean SCCM? Because that's what I'm using to push the script out to all the servers.. What can SCOM and its heartbeat monitor/mother role do for me here?

Powershell is fantastic and is absolutely necessary in the MS lineup - especially 2012...

What is the easier route I should be taking to install the windows feature (snmp services) and then set the community string and host? Not a GPO... I can only set the GPO to customize the hosts and strings - I can't install it.

Saulbadguy 02-09-2013 09:30 PM

Quote:

Originally Posted by QuikSsurfer (Post 9390129)
**** SCOM. We just moved from SCOM to solarwinds.
SCOM may be the chattiest shitsoftware I've used. It also has nothing to do with what I'm trying to accomplish.. Did you mean SCCM? Because that's what I'm using to push the script out to all the servers.. What can SCOM and its heartbeat monitor/mother role do for me here?

Powershell is fantastic and is absolutely necessary in the MS lineup - especially 2012...

What is the easier route I should be taking to install the windows feature (snmp services) and then set the community string and host? Not a GPO... I can only set the GPO to customize the hosts and strings - I can't install it.

SCOM is chatty as shit unless you configure everything correctly. You can't just install management packs and expect it to work the way you want it to. SNMP isn't going to be nearly as flexible as SCOM. You can even configure SCOM to take corrective actions when an alert is triggered. Log files filling up? Configure SCOM to delete them.

Powershell is awesome. Confirmed.

From looking at your Powershell script, it doesn't seem like it would work if SNMP wasn't already installed.

BigRedChief 02-09-2013 09:57 PM

Quote:

Originally Posted by Saulbadguy (Post 9390665)
SCOM is chatty as shit unless you configure everything correctly. You can't just install management packs and expect it to work the way you want it to. .

No shit. People say its shitty but they never configured the alerts correctly. Just install it and it should do everything correctly??

SCOM 2012 is way better than solarwinds. SCOM 2012 can do almost everything solarwinds can do way cheaper and easier to train people on how to admin the tool.

QuikSsurfer 02-10-2013 09:07 AM

Quote:

Originally Posted by Saulbadguy (Post 9390665)
SCOM is chatty as shit unless you configure everything correctly. You can't just install management packs and expect it to work the way you want it to. SNMP isn't going to be nearly as flexible as SCOM. You can even configure SCOM to take corrective actions when an alert is triggered. Log files filling up? Configure SCOM to delete them.

Powershell is awesome. Confirmed.

From looking at your Powershell script, it doesn't seem like it would work if SNMP wasn't already installed.

On the script, the where-object is fine. I can get it to install from the script no problem.. The problem is its not configuring the strings in one swoop. I'm having to run the script twice. Once snmp is installed it jumps right to deleting the former reg keys and adding the two that we need.
And again, SCOM will not help us here.. You guys are recommending SCOM to me and you haven't any idea what I'm setting this up for. Its for dell open manage essentials.
And I'll admit our SCOM team (1 guy) was very lazy with his configuration of Alerts - thus my getting over 700 emails a day.. None of which are critical.
SCOM is not the point of this thread... Nor can it do anything that I'm needing to use dell OME for -- updates (hardware), inventory, and warranty status.

QuikSsurfer 02-10-2013 09:13 AM

Quote:

Originally Posted by BigRedChief (Post 9390729)
No shit. People say its shitty but they never configured the alerts correctly. Just install it and it should do everything correctly??

SCOM 2012 is way better than solarwinds. SCOM 2012 can do almost everything solarwinds can do way cheaper and easier to train people on how to admin the tool.

I'm not responsible for SCOM.. I didn't set it up and I don't monitor it.. That is handled through our NOC.
We have a massive IT division with various teams.. They've made the decision to abandon SCOM 2007 (even though it is essentially free with our MS contract). I don't make those decisions.
We aren't even looking at SCOM 2012... I just got back a few weeks ago from a 10 day SCCM 2012 class. Apparently, that's the only piece we will be upgrading and migrating to 2012. Aside from the server and AD 2012.

On topic, you don't have any idea about the script in the OP?

Saulbadguy 02-10-2013 09:29 AM

Quote:

Originally Posted by QuikSsurfer (Post 9391181)
On the script, the where-object is fine. I can get it to install from the script no problem.. The problem is its not configuring the strings in one swoop. I'm having to run the script twice. Once snmp is installed it jumps right to deleting the former reg keys and adding the two that we need.
And again, SCOM will not help us here.. You guys are recommending SCOM to me and you haven't any idea what I'm setting this up for. Its for dell open manage essentials.
And I'll admit our SCOM team (1 guy) was very lazy with his configuration of Alerts - thus my getting over 700 emails a day.. None of which are critical.
SCOM is not the point of this thread... Nor can it do anything that I'm needing to use dell OME for -- updates (hardware), inventory, and warranty status.

Yea, it doesn't look like the script has anything to do after SNMP is installed if it wasn't already. I'm not a powershell expert though so I dunno.


FYI, Scom has a Dell management pack that can do all of that.

QuikSsurfer 02-10-2013 11:30 AM

Right on. I didn't look into any dell plugins on SCOM.. I don't believe it will help me in updating bios, firmware, and things relative to chassis CMC's and iDRACs though.


All times are GMT -6. The time now is 11:30 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2024, vBulletin Solutions, Inc.