TechColumnist Storage Information Blog

16Jul/100

ISY Python Script for controlling media lights via xbmc

Here is a simple python script to use the REST code in the ISY (http://universal-devices.com) to control devices that are linked. I'm designing this script to be used inside a script for xbmc. here's the first part of it. I recommend using scenes for the devicedim, deviceoff, and deviceon array, however you can use the individual devices as well in the array.


import urllib2
import urllib
import sys

devicedim = ['41941']
deviceoff = ['48839']
deviceon = ['62270']
username = 'admin'
password = 'admin'

topurl = 'http://isy'
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, topurl, username, password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)

if sys.argv[1] == 'playing':
	for devicex in deviceoff:
		theurl = 'http://isy/rest/nodes/' + devicex + '/cmd/DOF'
		#normalize the URL
		theurl = urllib.quote(theurl, safe="%/:=&?~#+!$,;'@()*[]")
		print (theurl)
		pagehandle = urllib2.urlopen(theurl)
	for devicex in devicedim:
		theurl = 'http://isy/rest/nodes/' + devicex + '/cmd/DON/64'
		#normalize the URL
		theurl = urllib.quote(theurl, safe="%/:=&?~#+!$,;'@()*[]")
		print (theurl)
		pagehandle = urllib2.urlopen(theurl)
elif sys.argv[1] == 'stopped':
	for devicex in deviceon:
		print (devicex)
		theurl = 'http://isy/rest/nodes/' + devicex + '/cmd/DON'
		#normalize the URL
		theurl = urllib.quote(theurl, safe="%/:=&?~#+!$,;'@()*[]")
		print (theurl)
		pagehandle = urllib2.urlopen(theurl)
else:
	print 'no state given'

Usage:

isy-medialights.py playing|stopped
Tagged as: , , No Comments
7Jul/100

Schedule a URL into Maintenance Mode

Found a nice article about how to script a URL (or web application) into maintenance mode. This was a little bit of a challenge to find so I'm reposting it to hopefully get some more attention. I've also posted the modified version of the script that allows for multiple watcher hosts.

param($rootMS,$urlName,$minutes,$comment,$reason)
Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable errSnapin;

Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin;
set-location $rootMS -ErrorVariable errSnapin;

$URLWatcher = (Get-MonitoringClass -name Microsoft.SystemCenter.WebApplication.Perspective) | Get-MonitoringObject | where {$_.DisplayName -eq $urlName}

$startTime = [System.DateTime]::Now
$endTime = $startTime.AddMinutes($minutes)

"Putting URL into maintenance mode"
foreach ($name in $URLWatcher) {
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime -monitoringObject:$name -comment:$comment -Reason:$reason }

Usage:

C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe URLMaintenanceModeV4.ps1 -rootMS: `SCOMRMS1′ -urlName: ‘MSN Website Checker’ -minutes:45 -comment: ‘My Comment’ -reason: ‘PlannedOther’

http://www.scom2k7.com/schedule-a-into-url-maintenance-mode/

Tagged as: , No Comments
7Jul/092

Script: Check for Orphaned HomeDirs

It seems no matter how much you try you cannot ever get those damned orphaned homedirs cleaned up. Well, this helps. Our org always has additional groups in the homedir (no, we don't just let the users have whatever they want in there, so we have to monitor). This causes a little confusion amongst most orphaned file checkers (as there is still a group in there that resolves). Read on for the code and an example.

What this script does is it scans a directory's subdirectories (as with many homedirs, the subdirectories are usually the AD account name). It then tries to match the subdirectory to an AD account name. If this proves that one doesn't exist, it prompts and spits out the ACL info and a prompt to move the files. If you say yes, it moves them to the directory you specified in arg1.

2Mar/080

Preparing for SCCM – enabling Secure Key Exchange

I found this interesting forum post on the msft forums. This code will help you change all your sites to require secure key exchange.

here's the post: http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2796017&SiteID=17

20Oct/070

Change SMS Cache Size

This script will change the sms cache size.
Usage Example: cscript change-sms-cache.vbs 1000 d:\
Note: size is in MB

24Aug/070

Check for reboot

call checkpendingstatus
sub CheckPendingStatus
Set ComputerStatus = CreateObject("Microsoft.Update.SystemInfo")
If ComputerStatus.RebootRequired Then
wscript.echo "This computer has a pending reboot."
Else
wscript.echo "this computer does not have a pending reboot."
End If
End sub

Tagged as: No Comments
9Aug/070

Ping a list of machines from txt

This vbscript pings machines from a text file:

change the two variables for your input and output txt files:
strPATHout = "C:\pingstatus.txt"
strPATHin = "C:\pinglist.txt"