<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2618798143602886071</id><updated>2024-09-05T10:54:40.453-07:00</updated><category term="Programming"/><category term="System Admin"/><category term="Python"/><category term="VBScript"/><category term="Files"/><category term="PowerShell"/><category term="Tips"/><category term="Tricks"/><category term="wmi"/><category term="Active Directory"/><category term="Android"/><category term="BATCH"/><category term="Backup"/><category term="Batch Scripting"/><category term="CMD"/><category term="Citrix"/><category term="Data"/><category term="Developer"/><category term="Disconnect"/><category term="GUI"/><category term="Help"/><category term="Input Output"/><category term="Java"/><category term="Scheduled Task"/><category term="TableLayout"/><category term="TableRow"/><category term="Tkinter"/><category term="Tutorial"/><category term="dos"/><category term="query farm"/><category term="query session"/><category term="query user"/><category term="tsdison"/><category term="windows admin"/><title type='text'>Programming and Whatnot</title><subtitle type='html'>Programming in general using Python, VBScript, PowerShell, Java.  Programming for System Admins and Nerds alike.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2618798143602886071.post-7711040752019098546</id><published>2012-07-04T06:52:00.001-07:00</published><updated>2012-07-04T06:52:44.049-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BATCH"/><category scheme="http://www.blogger.com/atom/ns#" term="Batch Scripting"/><category scheme="http://www.blogger.com/atom/ns#" term="Citrix"/><category scheme="http://www.blogger.com/atom/ns#" term="CMD"/><category scheme="http://www.blogger.com/atom/ns#" term="Disconnect"/><category scheme="http://www.blogger.com/atom/ns#" term="dos"/><category scheme="http://www.blogger.com/atom/ns#" term="query farm"/><category scheme="http://www.blogger.com/atom/ns#" term="query session"/><category scheme="http://www.blogger.com/atom/ns#" term="query user"/><category scheme="http://www.blogger.com/atom/ns#" term="System Admin"/><category scheme="http://www.blogger.com/atom/ns#" term="Tricks"/><category scheme="http://www.blogger.com/atom/ns#" term="tsdison"/><category scheme="http://www.blogger.com/atom/ns#" term="windows admin"/><title type='text'>DOS: Disconnect from ALL Citrix sessions with one batch file</title><content type='html'>I am pretty happy with myself for coming up with this.&amp;nbsp; It did take awhile, but it&#39;s working.&lt;br /&gt;
&lt;br /&gt;
First let me start off by saying that we are concerned with the security aspect with keeping information safe but we need to also provide a suitable workflow to help facilitate others with ease of use and help broaden the functionality of the tools they already use.&lt;br /&gt;
&lt;br /&gt;
Here is the Batch file contents.&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
@echo off &lt;br /&gt;SETLOCAL ENABLEDELAYEDEXPANSION&lt;br /&gt;for /f %%A in (&#39;QFARM ^| find &quot;*&quot;&#39;) DO (&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET curSERVER=%%A&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET curSERVER=!curSERVER:~0,-1!)&lt;br /&gt;for /f %%A in (&#39;QFARM ^| find &quot;CITRIX&quot;&#39;) DO (&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET SERVER=%%A&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET lastCHAR=!SERVER:~-1!&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF NOT !lastCHAR! == * for /f &quot;skip=1 tokens=2&quot; %%B in (&#39;QUSER %USERNAME% /SERVER:!SERVER!&#39;) DO (&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tsdiscon %%B /SERVER:!SERVER!&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br /&gt;)&lt;br /&gt;
for /f &quot;skip=1 tokens=2&quot; %%A in (&#39;QUSER %USERNAME%&#39;) do (&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tsdiscon %%A /SERVER:%curSERVER%)&lt;/blockquote&gt;
&lt;strong&gt;An important note:&lt;/strong&gt;&amp;nbsp; This is run from within Citrix... I found that when using the QUERY command locally you don&#39;t have access to the QFARM command, but in a Citrix context you do.&amp;nbsp; We also needed to run this within Citrix because we have generic logins in some locations that act as thin clients, so the %USERNAME% variable would not be effective in this case.&lt;br /&gt;
&lt;br /&gt;
tsdiscon is a great tool that was overlooked initially.&lt;br /&gt;
&lt;br /&gt;
Firstly we wanted to find out what the current server we are on is.&amp;nbsp; This was necessary because if you end up disconnecting from the server you are running this from, it stops.&lt;br /&gt;
&lt;br /&gt;
Secondly... we loop through the output of the QFARM command finding &quot;CITRIX&quot;... if you have different naming conventions, you just have to massage that a little and it&#39;s good to go.&lt;br /&gt;
&lt;br /&gt;
QFARM by itself spit output with the citrix servers and one of the servers has an asterisk at the end... this is one that we want to skip over until the end...&amp;nbsp; its the %curSERVER% variable.&lt;br /&gt;
&lt;br /&gt;
From there on you can see... we loop through the servers finding the ica-tcp#... sessions and use that to disconnect from each of the servers.&lt;br /&gt;
&lt;br /&gt;
I hope this is informative and helps you out!&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/7711040752019098546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://randallcummins.blogspot.com/2012/07/dos-disconnect-from-all-citrix-sessions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/7711040752019098546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/7711040752019098546'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/2012/07/dos-disconnect-from-all-citrix-sessions.html' title='DOS: Disconnect from ALL Citrix sessions with one batch file'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2618798143602886071.post-6138863758346145227</id><published>2012-06-20T07:00:00.004-07:00</published><updated>2012-06-20T07:00:59.994-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Active Directory"/><category scheme="http://www.blogger.com/atom/ns#" term="GUI"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="System Admin"/><category scheme="http://www.blogger.com/atom/ns#" term="Tkinter"/><title type='text'>Python: Let Domain User&#39;s manage themselves</title><content type='html'>Not sure if that&#39;s a great idea ;)&lt;br /&gt;
&lt;br /&gt;
I am always trying to find ways to help the 1st level support guys, they get lots of calls and when the calls pile up, I remember it being quite annoying.&lt;br /&gt;
&lt;br /&gt;
So here is what I created.&amp;nbsp; Hope you enjoy!&amp;nbsp; Now obviously you need to make a few changes to make it work for you, but this little tool allows domain users with little access the ability to Add/ Remove users from groups that they are managers of.&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiamOkJG1ac48ACjaF5hY6Jesu8tVaa_d5DrC5JocjqfJS9PtbFp_XNqngHOTVu8MT9davTizoFzAh1HJvOuqY4mxJ10ek9O-2qu61LOG7mlDzCfbjsfSlSjt2OBC_twBKdcSWIvilRZs/s1600/mconsole.bmp&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiamOkJG1ac48ACjaF5hY6Jesu8tVaa_d5DrC5JocjqfJS9PtbFp_XNqngHOTVu8MT9davTizoFzAh1HJvOuqY4mxJ10ek9O-2qu61LOG7mlDzCfbjsfSlSjt2OBC_twBKdcSWIvilRZs/s1600/mconsole.bmp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Heres what you need:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
Active Directory;&lt;br /&gt;
User account; must be a member of the group as well as selected in the Managed By tab, check the box that says Manager can update the group and you are set. &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;*note&lt;/b&gt; I have images in the current directory, so be sure to change those around as well.&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&#39;&#39;&#39;&lt;br /&gt;Created on Jun 14, 2012&lt;br /&gt;&lt;br /&gt;@author: rcummins&lt;br /&gt;&#39;&#39;&#39;&lt;br /&gt;import active_directory as AD&lt;br /&gt;from Tkinter import *&lt;br /&gt;from os import environ&lt;br /&gt;import ttk&lt;br /&gt;import win32com, win32com.client&lt;br /&gt;import pythoncom&lt;br /&gt;import tkMessageBox&lt;br /&gt;from PIL import Image, ImageTk&lt;br /&gt;&lt;br /&gt;login = environ[&quot;USERNAME&quot;]&lt;br /&gt;manager = []&lt;br /&gt;&amp;nbsp; &lt;br /&gt;LOGIN = AD.find_user(login)&lt;br /&gt;grps = {}&lt;br /&gt;for group in LOGIN.memberOf:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GROUP = AD.AD_object(group)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if str(LOGIN)[7:] == str(GROUP.managedby):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GRP = AD.AD_object(group)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grps[GRP.cn] = GRP.distinguishedName&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; manager.append(str(GRP.cn))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;root = Tk()&lt;br /&gt;root.title(&quot;Manager Console&quot;)&lt;br /&gt;&lt;br /&gt;root.wm_iconbitmap(&#39;mgmt.ico&#39;)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;master = PanedWindow(orient=VERTICAL)&lt;br /&gt;master.pack(fill=BOTH, expand=1)&lt;br /&gt;&lt;br /&gt;userframe = LabelFrame(master, text=&#39;Groups Managed By: %s&#39;%(LOGIN.cn))&lt;br /&gt;&lt;br /&gt;fr = Frame(userframe)&lt;br /&gt;userinfo = Label(fr, text=&#39;Manager of: &#39;)&lt;br /&gt;userinfo.pack(side=LEFT, padx=5, pady=10)&lt;br /&gt;usergroups = ttk.Combobox(fr, values=manager, width=30)&lt;br /&gt;usergroups.pack(side=LEFT, fill=X, expand=1, padx=5)&lt;br /&gt;&lt;br /&gt;type=None&lt;br /&gt;if(len(manager)&amp;gt;0):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; usergroups.set(manager[0])&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ggrp = AD.find_group(manager[0])&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; type = AD.AD_object(ggrp)&lt;br /&gt;grouptype = Label(userframe, text=&quot;No group(s) found..&quot;)&lt;br /&gt;if(type):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; grouptype = Label(userframe, text=&quot;Description: %s&quot;%(ggrp.description))&lt;br /&gt;fr.pack(side=TOP)&lt;br /&gt;grouptype.pack(side=TOP, padx=5)&lt;br /&gt;master.add(userframe)&lt;br /&gt;&lt;br /&gt;groupframe = LabelFrame(master, text=&#39;Group Detail and Modification&#39;)&lt;br /&gt;groupinfo = Listbox(groupframe, height=20, width=30)&lt;br /&gt;groupinfo.pack(side=LEFT, padx=5, pady=10)&lt;br /&gt;controlframe = Frame(groupframe)&lt;br /&gt;controlframe.pack(side=LEFT, padx=5, fill=BOTH)&lt;br /&gt;&lt;br /&gt;master.add(groupframe)&lt;br /&gt;def ADDUser(event=None):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; geo = root.winfo_pointerxy()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xx = geo[0]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; yy = geo[1]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TOPr = Toplevel()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TOPr.title(&quot;Add a user to this group&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TOPr.geometry(&quot;+%d+%d&quot;%(xx,yy))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = Label(TOPr, text=&quot;Enter username:&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x.pack(side=TOP, fill=X, padx=10)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f = Frame(TOPr)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; em = Label(f, text=&quot;@WORK.com&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; em.pack(side=RIGHT)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uname = Entry(f, width=15)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uname.pack(side=RIGHT)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.pack(side=TOP, padx=10)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def plusONE(event=None):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(uname.get()))&amp;gt;0:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usr = AD.find_user(str(uname.get()).strip())&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grp = AD.find_group(str(usergroups.get()).strip())&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uLDAP = &quot;LDAP://%s&quot;%(str(usr.distinguishedName))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gLDAP = &quot;LDAP://%s&quot;%(str(grp.distinguishedName))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grp_obj = win32com.client.GetObject(gLDAP)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grp_obj.Add(uLDAP)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #grp_obj.Remove(uLDAP)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grp_obj.SetInfo()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; groupinfo.insert(END, usr.cn)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except pythoncom.com_error,( hr,msg,exc,arg ):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &quot;Error adding user %s to group %s...&quot; % (usr.cn, grp.cn)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print hr, msg, exc, arg&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #http://code.activestate.com/recipes/511447-add-account-to-group-in-active-directory/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; addButton = Button(TOPr, text=&#39;Add User&#39;, command=plusONE)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; addButton.image = photo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; addButton.pack(side=TOP, fill=X)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; root.update()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TOPr.mainloop()&lt;br /&gt;&lt;br /&gt;img = Image.open(r&quot;business_user.png&quot;)&lt;br /&gt;photo = ImageTk.PhotoImage(img)&lt;br /&gt;addBTN = Button(groupframe, compound=TOP, image=photo, text=&#39;Add User&#39;, command=ADDUser)&lt;br /&gt;addBTN.pack(side=TOP)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def DELUser(event=None): &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; usr = AD.find_user(str(groupinfo.selection_get()).strip())&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; grp = AD.find_group(str(usergroups.get()).strip())&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uLDAP = &quot;LDAP://%s&quot;%(str(usr.distinguishedName))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gLDAP = &quot;LDAP://%s&quot;%(str(grp.distinguishedName))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grp_obj = win32com.client.GetObject(gLDAP)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #grp_obj.Add(uLDAP)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xray = tkMessageBox.askokcancel(&quot;Delete User from Group&quot;, &quot;Are you sure you want to delete: %s from %s&quot;%(usr.cn, grp.cn))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print xray&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(xray):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grp_obj.Remove(uLDAP)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grp_obj.SetInfo()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; except pythoncom.com_error,( hr,msg,exc,arg ):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &quot;Error adding user %s to group %s...&quot; % (usr.cn, grp.cn)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print hr, msg, exc, arg&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #http://code.activestate.com/recipes/511447-add-account-to-group-in-active-directory/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; root.update()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; groupname = usergroups.get()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; usrs = []&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for groupmbr in AD.find_group(groupname).member:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usrs.append(str(groupmbr.cn))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; usrs.sort()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; groupinfo.delete(0, END)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for usrer in usrs:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if usrer != usr.displayName:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; groupinfo.insert(END, usrer)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;br /&gt;&lt;br /&gt;img2 = Image.open(r&quot;business_user_delete.png&quot;)&lt;br /&gt;photo2 = ImageTk.PhotoImage(img2)&lt;br /&gt;delBTN = Button(groupframe, compound=TOP, image=photo2, text=&#39;Remove User&#39;, command=DELUser)&lt;br /&gt;delBTN.pack(side=TOP)&lt;br /&gt;&lt;br /&gt;master.add(groupframe)&lt;br /&gt;&lt;br /&gt;def SelectDropdown(event=None):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(usergroups.get()):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; groupname = usergroups.get()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usrs = []&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for groupmbr in AD.find_group(groupname).member:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usrs.append(str(groupmbr.cn))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usrs.sort()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; groupinfo.delete(0, END)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for usrer in usrs:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; groupinfo.insert(END, usrer)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; root.update()&lt;br /&gt;usergroups.bind(&quot;&amp;lt;&amp;lt;ComboboxSelected&amp;gt;&amp;gt;&quot;, SelectDropdown)&lt;br /&gt;SelectDropdown()&lt;br /&gt;root.mainloop()&lt;/blockquote&gt;
&lt;br /&gt;
As always, I accept constructive feedback, so if it could be cleaner, please let me know! always looking for feedback.</content><link rel='replies' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/6138863758346145227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://randallcummins.blogspot.com/2012/06/python-let-domain-users-manage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/6138863758346145227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/6138863758346145227'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/2012/06/python-let-domain-users-manage.html' title='Python: Let Domain User&#39;s manage themselves'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiamOkJG1ac48ACjaF5hY6Jesu8tVaa_d5DrC5JocjqfJS9PtbFp_XNqngHOTVu8MT9davTizoFzAh1HJvOuqY4mxJ10ek9O-2qu61LOG7mlDzCfbjsfSlSjt2OBC_twBKdcSWIvilRZs/s72-c/mconsole.bmp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2618798143602886071.post-5909016525178314180</id><published>2012-06-18T08:02:00.000-07:00</published><updated>2012-06-18T08:02:28.569-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Backup"/><category scheme="http://www.blogger.com/atom/ns#" term="Data"/><category scheme="http://www.blogger.com/atom/ns#" term="Files"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="Scheduled Task"/><category scheme="http://www.blogger.com/atom/ns#" term="System Admin"/><category scheme="http://www.blogger.com/atom/ns#" term="wmi"/><title type='text'>Python: Backup your data on the fly</title><content type='html'>I have been bitten before, and so to prevent any unforeseen loss of data, I set out to create something of the sort.&lt;br /&gt;
&lt;br /&gt;
I did it.&amp;nbsp; And I am quite proud of it.&amp;nbsp; Even though its not perfect... the concept is pretty rad.&lt;br /&gt;
&lt;br /&gt;
Things you will need.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Python [Modules] - wmi, shutil, os, sys, winpaths(optional....)&lt;/li&gt;
&lt;li&gt;TaskScheduler&lt;/li&gt;
&lt;li&gt;USB or SD card, need to change its name to eBackup, instead of &quot;Removable Disk&quot;&lt;/li&gt;
&lt;/ol&gt;
The basic idea is to: &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;have a scheduled task run when the system is on idle... &lt;/li&gt;
&lt;li&gt;only runs when a drive is present that is labeled eBackup&lt;/li&gt;
&lt;li&gt;copy directories, specified in a cfg file.&lt;/li&gt;
&lt;/ul&gt;
Here is the code for this project:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&#39;&#39;&#39;&lt;br /&gt;Created on Apr 30, 2012&lt;br /&gt;
@author: rcummins&lt;br /&gt;&#39;&#39;&#39;&lt;br /&gt;import wmi&lt;br /&gt;import shutil&lt;br /&gt;import os&lt;br /&gt;import winpaths&lt;br /&gt;import sys&lt;br /&gt;
def getDrive(computer=None):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = wmi.WMI(computer)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; host_info = c.Win32_LogicalDisk(VolumeName=&#39;EBACKUP&#39;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return host_info[0].Name&lt;br /&gt;
def fileChange(source):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drive = getDrive()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for dirs in os.listdir(source):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path = source+&#39;\\&#39;+dirs&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dest = path.replace(&quot;C:\\&quot;, drive[0]+&quot;:\\&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if os.path.getmtime(dest) - os.path.getmtime(path) &amp;lt; 0:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.copytree(path, dest)&lt;br /&gt;
if __name__ == &#39;__main__&#39;:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; computer = &#39;&#39;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; logfile = &#39;&#39;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = getDrive(computer)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logfile = str(sys.argv[1]).strip()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logfile = &#39;eBrake.cfg&#39;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if os.path.exists(logfile):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f = open(logfile,&#39;r&#39;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for q in f.readlines():&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; source = q.strip()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(path, dirs, files) in os.walk(source):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for filez in files:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; src = os.path.join(path, filez)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dst = str(os.path.join(path, filez)).replace(&quot;C:\\&quot;,x[0]+&quot;:\\&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if str(src).find(&quot;.metadata&quot;) &amp;lt; 0:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if os.path.getmtime(dst) - os.path.getmtime(src) &amp;lt; 0:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &quot;Overwriting &amp;gt;&amp;gt; &quot; + dst &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.copy(src, dst)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &quot;Created: &quot; + dst&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not os.path.exists(dst): os.makedirs(dst)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.copytree(src, dst)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except: shutil.copy(src, dst)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &quot;Create file: %s \n\n Enter paths to backup on SD card\n\ncard needs to be named &#39;EBACKUP&#39;&quot;%(logfile)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/blockquote&gt;
I hope this has either inspired you or saved your data.&amp;nbsp; Enjoy!&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/5909016525178314180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://randallcummins.blogspot.com/2012/06/python-backup-your-data-on-fly.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/5909016525178314180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/5909016525178314180'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/2012/06/python-backup-your-data-on-fly.html' title='Python: Backup your data on the fly'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2618798143602886071.post-612889659710055425</id><published>2012-06-14T20:46:00.002-07:00</published><updated>2012-06-14T20:48:35.441-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Files"/><category scheme="http://www.blogger.com/atom/ns#" term="Input Output"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="Tips"/><category scheme="http://www.blogger.com/atom/ns#" term="Tricks"/><title type='text'>Python: Breaking apart large files into smaller chunks</title><content type='html'>Something that I find really neat with Python is its flexibility and strong support in the online community.&amp;nbsp; I found a really good example somewhere on how to do this and I adapted it to my own needs...&amp;nbsp; like most programmers ;)&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
import os&lt;br /&gt;
def UnpileFile(src, outPATH, parts):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not os.path.isdir(outPATH): os.mkdir(outPATH)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; f = open(src, &#39;rb&#39;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; data = f.read()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; f.close()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; byts = len(data)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; inc = (byts+4)/int(parts)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; filenames = []&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in range(0, byts+1, inc):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fn1 = outPATH + &quot;\\file&amp;nbsp;%s&quot; % i&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filenames.append(fn1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f = open(fn1, &#39;wb&#39;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(data[i:i+inc])&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.close()&lt;br /&gt;
def CompileFile(srcPATH, outFILE):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not os.path.isdir(srcPATH): os.mkdir(srcPATH)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; dataList = []&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for root, dirs, files in os.walk(srcPATH):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fn in files:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f = open(str(root+&#39;\\&#39;+fn), &#39;rb&#39;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataList.append(f.read())&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.close()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; f = open(outFILE, &#39;wb&#39;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for data in dataList:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(data)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; f.close()&lt;br /&gt;
&lt;div&gt;
if __name__ == &#39;__main__&#39;:&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/div&gt;
&lt;/blockquote&gt;
There&#39;s not much to import which is a plus... ;)&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
So say you had an ISO image... you only have 2 2gb usb drives? &amp;nbsp;no problem... break these guys up into 2 parts by saying;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
src = the path to the ISO you want to break up&lt;br /&gt;
outPATH = the directory you want to save the broken pieces to&lt;br /&gt;
parts = the number of parts you want the files split into&lt;br /&gt;
&lt;span style=&quot;text-align: -webkit-auto;&quot;&gt;UnpileFile(src, outPATH, parts)&lt;/span&gt;&lt;/blockquote&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_Wr9Tiyueav_v7R9x8K3Lmcm44rwBU8GgAxQpdjdWVnXBVAUWeETq5dPexvJDM-NmV9LJ6_4ICY82ODumc5gPHYySn6naLGOexj8wBM66pi6-ySjMdYUMgfnpQ7D4SCrkL6Qx9W44Hvo/s1600/files.bmp&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_Wr9Tiyueav_v7R9x8K3Lmcm44rwBU8GgAxQpdjdWVnXBVAUWeETq5dPexvJDM-NmV9LJ6_4ICY82ODumc5gPHYySn6naLGOexj8wBM66pi6-ySjMdYUMgfnpQ7D4SCrkL6Qx9W44Hvo/s1600/files.bmp&quot; title=&quot;ISO file broken into 4 parts&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And to put humpty dumpty back together again... so to speak... you just say:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
srcPATH = the directory that has the broken files&lt;br /&gt;
outFILE = the name you want to give your patched up ISO...&lt;br /&gt;
CompileFile(srcPATH, outFILE)&lt;/blockquote&gt;
*NOTE... I am pretty sure I specified mkdir and not makedirs, there is a difference...&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.python.org/library/os.html?highlight=os.mkdir#os.mkdir&quot;&gt;http://docs.python.org/library/os.html?highlight=os.mkdir#os.mkdir&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/612889659710055425/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://randallcummins.blogspot.com/2012/06/python-breaking-apart-large-files-into.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/612889659710055425'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/612889659710055425'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/2012/06/python-breaking-apart-large-files-into.html' title='Python: Breaking apart large files into smaller chunks'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_Wr9Tiyueav_v7R9x8K3Lmcm44rwBU8GgAxQpdjdWVnXBVAUWeETq5dPexvJDM-NmV9LJ6_4ICY82ODumc5gPHYySn6naLGOexj8wBM66pi6-ySjMdYUMgfnpQ7D4SCrkL6Qx9W44Hvo/s72-c/files.bmp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2618798143602886071.post-8212532858714846947</id><published>2012-06-14T19:44:00.001-07:00</published><updated>2012-06-14T20:48:59.690-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="Developer"/><category scheme="http://www.blogger.com/atom/ns#" term="Help"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="TableLayout"/><category scheme="http://www.blogger.com/atom/ns#" term="TableRow"/><category scheme="http://www.blogger.com/atom/ns#" term="Tips"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial"/><title type='text'>Android: Learning to walk... and then programmatically add TableRows to a TableLayout</title><content type='html'>I have had some long spent nights trying to learn developing for Android...&amp;nbsp;LayoutParams... oh you light of my life, LayoutParams...&lt;br /&gt;
&lt;br /&gt;
One recent problem I have been facing is the TableRow widget I intend on populating with data scraped from the web... &amp;nbsp;store it in a ArrayList&amp;lt;String&amp;gt; and pop it into the TableRow as necessary.&lt;br /&gt;
&lt;br /&gt;
I did buy an idiots guide to Android Development... and I gently set it aside and started&amp;nbsp;Google-ing&amp;nbsp;how to accomplish what I wanted an android app to do. &amp;nbsp;If you are struggling,&amp;nbsp;Google&amp;nbsp;is your friend... &amp;nbsp;and just like real life... some friends take you down the wrong path, and others have just what you need.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/3200691/dynamically-add-tablerow-to-tablelayout&quot;&gt;http://stackoverflow.com/questions/3200691/dynamically-add-tablerow-to-tablelayout&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
import android.widget.TableRow.LayoutParams;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
//import android.widget.RelativeLayout.LayoutParams;&amp;nbsp;&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
Just like dfetter88 mentions in his/her answer... ensure you are importing the right thing. &lt;br /&gt;
&lt;br /&gt;
So the background, before getting into the gritty for loop, is that I have scraped data from the web and stored it into an arraylist. &amp;nbsp;So here&#39;s my scratch;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
ArrayList&amp;lt;String&amp;gt; prices = getPrice (doc);&lt;br /&gt;
for(int i =0; i&amp;lt;prices.size(); i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Log.d(&quot;PRINT&quot;, prices.get(i));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //RelativeLayout RLay = new RelativeLayout(getParent());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; TableRow TR = new TableRow(getApplicationContext());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; TR.setId(10);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; TR.setLayoutParams(lp);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; TextView price = new TextView(getApplicationContext());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; price.setId(20);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; price.setLayoutParams(lp);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; price.setText(prices.get(i));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; TR.addView(price);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; TLay.addView(TR, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));&lt;br /&gt;
}&lt;/blockquote&gt;
I had a difficult time wrapping my head around the context argument. &amp;nbsp;Because this for-loop was triggered by a button click, the context was changed and you couldn&#39;t use the term THIS... &amp;nbsp;which refers to the current object... &amp;nbsp;and the current object in that situation is BUTTON... &amp;nbsp;so you can&#39;t very well create a new TableRow within the Button context, so I had to use getApplicationContext()... &lt;br /&gt;
&lt;br /&gt;
I think that is explained right, but then again... I really SHOULD read the Android Developer book.&lt;br /&gt;
&lt;br /&gt;
Another really cool trick I learned is to import the Log &quot;module&quot;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
import android.util.Log;&lt;/blockquote&gt;
This will help you troubleshoot issues while you are testing. &amp;nbsp;you use it like this;&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Log.d(&quot;LEVEL1&quot;,&quot;about to go through the loop... buckle up.&quot;);&lt;/blockquote&gt;
&amp;nbsp;LEVEL1 is just the Tag you can assign to the log... &amp;nbsp;makes it really handy. &amp;nbsp;Eclipse is a super powerful tool that you definitely need to have if you want to explore android development...&amp;nbsp;There are at least a gajillion resources at your disposal. &lt;br /&gt;
&lt;br /&gt;
Here&#39;s where you go to get started:&amp;nbsp;&lt;a href=&quot;http://developer.android.com/guide/index.html&quot;&gt;http://developer.android.com/guide/index.html&lt;/a&gt;&amp;nbsp; Do it up.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/8212532858714846947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://randallcummins.blogspot.com/2012/06/android-learning-to-walk-and-then.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/8212532858714846947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/8212532858714846947'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/2012/06/android-learning-to-walk-and-then.html' title='Android: Learning to walk... and then programmatically add TableRows to a TableLayout'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2618798143602886071.post-1957400296832405700</id><published>2012-06-13T05:38:00.000-07:00</published><updated>2012-06-13T05:38:13.400-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="System Admin"/><category scheme="http://www.blogger.com/atom/ns#" term="VBScript"/><title type='text'>VBScript: XP only!: Find Computer by User Name</title><content type='html'>When I was working for &quot;The helpdesk&quot; a long time ago... I would always forget to write down the computer name and it seemed to be taking more time than it should just to get that info back... I sometimes called the end user... I was looking online and actually didn&#39;t find anything until I ran into an old classmate who had a huge script that he sent me, it was really awesome, filled with SUBS and whatnot.&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here&#39;s the bare necessity:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Dim inputStr, UserName, Domain, splitInput, sName, oArgs, Session&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Dim oUser, userFullName, userHome, fService, LoggedOn, q, ss&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&#39;On Error Resume Next&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
q = Chr(34)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Domain = &quot;Domain&quot;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
username = inputbox(&quot;Enter username: &quot;)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Set oUser = GetObject(&quot;WinNT://&quot; &amp;amp; Domain &amp;amp; &quot;/&quot; &amp;amp; UserName &amp;amp; &quot;,user&quot;)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;br /&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
userFullName = oUser.FullName&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
userHome = oUser.HomeDirectory&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
sName = Split(userHome, &quot;\&quot;)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;br /&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Set fService = GetObject(&quot;WinNT://&quot; &amp;amp; Domain &amp;amp; &quot;/&quot; &amp;amp; sName(2) &amp;amp; &quot;/LanmanServer&quot;)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Set ss = fService.Sessions&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
For Each Session In ss&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;If LCase(Session.User) = LCase(UserName) Then&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;LoggedOn = LoggedOn &amp;amp; vbcr &amp;amp; Session.Computer&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;End If&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Next&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
If LoggedOn = &quot;&quot; then&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;msgbox &quot;User &quot; &amp;amp; q &amp;amp; UserName &amp;amp; q &amp;amp; &quot; (&quot; &amp;amp; userFullName &amp;amp; &quot;) is not logged on.&quot;, 64, &quot;Query:&quot;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Else&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;MsgBox &quot;User &quot; &amp;amp; q &amp;amp; UserName &amp;amp; q &amp;amp; &quot; (&quot; &amp;amp; userFullName &amp;amp; &quot;) logged on to the following workstations: &quot; &amp;amp; vbcr &amp;amp; vbcr &amp;amp; LoggedOn, , &quot;Query:&quot;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
End If&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
One of the cool things about this script is that it doesn&#39;t return the first one it finds, it returns a list of them.&lt;br /&gt;
&lt;br /&gt;
So you may find a bunch of Citrix Servers. &amp;nbsp;I have found it to be&amp;nbsp;flaky&amp;nbsp;at times and have never been able to get this to work with Windows 7... &amp;nbsp;I think because of the LanmanServer part. &lt;br /&gt;
&lt;br /&gt;
Anyways, enjoy!</content><link rel='replies' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/1957400296832405700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://randallcummins.blogspot.com/2012/06/vbscript-xp-only-find-computer-by-user.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/1957400296832405700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/1957400296832405700'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/2012/06/vbscript-xp-only-find-computer-by-user.html' title='VBScript: XP only!: Find Computer by User Name'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2618798143602886071.post-8938236432828581957</id><published>2012-06-13T05:18:00.001-07:00</published><updated>2012-06-13T05:18:47.098-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="System Admin"/><category scheme="http://www.blogger.com/atom/ns#" term="VBScript"/><title type='text'>VBScript: Shutdown / Reboot workarounds</title><content type='html'>Every now and then I find myself trying to script the silliest things.&lt;br /&gt;
&lt;br /&gt;
I was really annoyed at how when you are using Remote Desktop to connect to a workstation, the Shutdown / Reboot option is replaced by the Disconnect option... I think it&#39;s probably a safe guard, which is nice to have, but I like to have the option.&lt;br /&gt;
&lt;br /&gt;
I created a VBScript on my desktop called Shutdown.vbs; its remarkably simple.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Set OpSysSet = GetObject(&quot;winmgmts:{(Shutdown)}//./root/cimv2&quot;).ExecQuery(&quot;select * from Win32_OperatingSystem where Primary=true&quot;)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
for each OpSys in OpSysSet&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;x = InputBox(&quot;Reboot or Shutdown?&quot;, &quot;Reboot or Shutdown?&quot;, &quot;Shutdown&quot;)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if Left(x, 1) = &quot;R&quot; Then&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;OpSys.Reboot()&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;end if&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if Left(x, 1) = &quot;S&quot; Then&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;OpSys.Shutdown()&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;end if&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
next&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
the section that contains&lt;br /&gt;
x = InputBox(&quot;Reboot or Shutdown?&quot;, &quot;Reboot or Shutdown?&quot;, &quot;Shutdown&quot;)
&lt;br /&gt;
can be modified; if you change the last parameter, you can set it to &quot;Reboot&quot;&lt;br /&gt;
&lt;br /&gt;
like I mentioned, its not overly complicated, but I found it annoying to keep typing&lt;br /&gt;
shutdown -s -t 1 or shutdown -r -t 1&lt;br /&gt;
&lt;br /&gt;
*Note... when showing this to people from a remote location, be sure you really want to shutdown... otherwise you risk taking the walk of shame and force yourself to either call somebody there to turn it back on or do what every System Admin hates doing... get up and do it yourself.&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/8938236432828581957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://randallcummins.blogspot.com/2012/06/vbscript-shutdown-reboot-workarounds.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/8938236432828581957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/8938236432828581957'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/2012/06/vbscript-shutdown-reboot-workarounds.html' title='VBScript: Shutdown / Reboot workarounds'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2618798143602886071.post-622117241042054558</id><published>2012-06-12T11:15:00.003-07:00</published><updated>2012-06-12T11:15:47.744-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="System Admin"/><category scheme="http://www.blogger.com/atom/ns#" term="wmi"/><title type='text'>Python: Preventing an application from exiting.</title><content type='html'>I overheard somebody complaining that a program needs to be &quot;Always open&quot; and that the &quot;Stinkin&#39; Users&quot; always close it causing issues down the line...&lt;br /&gt;
&lt;br /&gt;
This can be really easy to fix... create a watcher with the WMI module for python and when the event is triggered, open the program again... then call the &#39;def&#39; again recursively so the watcher program stays open all the time...&amp;nbsp; I don&#39;t think that&#39;s very clear to them, so I just said I could make something for them.&lt;br /&gt;
&lt;br /&gt;
Heres what it looks like:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&#39;&#39;&#39;&lt;br /&gt;Created on Feb 13, 2012&lt;br /&gt;
@author: rcummins&lt;br /&gt;&#39;&#39;&#39;&lt;br /&gt;import wmi&lt;br /&gt;import subprocess&lt;br /&gt;
def ohnoyoudidnt():&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = wmi.WMI()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; watcher = c.watch_for (&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; notification_type=&quot;Deletion&quot;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wmi_class=&quot;Win32_Process&quot;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay_secs=1,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Name=&quot;application.exe&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; watcher ()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exe_path = r&#39;C:\Program Files\application.exe&#39;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; subprocess.Popen(exe_path)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ohnoyoudidnt()&lt;br /&gt;if __name__ == &#39;__main__&#39;:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ohnoyoudidnt()&lt;/blockquote&gt;
Now you need to get yourself the WMI Module here: &lt;a href=&quot;http://timgolden.me.uk/python/wmi/index.html&quot;&gt;http://timgolden.me.uk/python/wmi/index.html&lt;/a&gt;&lt;br /&gt;
It&#39;s a really awesome module and I have seen Tim Golden&#39;s posts around the web; very helpful.&lt;br /&gt;
&lt;br /&gt;
the Subprocess module is standard so theres nothing to download there...&lt;br /&gt;
&lt;br /&gt;
Hope it helps you out!&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/622117241042054558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://randallcummins.blogspot.com/2012/06/python-preventing-application-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/622117241042054558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/622117241042054558'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/2012/06/python-preventing-application-from.html' title='Python: Preventing an application from exiting.'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2618798143602886071.post-2051144989577975248</id><published>2012-06-11T13:44:00.001-07:00</published><updated>2012-06-11T13:45:02.560-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PowerShell"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="VBScript"/><title type='text'>Moving from VBScript to Python to Java to PowerShell</title><content type='html'>I have always been an idea person.&amp;nbsp; I like the idea of things and if I like the idea so much, I follow through with it.&lt;br /&gt;
&lt;br /&gt;
An example of this is when I was asked to stay for a week during a project go live from 10 pm to 10 am...&amp;nbsp; well I actually almost jumped at the opportunity.&amp;nbsp; I had needed some time to start getting into VBScript since I had little to no experience with programming, I thought it would be a great place to start.&amp;nbsp; Luckily the project go live was very successful and i was not busy by any means.&lt;br /&gt;
&lt;br /&gt;
http://cbtnuggets.com/ has training courses available to view any time so I started there.&amp;nbsp; During that time we had a run in with a pretty &lt;a href=&quot;http://www.symantec.com/security_response/writeup.jsp?docid=2008-112203-2408-99&quot; target=&quot;_blank&quot;&gt;annoying virus&lt;/a&gt;.&amp;nbsp; One thing about this virus... actually its a worm.&amp;nbsp; Anyways, this thing created scheduled tasks to do whatever it was doing.&amp;nbsp; I then used the training videos to help guide me through the process...&amp;nbsp; first it was finding out &quot;What is the scope of the problem?&quot;, then it was &quot;What am I looking for?&quot;&lt;br /&gt;
&lt;br /&gt;
So just moseying along I determined that if I could get a list of computers from Active Directory, I might be able to find out if the scheduled tasks are in the &#39;Tasks&#39; folder...&amp;nbsp; it was a little more tricky than that because we had a mix of Windows 2000 desktops along with XP, but after learning the magical &quot;On Error Resume Next&quot;, I was set.&lt;br /&gt;
&lt;br /&gt;
From then on, I was determined to make scripting / app development a priority.&amp;nbsp; Everyday tasks can be automated.&amp;nbsp; At one point I was picked to create over 150 user accounts in just 3 days.&amp;nbsp; Then I learned this would continue to happen.&amp;nbsp; I needed to learn more.&amp;nbsp; That&#39;s when I remembered that in school we were given an MSDN academy account and Visual Basic 6.0 was part of that.&amp;nbsp; So now I could leverage the power of VBScript and add buttons to it... entry fields... graphics.&lt;br /&gt;
&lt;br /&gt;
I created a password reset utility for our receptionists.&lt;br /&gt;
I created a bulk user account creation form.&lt;br /&gt;
I created a front end for starting stopping services on remote systems.&lt;br /&gt;
&lt;br /&gt;
All along, I had been using Google to get what I need to know.&lt;br /&gt;
&lt;br /&gt;
I was in a Chapters one day looking around and saw a book called Gray hat Python...&amp;nbsp; It looked intimidating.&amp;nbsp; I wanted to know it.&amp;nbsp; I slowly took python in, thinking it was nice but still sticking to my vbscript guns and just feeling out python...&amp;nbsp; I noticed that python had a little section in the CBTnuggets site, so I checked it out and now I, only seldom, go back to VBScript for odds and ends.&lt;br /&gt;
&lt;br /&gt;
There are a lot of modules available for Python... its nearly limitless&lt;br /&gt;
&lt;br /&gt;
I created a banner application that displays messages sent via TCP or UDP. (not in production)&lt;br /&gt;
I created a SQL frontend for our current inventory control system and am linking documentation... make registry changes... yada yada, its very robust.&lt;br /&gt;
&lt;br /&gt;
In an effort to actually make money from learning these things... I decided to try my hand at developing for Android... since its only 25 to sign up for the developer account.&amp;nbsp; Agh, see the problem there... gotta learn Java.&amp;nbsp; Well CBTnuggets offers an intro to Java, so that has gotten my foot in the door.&lt;br /&gt;
&lt;br /&gt;
I created the ohsnAPP Band Name Generator...&amp;nbsp; the free version has 177 downloads so far..&lt;br /&gt;
&lt;br /&gt;
The paid version has 1 download... my brother in law...&amp;nbsp; he didn&#39;t leave any comments..&amp;nbsp; I have to laugh though, I never thought I&#39;d be swimming in the money for developing something that serves no other purpose than making people chuckle.&amp;nbsp; It&#39;s a little disappointing, but the real reward is to be able to say that I published something.&amp;nbsp; It&#39;s also very rewarding to be able to help others accomplish their needs and know that I helped them in some way.&lt;br /&gt;
&lt;br /&gt;
And while I am developing for Android, I am also trying to learn PowerShell... seems like a really interesting tool and I plan on sharing as much as possible with it.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/2051144989577975248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://randallcummins.blogspot.com/2012/06/moving-from-vbscript-to-python-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/2051144989577975248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/2051144989577975248'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/2012/06/moving-from-vbscript-to-python-to.html' title='Moving from VBScript to Python to Java to PowerShell'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2618798143602886071.post-1867713037578577076</id><published>2012-06-11T12:03:00.001-07:00</published><updated>2012-06-11T12:09:38.364-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="System Admin"/><category scheme="http://www.blogger.com/atom/ns#" term="VBScript"/><title type='text'>VBScript:  Alert system for certificates that will expire in &#39;n&#39; days.</title><content type='html'>One day, an individual was called at... oh lets say 3 in the morning, because some certificates which were not set to auto renew and the outlook reminder was never set to tell him or her that the certificates were going to expire.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;This could have been avoided by preparing a scheduled task to help alert the Computer System Technician of the upcoming demise and prompt them to take action 5, 10, 30, 60 days before the certs expired.&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
I did a bit of research to help the person out... no it was not me called at 3am, thankfully!&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
Breaking the VBScript into parts helps out a lot... portability is key when it comes to any scripting language.&amp;nbsp; I do not have any formal education when it comes to programming, however I do have a lot of confidence in two things... Trial and Error... and Google.&lt;br /&gt;
&lt;br /&gt;
One part of this overall task is the alerting piece.... yes, standard email will do the trick.&amp;nbsp; I already had something I had used this for anyhow and its a pretty standard piece of code that sys admins should have readily available.&amp;nbsp; The below code is derived from &lt;a href=&quot;http://www.paulsadowski.com/wsh/cdo.htm&quot;&gt;http://www.paulsadowski.com/wsh/cdo.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Sub EMAIL(mailto,txtbody)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objMessage = CreateObject(&quot;CDO.Message&quot;) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; objMessage.Subject = &quot;Certificates are expiring soon...&quot; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; objMessage.From = &quot;CertificateAuthorityExpirations@work.com&quot; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; objMessage.To = mailto&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; objMessage.TextBody = txtbody&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; objMessage.Configuration.Fields.Item _&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&quot;http://schemas.microsoft.com/cdo/configuration/sendusing&quot;) = 2 &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; objMessage.Configuration.Fields.Item _&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&quot;http://schemas.microsoft.com/cdo/configuration/smtpserver&quot;) = &quot;exchange.server.dot.com&quot;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; objMessage.Configuration.Fields.Item _&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&quot;http://schemas.microsoft.com/cdo/configuration/smtpserverport&quot;) = 25 &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; objMessage.Configuration.Fields.Update&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; objMessage.Send&lt;br /&gt;END SUB&lt;/blockquote&gt;
The next part is derived from &lt;a href=&quot;http://blogs.msdn.com/b/spatdsg/archive/2007/07/19/notify-users-of-cert-expiration.aspx&quot;&gt;http://blogs.msdn.com/b/spatdsg/archive/2007/07/19/notify-users-of-cert-expiration.aspx&lt;/a&gt;&amp;nbsp; and modified to meet my needs...&amp;nbsp; so you can add any arguments you want like number of days to check for... also maybe who you want the email to go to.&amp;nbsp; Like I mentioned before portability is a sys admins best friend.&amp;nbsp; Along with documentation... but... like I said, I don&#39;t have any formal programming education, so that&#39;s my excuse for not commenting my code enough ;)&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Const CV_OUT_BASE64 = &amp;amp;H1&lt;br /&gt;Const DUMMY_CERT = &quot;modifiable cert to exclude&quot;&amp;nbsp; &#39;&amp;lt;== I used this part to skip common certs that all desktops use, because they auto renew anyways and nothing will go down if they are expired&lt;br /&gt;&lt;br /&gt;&#39; Setup arguments if there are any....&lt;br /&gt;SET Args = WScript.Arguments&lt;br /&gt;&lt;br /&gt;If WScript.Arguments.Count = 1 Then&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39; This part can be modified to something hard coded &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mailto = Args.Item(0)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39; definitely up to you though.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; limit = 60&lt;br /&gt;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; limit = 60&amp;nbsp;&amp;nbsp; &#39; &amp;lt;-- number of days to check for...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mailto = &quot;system_admin@work.com&quot;&lt;br /&gt;End if&lt;br /&gt;&#39;Log it...&lt;br /&gt;Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)&lt;br /&gt;SET writeFile = objFSO.OpenTextFile(&quot;Certificates.log&quot;, 2, True)&amp;nbsp; &#39;&amp;lt;-- just creates a new log every time... you can set it to append if you want.&lt;br /&gt;&lt;br /&gt;&#39;THIS IS THE &amp;lt;Machinename&amp;gt;\CAName&lt;br /&gt;CAName = &quot;domain_controller.work.int\WORK&quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;=======&amp;gt;&amp;gt; CHANGE THIS TO THE CORRECT MACHINE\CA==&lt;br /&gt;&lt;br /&gt;&#39;create the CAView object&lt;br /&gt;set oCAView = CreateObject(&quot;CertificateAuthority.View&quot;)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&#39;open the connection to the Machine\CA&lt;br /&gt;oCAView.OpenConnection (CAName)&lt;br /&gt;&lt;br /&gt;&#39;retrieve specific columns from DB&amp;nbsp; (This part took me awhile to figure out the field names...)&lt;br /&gt;oCAView.SetResultColumnCount(4) &lt;br /&gt;Index0 = oCAView.GetColumnIndex(False, &quot;CommonName&quot;)&amp;nbsp; &lt;br /&gt;Index1 = oCAView.GetColumnIndex(False, &quot;NotAfter&quot;) &lt;br /&gt;Index2 = oCAView.GetColumnIndex(False, &quot;SerialNumber&quot;) &lt;br /&gt;Index3 = oCAView.GetColumnIndex(False, &quot;CertificateTemplate&quot;) &lt;br /&gt;oCAView.SetResultColumn (Index0) &lt;br /&gt;oCAView.SetResultColumn (Index1) &lt;br /&gt;oCAView.SetResultColumn (Index2) &lt;br /&gt;oCAView.SetResultColumn (Index3) &lt;br /&gt;&#39;open the view&lt;br /&gt;Set RowObj= oCAView.OpenView&lt;br /&gt;&lt;br /&gt;txtbody = &quot;&quot;&lt;br /&gt;&lt;br /&gt;on error resume next&lt;br /&gt;Do Until RowObj.Next = -1 &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; Set ColObj = RowObj.EnumCertViewColumn()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; x = &quot;&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until ColObj.Next = -1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = x + Cstr(ColObj.GetValue(CV_OUT_BASE64))+&quot;,&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if Left(x, 1) &amp;lt;&amp;gt; &quot; &quot; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; items = split(x,&quot;,&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Machine = items(0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Expires = items(1)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Subject = items(2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Info = items(3)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if Info &amp;lt;&amp;gt; DUMMY_CERT then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; edate = cdate(Expires)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; odate = Date&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; blarg = DateDiff(&quot;y&quot;, edate, odate)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if blarg &amp;lt; 0 then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if abs(blarg) &amp;lt; limit then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; difference = Abs(DateDiff(&quot;y&quot;, edate, odate)) &amp;amp; &quot; Days until it expires!&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeFile.writeline(Machine &amp;amp; &quot;,&quot; &amp;amp; difference &amp;amp; &quot;,SerialNumber: &quot; &amp;amp; Subject &amp;amp; &quot;,CertificateTemplate: &quot; &amp;amp; Info)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; txtbody = txtbody + &quot;Certificate for: &quot;&amp;amp; Machine &amp;amp; &quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Has Only: &quot; &amp;amp; difference &amp;amp; vbcrlf &amp;amp; vbcrlf &amp;amp; _&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;CA Details;&quot; &amp;amp; vbcrlf &amp;amp; &quot;SerialNumber: &quot; &amp;amp; Subject &amp;amp; vbcrlf &amp;amp; &quot;CertificateTemplate: &quot; &amp;amp; Info &amp;amp; _&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; vbcrlf &amp;amp; &quot;=======================&quot; &amp;amp; vbcrlf &amp;amp; vbcrlf&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; end if&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; end if&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; end if&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end if&lt;br /&gt;&amp;nbsp; Set ColObj = Nothing&lt;br /&gt;&lt;br /&gt;Loop&lt;br /&gt;call EMAIL(mailto,txtbody)&amp;nbsp;&amp;nbsp; &#39;&amp;lt;-- this is the SUB i mentioned earlier... cdo send method&lt;br /&gt;writeFile.Close&lt;br /&gt;&lt;/blockquote&gt;
There is a lot going on it there, but its not hard to pick out what needs to change.&amp;nbsp; The domain controller&lt;br /&gt;
I found from the command line using the certutil exe found in system32...&amp;nbsp; I don&#39;t recall the actual command, but I&#39;m sure its not hard to find on the &lt;a href=&quot;http://technet.microsoft.com/en-us/library/c264ccf0-ba1e-412b-9dd3-d77dd9345ad9&quot; target=&quot;_blank&quot;&gt;msdn site...&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Hopefully this has been informative and takes you all less time than it took me ;)&lt;br /&gt;
&lt;br /&gt;
Happy testing/fixing/administering&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/1867713037578577076/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://randallcummins.blogspot.com/2012/06/vbscript-alert-system-for-certificates.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/1867713037578577076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/1867713037578577076'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/2012/06/vbscript-alert-system-for-certificates.html' title='VBScript:  Alert system for certificates that will expire in &#39;n&#39; days.'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2618798143602886071.post-77594677798845493</id><published>2012-06-07T11:42:00.003-07:00</published><updated>2012-06-11T12:09:46.717-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PowerShell"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="System Admin"/><title type='text'>PowerShell: Email me my EventLog, Please.</title><content type='html'>Today at work I decided to try my hand at PowerShell a little bit.&lt;br /&gt;
&lt;br /&gt;
I DO like it... it&#39;s a little tricky to learn any new language, but it is really powerful.&lt;br /&gt;
&lt;br /&gt;
I have a Server (Windows Server 2003...) and occasionally something happens when a process crashes.&amp;nbsp; Based on that... I thought maybe I could setup some sort of means for reporting to my email (which coincidently, I get my work email on my phone... so voila..)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Heres what I used..&amp;nbsp; and its all under 15 lines of code... some good potential here&lt;br /&gt;
&lt;br /&gt;
----------------------------&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;background-color: black; color: lime;&quot;&gt;
$FROM = &quot;SERVER@work.com&quot;&lt;br /&gt;$TO = &quot;RCUMMINS@WORK.COM&quot;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;background-color: black; color: lime;&quot;&gt;
$SMTP_Server = &quot;Exchange.Dot.Com&quot;&lt;/div&gt;
&lt;div style=&quot;background-color: black; color: lime;&quot;&gt;
$smtp = New-Object Net.Mail.SmtpClient($SMTP_Server)&lt;/div&gt;
&lt;div style=&quot;background-color: black; color: lime;&quot;&gt;
$SUBJECT = &quot;Server Health Report&quot;&lt;/div&gt;
&lt;div style=&quot;background-color: black; color: lime;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: black; color: lime;&quot;&gt;
$x = Get-EventLog &quot;Application&quot; -EntryType &#39;Error&#39; -After (Get-Date).addHours(-1) |&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;background-color: black; color: lime;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Where-Object {$_.Source -eq &#39;Application Hang&#39;}&lt;/div&gt;
&lt;div style=&quot;background-color: black; color: lime;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: black; color: lime;&quot;&gt;
if($x)&lt;/div&gt;
&lt;div style=&quot;background-color: black; color: lime;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;background-color: black; color: lime;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $xx = $x | select TimeGenerated, Message | Out-String&lt;/div&gt;
&lt;div style=&quot;background-color: black; color: lime;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $smtp.Send($FROM, $TO, $SUBJECT, $xx) &lt;/div&gt;
&lt;span style=&quot;background-color: black; color: lime;&quot;&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;/blockquote&gt;
---------------------------&lt;br /&gt;
&lt;br /&gt;
So to setup the scheduled task... I just had to do a quick google for the hidden window option...&lt;br /&gt;
&lt;br /&gt;
---------------------------&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;br /&gt;&lt;span style=&quot;background-color: black; color: lime;&quot;&gt;C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle 
&quot;Hidden&quot; -Command &quot;.&#39;C:\Path\To\Scripts\Process Checking.ps1&#39;&quot;&lt;/span&gt; &lt;/blockquote&gt;
---------------------------&lt;br /&gt;
&lt;br /&gt;
That was enjoyable.</content><link rel='replies' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/77594677798845493/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://randallcummins.blogspot.com/2012/06/powershell-email-me-my-eventlog-please.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/77594677798845493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/77594677798845493'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/2012/06/powershell-email-me-my-eventlog-please.html' title='PowerShell: Email me my EventLog, Please.'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2618798143602886071.post-6745433813936230312</id><published>2012-06-07T05:19:00.001-07:00</published><updated>2012-06-11T12:03:44.095-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Python: Scraping Ebay for Prices</title><content type='html'>I created a tool to search Ebay.ca for the values of baseball cards... you can actually search whatever you want with it, but I thought it was clever at the time... (01:00am)&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/goog_676503144&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://skydrive.live.com/?cid=5e41638777156ad2&amp;amp;Bsrc=Share&amp;amp;Bpub=SDX.SkyDrive&amp;amp;sc=Documents&amp;amp;resid=5E41638777156AD2%21110&amp;amp;id=5E41638777156AD2%21110&quot; target=&quot;_blank&quot;&gt;Card Collector&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Here&#39;s the path and the source for it is saved there as well... written in Python, enjoy!</content><link rel='replies' type='application/atom+xml' href='http://randallcummins.blogspot.com/feeds/6745433813936230312/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://randallcummins.blogspot.com/2012/06/i-created-tool-to-search-ebay.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/6745433813936230312'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2618798143602886071/posts/default/6745433813936230312'/><link rel='alternate' type='text/html' href='http://randallcummins.blogspot.com/2012/06/i-created-tool-to-search-ebay.html' title='Python: Scraping Ebay for Prices'/><author><name>Randall.Cummins</name><uri>http://www.blogger.com/profile/12223802221887912503</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsJP92MbPMG5e1UY0amha-xFGbwKEhv7Kn99uY5rCFPFRwlQx2FJ5D5Tnwp0DZTQ77Rvj2MUTJ1uv4NEwPzjGFwB6rEXWVWjbPHSxqZyTmcZt_HeNjbQPibkEL5VuGS_s/s1600/14340_218490171154_5165236_n.jpg'/></author><thr:total>0</thr:total></entry></feed>