tag:blogger.com,1999:blog-64748270984890775552024-02-07T04:11:25.023-05:00The Scripting Adminncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.comBlogger28125tag:blogger.com,1999:blog-6474827098489077555.post-57420349957209021242019-05-30T22:00:00.000-04:002019-06-06T10:40:53.622-04:00WSUS cleaning wizard fails 'Database Error'If while running the WSUS cleaning wizard you get a Database error that looks like this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSW8bXhsDz_Efy4HYATfHvhOUIit4hnv-0q4080fD8XNhGqGBcQ_NjDvUJBwMdx7G1i86F6vY2cC3TFTHd0JvHMNJzKiIIN-hBK8w25fmctcrXF8rrSyKqjKaHRtSMnSlBggb0rDEzH8vv/s1600/wsus-db-error.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="182" data-original-width="821" height="70" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSW8bXhsDz_Efy4HYATfHvhOUIit4hnv-0q4080fD8XNhGqGBcQ_NjDvUJBwMdx7G1i86F6vY2cC3TFTHd0JvHMNJzKiIIN-hBK8w25fmctcrXF8rrSyKqjKaHRtSMnSlBggb0rDEzH8vv/s320/wsus-db-error.PNG" width="320" /></a></div>
<br />
You could reboot the server that WSUS is running on, but if it's used for other things also (e-mail, dhcp, dns, file, printing, etc...), you'll have to wait till there's downtime, before trying again.<br />
<br />
Another option though is to restart the database service.<br />
If you go to administrative tools -> services (or runbox services.msc), look for 'Windows Internal Database" and right click on it, and select restart<br />
<br />
or from an admin command prompt:<br />
sc stop mssql$microsoft##wid<br />
sc start mssql$microsoft##wid<br />
<br />
Then go back to the wsus management console, click on reset server node, and you should now be able to run the cleaning wizard (it'll probably take a couple hours or more, but it shouldn't give you an error),<br />
<br />
And you were able to do this without interrupting whatever else may be running on it.<br />
<br />
<br />
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-51625910306382754532015-09-21T15:04:00.000-04:002015-09-21T15:04:41.110-04:00Firefox freezing on linux (x2go)Not scripting related however: <br />
I am using x2go to access my linux (ubuntu) system remotely, using the kdeWM. If I use firefox though, the moment I right click anywhere on a web page (say to open a link in a new tab or window), firefox freezes. <br />
<br />
Turns out it's an issue with the pulse audio daemon, and at least if you're using x2go like me, it's easy to fix once you know what the problem is. <br />
<br />
When disconnected from your linux server, in the x2go client, go into the session preferences, click on the Media tab -> and uncheck "Enable sound support". Selecting esd might also fix it, but I haven't tried that. <br />
<br />
Many thanks to the comment by oms-ubun at: <a href="https://bugs.launchpad.net/ubuntu/+source/firefox-3.0/+bug/528798">https://bugs.launchpad.net/ubuntu/+source/firefox-3.0/+bug/528798</a> for directing me to the issue. <br />
<br />
<br />
<br />
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com1tag:blogger.com,1999:blog-6474827098489077555.post-29922844041140118422015-03-24T22:00:00.000-04:002015-03-25T11:11:45.474-04:00linux (fedora) how to change your screen resolutionThe following are intended for when you're using a virtual machine (proxmox host in my case), and the resolution is too high for your 1080p laptop screen that you're using to manage the VMs remotely. <br />
However these methods will probably work with a physical linux installation also (not just a virtual one). <br />
<br />
<br />
As of 2015 the following method worked for me on Fedora 21 (server version):<br />
Edit the following file with your favorite text editor (mine is VIM): /etc/default/grub<br />
find the line starting with: GRUB_CMDLINE_LINUX=<br />
and put at the end: video=800x600" <br />
when you're done the line should look something like:<br />
GRUB_CMDLINE_LINUX="rd.lvm.lv=fedora-server/root rd.lvm.lv=fedora-server/swap rhgb quiet video=800x600"<br />
<br />
note: instead of 800x600 you can use, 640x480 or 1024x768 also<br />
<br />
sources: <br />
https://fedoraproject.org/wiki/Display_resolution_of_Fedora_18_virtual_machines<br />
https://fedoraproject.org/wiki/GRUB_2?rd=Grub2<br />
<br />
<br />
To change the resolution off X-windows (xorg),<br />
xrandr --output VGA-0 --mode 800x600<br />
-if you have any errors type xrandr by itself, (and hit enter), and you will see a list of available outputs and the list of modes for each one:<br />
source: https://wiki.archlinux.org/index.php/xrandr<br />
<br />
<br />
edit: below is my original method, which newer versions of fedora (as of 2015/ fedora 21) doesn't appear to work very well.<br />
<br />
If you're running fedora in a virtual machine (proxmox, vmware, virtualbox), and the screen resolution of fedora in console mode (not X), is so high that it takes up your entire screen you can change it using fbset. <br />
<br />
If you don't have fbset, first you'll have to install it "sudo yum install fbset"<br />
<br />
Then you can change the resolution with the following:<br />
sudo fbset -xres 800 -yres 600<br />
(can use 1024 768, or other resolutions also). <br />
<br />
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-80069784838582191422014-11-05T20:55:00.000-05:002014-11-05T20:55:09.414-05:00chrome for enterprise auto downloadIn a work environment normally you want to download one copy of an update to one computer, and then copy it to the rest of the computers. This way you don't clog up your office's internet connection. While proxys can work, they are often tricky to configure. <br />
<br />
Google has a version of chrome that will install for all users on a computer, that you can manage (like disable group updates, and configure some other settings). Details are at: <a href="http://wpkg.org/Google_Chrome">http://wpkg.org/Google_Chrome</a>. They also have a script that will download proper version of chrome and rename it so you can deploy it using a tool to the computers in your enterprise (which is designed to work with their deployment tool but I made it work with some slight modifications). <br />
<br />
Chrome has an rss feed at <a href="http://googlechromereleases.blogspot.com/">http://googlechromereleases.blogspot.com/</a> which will notify you when there's an update. While you could check it every day, how likely are you going to miss the day it came out, and then end up either downloading it during the day (clogging people's bandwidth), or waiting another day to schedule the download? <br />
Below is my batch script for checking the rss feed, and if it sees there's an updated chrome, will call a script that download it automatically. <br />
<br />
Now when you see there's a new version of chrome, it's already downloaded (if you scheduled the checking script to run every night). I then create a package using local update publisher or wsus package publisher. <br />
<br />
<br />
rem -----------------------------------------------------------------------------------------------<br />
@echo off<br />
set updatesloc=\\server\share\folder\google-chrome<br />
rem set debug=1 if you have any problems. <br />
set debug=0<br />
if %debug%==1 echo grabbing the feed at %time%<br />
wget http://googlechromereleases.blogspot.com/ -O %temp%\chrome-updates-feed.html<br />
rem searching the feed for the current chrome version, and breaking out as soon as we<br />
rem find the first one (that's not for chrome OS).<br />
<br />
if %debug%==1 echo searching the downloaded feed for the current version at %time%<br />
for /f "tokens=8" %%v in ('find /i "The stable channel has been updated to " %temp%\Chrome-updates-feed.html ^|find /v "Chrome OS"') do (<br />
set curver=%%v<br />
goto endverfind<br />
)<br />
:endverfind<br />
<br />
if %debug%==1 echo searching the directory of downloaded updates to see if we already have the current version %time%<br />
rem if the curver string length is less then three characters it's probably not valid.<br />
rem google uses very long version numbers like: 38.0.2125.111<br />
if "%curver:~3,1%"=="" goto end<br />
<br />
for /f "tokens=1" %%d in ('dir /s /b %updatesloc% ^|find /c "%curver%"') do set curverdownloaded=%%d<br />
if %debug%==1 echo search complete now to figure out what to do %time%<br />
if %curverdownloaded%==0 goto downloadnewver<br />
if %curverdownloaded%==0 goto gotcurver<br />
<br />
:gotcurver<br />
echo got the current version, %curver% nothing to do<br />
goto end<br />
<br />
:downloadnewver<br />
echo need to download the newest version %curver%, at %time%<br />
c:\windows\syswow64\cscript.exe %updatesloc%\update-chrome.vbs<br />
goto end<br />
<br />
:end<br />
echo %time%<br />
rem -------------------------------------------------------------------<br />
<br />
<br />
my modified download vbscript (based heavily on the script at http://wpkg.org/Google_Chrome)<br />
make sure you've downloaded dsofile<br />
<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9ba6fac6-520b-4a0a-878a-53ec8300c4c2&DisplayLang=en">www.microsoft.com/downloads/details.aspx?FamilyID=9ba6fac6-520b-4a0a-878a-53ec8300c4c2&DisplayLang=en</a><br />
and that you have wget in your path, wget is needed for the batch file above also.<br />
<a href="http://gnuwin32.sourceforge.net/packages/wget.htm">http://gnuwin32.sourceforge.net/packages/wget.htm</a><br />
<br />
<br />
'------------------------------------------------------------------------<br />
' update-chrome.vbs -- stored in %updatesloc%\google-chrome<br />
'from http://wpkg.org/Google_Chrome<br />
Option Explicit<br />
Dim objFSO, objFile, strFileProperties, objShell, strChromePath, strChromeURL<br />
Dim strVersion, objResult, strChromeFilename, objOleFile, arrComments<br />
Dim strTemplateFilename, ForReading, ForWriting, strText<br />
Dim strNewText<br />
<br />
strChromePath = "j:\patches\google-chrome\"<br />
'strChromePath = "c:\downloads\"<br />
strChromeFilename = "GoogleChromeStandaloneEnterprise.msi"<br />
strTemplateFilename = "google-chrome-template.xml"<br />
strChromeURL = "https://dl.google.com/edgedl/chrome/install/" & _<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>strChromeFilename<br />
<br />
Set objShell = CreateObject("WScript.Shell")<br />
Set objFSO = CreateObject("Scripting.FileSystemObject")<br />
Set objOleFile = CreateObject("DSOFile.OleDocumentProperties")<br />
<br />
objShell.CurrentDirectory = strChromePath<br />
' wget downloaded from http://users.ugent.be/~bpuype/wget/<br />
objResult = objShell.Run("wget --limit-rate=200k --no-check-certificate " & strChromeURL, 1, True)<br />
If objFSO.FileExists(strChromePath & strChromeFilename) Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Grab version number. Requires Office installation, or DSOFile.dll<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' from http://support.microsoft.com/kb/224351<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objOleFile.Open(strChromePath & strChromeFilename)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>arrComments = Split(objOleFile.SummaryProperties.Comments, " ", 2)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>strVersion = arrComments(0)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objOleFile.Close<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Make a copy of the file<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Set objFile = objFSO.GetFile(strChromePath & strChromeFilename)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFile.Copy strChromePath & "GoogleChromeStandaloneEnterprise-" & _<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>strVersion & ".msi", True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Delete the original file<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFile.Delete True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Update package definitions<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>updateXML strTemplateFilename, _<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>"..\..\packages\google-chrome.xml" ' legacy tree<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>updateXML strTemplateFilename, _<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>"..\..\dev\packages\google-chrome.xml" ' dev tree<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>updateXML strTemplateFilename, _<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>"..\..\stable\packages\google-chrome.xml" ' stable tree<br />
Else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>MsgBox "Selected file does not exist!"<br />
End If<br />
<br />
'Sub updateXML(strTemplateFilename, strPackageFilename)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Update package definition<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>ForReading = 1<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>ForWriting = 2<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>Set objFile = objFSO.OpenTextFile(strTemplateFilename, ForReading)<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>strText = objFile.ReadAll<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>objFile.Close<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>strNewText = Replace(strText, "__VERSION__", strVersion)<br />
'<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>Set objFile = objFSO.OpenTextFile(strPackageFilename, ForWriting)<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>objFile.WriteLine strNewText<br />
'<span class="Apple-tab-span" style="white-space: pre;"> </span>objFile.Close<br />
'End Sub<br />
'-----------------------------------------------------------------------------ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-54633990651556405572014-08-07T19:30:00.000-04:002014-09-02T10:32:39.576-04:00finding your interface name for netshHow to find the name of your interface for netsh.<br />
<br />
In a previous post I had a ip changing script that used netsh to change the ip addresses. <br />
The main syntax being: "netsh interface ip set address "Local Area Connection" static 192.168.1.53 255.255.255.0 192.168.1.1 1<br />
<br />
However in windows 8, there are two issues:<br />
1) you now have to use ipv4 instead of ip,<br />
2) my previous method of using ipconfig to find the name of the network connection to use, doesn't work.<br />
<br />
For the second issue I would get the error: "The filename, directory name, or volume label syntax is incorrect." <br />
<br />
To find the correct name for your connection (where it says "Local Area Connection" above), type in:<br />
netsh interface show interface<br />
This will list the currently enabled interfaces, which hopefully will include the one you're trying to mess with. If the one you want isn't listed, make sure it's associated with a wireless network (if it's the Wi-Fi interface), or the network cable is plugged in if it's a wired interface.<br />
<br />
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-89505583689538648552014-01-23T22:33:00.000-05:002014-01-23T22:33:05.308-05:00windows ip switcherWhere I work, I support multiple offices. Most of the offices do not have DHCP, they use static ip addresses (not my decision). So here is a script I made for changing the ip address settings on a windows laptop, this does have to be ran with full admin privileges. You will have to change parts of this script for your usage (where ever you see an ip address, and probably want to change the labels for the networks also). <br />
<br />
echo ip-switch ver 20081119<br />
<br />
set baseoffice=hq<br />
<br />
rem now we figure out what subnet we're on<br />
for /f "tokens=2 delims=:" %%i in ('ipconfig ^|find "IP Address"') do set ipaddr=%%i<br />
for /f "tokens=2,3 delims=." %%o in ('echo %ipaddr%') do set subnet=%%o.%%p<br />
<br />
<br />
rem based on the sub-net we determine what our location is<br />
if /i "%subnet%" == "10.10" set loc=hq<br />
if /i "%subnet%" == "10.11" set loc=sub<br />
if /i "%subnet%" == "11.11" set loc=b1<br />
if /i "%subnet%" == "11.12" set loc=b2<br />
if "%loc%" == "hq" set comploc=acompanyoffice<br />
if "%loc%" == "substation" set comploc=acompanyoffice<br />
if "%loc%" == "branch1" set comploc=acompanyoffice<br />
if "%loc%" == "branch2" set comploc=acompanyoffice<br />
if "%comploc%" == "acompanyoffice" goto comploc<br />
set comploc=remote<br />
:comploc<br />
<br />
<br />
echo off<br />
<br />
:complocmenu<br />
cls<br />
if "%comploc%" == "acompanyoffiice" echo this computer is currently setup for %comploc% (%loc%) use<br />
if "%comploc%" == "remote" echo this computer is currently setup for %comploc% use<br />
echo where is this laptop now (so it can communicate with the internet)?<br />
echo 1) your base office (%baseoffice%)<br />
echo 2) remote, home/other office<br />
echo x) exit (leave everything as it is)<br />
echo if another office enter the two-three letter abbreviation for it,<br />
echo (hq,sub,b1,b2,etc...), and press enter, otherwise,<br />
set /p comploc=press 1,2 or x and then enter:<br />
rem if we entered a correct choice go to the next menu<br />
if "%comploc%" == "1" goto methodmenu<br />
if "%comploc%" == "2" goto methodmenu<br />
if "%comploc%" == "x" echo no changes will be made<br />
if /i "%comploc%" == "x" goto endprog<br />
if /i "%comploc%" == "hq" goto otheroffice<br />
if /i "%comploc%" == "sub" goto otheroffice<br />
if /i "%comploc%" == "b1" goto otheroffice<br />
if /i "%comploc%" == "b2" goto otheroffice<br />
<br />
<br />
cls<br />
rem if we entered a wrong chose clear screen of distraction<br />
rem and ask for correct input<br />
echo "you must press 1 or 2, or just press enter"<br />
goto complocmenu<br />
<br />
:otheroffice<br />
set baseoffice=%comploc%<br />
goto methodmenu<br />
<br />
:methodmenu<br />
echo is the laptop plugged in or using wireless?<br />
echo 1) plugged in<br />
echo 2) wireless<br />
echo x) endprog<br />
set /p netmethod=press 1 or 2 and then press enter<br />
<br />
if "%netmethod%" == "1" set conmethod="Local Area Connection"<br />
if "%netmethod%" == "2" set conmethod="Wireless Network Connection"<br />
if "%netmethod%" == "1" goto methodselected<br />
if "%netmethod%" == "2" goto methodselected<br />
if "%netmethod%" == "x" goto endprog<br />
echo "incorrect method selected"<br />
goto methodmenu<br />
:methodselected<br />
<br />
<br />
if "%comploc%" == "1" goto staticip<br />
if "%comploc%" == "2" goto dhcpip<br />
<br />
:staticip<br />
echo we will configure the computer for jcc office use<br />
rem goto endprog<br />
rem remove the goto endprog when we fix these settings<br />
rem set static ip address (needs to be edited)<br />
<br />
for /f "tokens=1 delims=-" %%I in ('echo %baseoffice%') do set loc=%%I<br />
for /f "tokens=2 delims=-" %%C in ('hostname') do set compip=%%C<br />
echo computer ip is %compip%<br />
<br />
if /i "%baseoffice%" == "h1" set netaddr=10.10.10<br />
if /i "%baseoffice%" == "sub" set netaddr=10.10.11<br />
if /i "%baseoffice%" == "b1" set netaddr=10.11.11<br />
if /i "%baseoffice%" == "b2" set netaddr=10.11.12<br />
<br />
<br />
<br />
<br />
echo network address is %netaddr%<br />
<br />
rem netsh interface ip set address "Local Area Connection" static %netaddr%.%compip% 255.255.255.0 %netaddr%.1 1<br />
rem netsh interface ip set dns "Local Area Connection" static 10.91.1.21<br />
rem netsh interface ip set wins "Local Area Connection" static 204.130.253.130<br />
netsh interface ip set address %conmethod% static %netaddr%.%compip% 255.255.255.0 %netaddr%.1 1<br />
netsh interface ip set dns %conmethod% static 10.91.1.21<br />
netsh interface ip set wins %conmethod% static 10.254.2.130<br />
rem start /wait sysdm.cpl<br />
<br />
goto endprog<br />
<br />
<br />
:dhcpip<br />
rem some netsh commands to set dhcp on the interface<br />
netsh interface ip set address name=%conmethod% source=dhcp<br />
netsh interface ip set dns name=%conmethod% source=dhcp<br />
netsh interface ip set wins name=%conmethod% source=dhcp<br />
goto endprog<br />
<br />
:endprog<br />
hostname<br />
for /f "tokens=2 delims=:" %%i in ('ipconfig ^|find "Default Gateway"') do set gateway=%%i<br />
ipconfig |find "Address"<br />
ping %gateway%<br />
echo if you got back replys your good, if any of the requests timed out that's not good. <br />
pausencc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-20059219268089914552013-12-12T19:00:00.000-05:002014-01-23T22:33:23.766-05:00change system SQL database connectionIn windows you can create a database connection for your front end program to use. Well as with all things in life things change, you decide to get a new database server, you messed up on the initial imaging of the workstations, you decided to expand or consolidate your database servers. Instead of having to go around to each desktop and dig through control panel on each one to edit the database connection, here's a script to change the server.<br />
<br />
This does not create a new database connection on each computer, for that you'll probably want to do configuration through control panel on one of the computers and then export it out the HKLM\SOFTWARE\Wow6432Node\ODBC\ODBC.INI or HKLM\SOFTWARE\ODBC\ODBC.INI keys to a file. <br />
<br />
If your database is something other then CMS you'll need to change the key path referenced below. <br />
<br />
<br />
<br />
<br />
@echo off<br />
if "%1" == "" goto needarguments<br />
for /f "tokens=2" %%W in ('date /t') do set dater=%%W<br />
for /f "tokens=1-3 delims=/" %%d in ('echo %dater%') do set curdate=%%f%%d%%e<br />
rem what we're changing the CMS database server to. <br />
set dsnserver=newprod<br />
<br />
<br />
<br />
:nextcomp<br />
set remotecomp=%1<br />
rem need to do some ping checks and stuff<br />
echo updating %1 at %time%<br />
<br />
<br />
for /f "tokens=2 skip=1 delims==" %%q in ('ping -n 1 %1') do set pingtimer=%%q<br />
for /f "tokens=1 delims=m" %%s in ('echo %pingtimer%') do set pingtime1=%%s<br />
<br />
<br />
if "%pingtime1%" == "1 Received " set pingtime1=down<br />
if "%pingtime1%" == "down" echo %1 down at %date% %time% >> pc-down-dsn-%curdate%.lst<br />
if "%pingtime1%" == "down" goto thiscompfinished<br />
<br />
<br />
<br />
rem this works only if changing the server, if no dsn/odbc connection is <br />
rem yet set up, you'll need to add more registry keys then just this one. <br />
rem echo on<br />
if exist \\%1\c$\windows\syswow64 reg add "\\%1\HKLM\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\CMS" /v Server /t reg_sz /d %dsnserver% /f<br />
if not exist \\%1\c$\windows\syswow64 reg add "\\%1\HKLM\SOFTWARE\ODBC\ODBC.INI\CMS" /v Server /t reg_sz /d %dsnserver% /f<br />
if errorlevel 1 echo %1 had error updating dsn on %date% %time% >> pc-error-dsn-%curdate%.lst<br />
if errorlevel 0 echo %1 updated dsn to %dsnserver% on %date% %time% >> pc-fixed-dsn-%curdate%.lst<br />
echo off<br />
<br />
<br />
:thiscompfinished<br />
shift<br />
if not "%1" == "" goto nextcomp<br />
echo finished at %date% %time%<br />
goto end<br />
<br />
<br />
<div>
:needarguments<br />
echo usage: %0 comp1 comp2 comp3 etc...<br />
echo make sure to not use any \\<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
:end</div>
ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-1179785525856592112013-12-09T19:00:00.000-05:002014-02-14T08:37:18.284-05:00IE Tracking protection listsWhere I'm at we have a web filtering device that will display a full pdf with the employer's terms of service if you go to a website we have blocked. Problem is one of those is facebook, and if you go to say a news site and it has a facebook like button, the news site isn't blocked, but you still get a huge pdf file come up on your screen.<br />
<br />
Thankfully if you're running a newer version of Internet Explorer, there is a feature called "Tracking Protection Lists", while meant to improve your privacy, they can also disable the facebook "like" button that you find on many websites. Problem is digging through all of IE's settings can be a pain. So here is a simple internal web page for users to go to load the page (just have to click a button on the page). <br />
<br />
note: If you're using IIS to serve this you will need to go into the server's "MIME Types" and add<br />
the .tpl extension. I labeled it as "application/ie", IIS apparently won't serve unknown MIME types. <br />
<br />
First file is the tracking protection list file that we want IE to load. <br />
#------------------don't include this line in facebook-block.tpl ---------------------------<br />
msFilterList<br />
: Expires = 5<br />
# blocked strings<br />
- like.php<br />
# domain rules<br />
-d facebook.com<br />
-d facebook.net<br />
# from http://anglachelg.blogspot.com/2011/04/create-your-own-tpl-for-ie9.html<br />
#------------------don't include this line in facebook-block.tpl ---------------------------<br />
<div>
<br /></div>
------index.html --- don't include this line ---------------------<br />
<!DOCTYPE html /><br />
<html ><br />
<head><br />
<!--- from http://msdn.microsoft.com/en-us/library/hh273399%28v=vs.85%29.aspx --><br />
<title>Internet Explorer 9 Tracking Protection list loader</title><br />
<script type="text/javascript"><br />
<br />
function checkTP() {<br />
//checks whether Tracking Protection has been enabled (any list is on)<br />
if (window.external.msTrackingProtectionEnabled())<br />
{<br />
document.getElementById("results").innerHTML = "Tracking protection is: ON";<br />
} else {<br />
document.getElementById("results").innerHTML = "Tracking protection is: OFF";<br />
}<br />
}<br />
<br />
//loads a list specified by input field<br />
function loadTPFile() {<br />
var URL = document.getElementById("tplfile").value; <br />
var description = 'Facebook blocking Tracking Protection List'; <br />
window.external.msAddTrackingProtectionList(URL, description);<br />
}<br />
</script><br />
<br />
</head><br />
<body><br />
<!---- First check that you have tracking protection enabled by click the<br />
"check tracking protection" button<br />
<div><br />
<button onclick="checkTP();">Check tracking protection</button><br />
<span id="results">Tracking protection is: </span><br />
</div><br />
<p /><br />
Remember that you need to have tracking protection "on" for this to work<br />
if tracking protection is off, go to: <br><br />
tools, tracking protection, select "Your Personalized List" and click enable, close, <br><br />
then click on the "check tracking protection" button again. <br />
<br />
---><br />
<p /><br />
This is for blocking the facebook like button (and facebook's other tracking mechanisims),<br />
that are on many websites nowdays, which cause the company's usage policy to pop up. To stop this: <br><br />
click on "load TPL file"<br />
and click on the "add list" button<br />
<p /><br />
<div><br />
<button onclick="loadTPFile();">Load TPL file</button><br />
<input id= "tplfile" type="text" value="facebook-block.tpl" size="60" /><br />
</div><br />
<br />
<p /><br />
Remember if you go to the facebook.com website itself you will still get a copy of the company's<br />
Internet usage policy poping up. <br />
</body><br />
</html><br />
<div>
<br /></div>
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-4923525746667516612013-09-23T09:46:00.001-04:002013-09-23T09:46:25.047-04:00enable basic games in windowsTo enable/disable features in windows 7 you use dism (deployment image servicing and management). <br />
<br />
The following batch file will enable the basic games (chess, minesweeper, solitaire, etc...), but not any of the internet games. <br />
This will have to be ran with full admin privileges.<br />
<br />
rem --------------games-enable-w7.bat--------------<br />
rem to get a list of whats available and enabled/disabled<br />
rem dism /online /Get-Features<br />
echo make sure you're running this with admin privleges<br />
dism /online /enable-feature /featurename:"InboxGames"<br />
dism /online /disable-feature /featurename:"Internet Games"<br />
dism /online /disable-feature /featurename:"More Games"<br />
rem ---------end of batch script----------------<br />
<br />
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-27461464449692035652013-07-31T20:00:00.000-04:002013-09-25T10:09:29.839-04:00setting windows permissions from the command line using icaclsWhy set permissions from the command line when you can just right click and check or uncheck a few boxes?<br />
<div>
<br /></div>
<div>
Well checking boxes is great, if you only have one computer or two, and never have to re-do it. Once you have a few, well it's probably time to script it :)</div>
<div>
<br /></div>
<div>
Here are some basic ones I've used</div>
<div>
<br /></div>
<div>
To lock down a folder so that no one can delete what they created, a write only folder, (two liner):</div>
<div>
icacls d:\writeonlyfolder /deny Everyone:(CI)(OI)(DE)</div>
<div>
icacls d:\writeonlyfolder /deny Everyone:(CI)(OI)(DC)</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
So that people can't put any files in a folder (just subfolders)</div>
<div>
icacls d:\parentfolder /deny "Domain Users":(WD)</div>
<div>
<br />
This is a locked down structure, where only the creator of a folder on a share<br />
has access to the contents, no one else can even get into the folder created, other then administrators.<br />
<br />
rem we do want administrators and the creator of the folder though to have access</div>
<div>
icacls d:\secured /grant:r "Domain Administrators":(OI)(CI)F<br />
icacls d:\secured /grant:r "Creator Owner":(OI)(CI)F<br />
allow users to create folders in the parent folder. <br />
icacls d:\secured /grant:r users:WRXM<br />
remove any inheritance which could cause issues. <br />
icacls d:\secured /inheritance:r </div>
<div>
<br /></div>
<div>
Background on how windows file permissions work:</div>
<div>
<a href="http://technet.microsoft.com/en-us/magazine/2009.07.geekofalltrades.aspx">http://technet.microsoft.com/en-us/magazine/2009.07.geekofalltrades.aspx</a></div>
<div>
<br /></div>
ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-29944006642107172782013-07-09T19:25:00.000-04:002013-07-31T10:13:04.005-04:00Git revision control on windows via cygwinWith all this scripting one needs to be able to track the changes to their larger scripts. You can do the crude append -## to the file-name where ## is some revision number, but if you have a large script that you change a lot over a long period of time, relying on this, or file system backups, just doesn't work very well. Fortunately the programming field has revision control, and I've decided to use GIT. Unfortunately tortoise git while it is easy to use and install, caused some issues where browsing via network neighborhood to a remote site was slowed down tremendously. <br />
<br />
So I decide to use cygwin and the git it has, unfortunately the git gui interface (which I'm use to from tortoise git), is a little tricky to set up. <br />
<br />
When in the cygwin setup go into the "Devel" section and select all the items that start with git, including gitk, then go to the "X11" section and select, X-Start-menu-icons, and xinit. Once the cygwin setup program finished up, click on the start button, all programs, cygwin-x, X win server. You should see a white terminal box pop up. Use normal unix/linux commands to go the directory where your scripts are, and run your git commands. The reason for using the white terminal window from the X-win-server is so that you can run gitk. For some reason git gui gives me an error, but gitk works just fine. <br />
<br />
The git gui that is in cygwin is just for browsing the history of your code, to actually commit changes, and do anything other then view, you will still need to use the command line:<br />
<br />
For those new to git at the command line this is my cheetsheet<br />
for more commands and details of the commands check <a href="http://www.vogella.com/articles/Git/article.html">http://www.vogella.com/articles/Git/article.html</a><br />
<br />
first create the repository<br />
git init<br />
<br />
add files to the repository<br />
git add filename<br />
<br />
see the changes since the last commit:<br />
git diff<br />
<br />
commit the changes:<br />
git commit -m "some comments"<br />
<br />
commit a particular file:<br />
git commit script.bat<br />
<br />
git status<br />
<br />
git add script.bat<br />
<br />
git log<br />
<br />
see the commits for a file<br />
git log filename<br />
<br />
see the diffs of each commit for a file<br />
git log -p filename<br />
<br />
see the entire history<br />
git log --follow -p file<br />
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-40949883680693356812013-05-23T07:48:00.000-04:002013-05-23T07:48:11.412-04:00Monitor Inventory scriptInventory time. That time of the year where property control (or whatever they call it in your business), wants to know where everything is, usually for tax or insurance purposes. <br />
<br />
There's a good chance you already have a means for easily finding a computer if you have its serial number, several products will make it so that it's at least not too hard, and you may even have your own records for the computers. If you don't already, I have a script for that, that I'll post latter. However property control wants to know about everything, not just the tower unit, but furniture, metal detectors, TV's, monitors, etc... <br />
<br />
I can't help you for most of those things, but if you got property control asking you where are your different monitors, because they're hooked into the computer, or maybe you did some moving or replacing of the monitors, I have something that may help, if they have the serial numbers for the monitors.<br />
<br />
I've only ran this on dell computers with dell monitors with admin rights to all the computers, but if you have a different setup, you can still try this script, no guarantees though.... If you still can't find your monitor, make sure the computer is on, and that it's not in a store room somewhere unplugged. <br />
<br />
<br />
The resulting csv file looks like:<br />
machine, monitor model, serial, mfg, date of mfg<br />
<br />
comp1,DELL 1702FP,8G1522CGxxx1,DEL,12/2002<br />
comp2,DELL 1907FP,DC32364Hxxx2,DEL,4/2006<br />
comp3,DEL 1908FPBLK,D325J958xxx3,DEL,5/2009<br />
comp4,DELL 1702FP,8G1522CGxxx4,DEL,12/2002<br />
<br />
remember, on dell monitors at least, it only pulls approximately the last half of the monitor's serial number.<br />
<br />
this is the batch file that has all the computers you want to check for monitors on, and runs a vbscript on each one, which saves the monitor information into a csv file. <br />
<br />
<br />
rem monitor-inventory.bat<br />
rem you'll probably want to change the location of the csv file<br />
set csvfile=\\fileserver\staff\it-docs\monitors.csv<br />
rem the first line of the csv file so you know what's in each column.<br />
echo machine, monitor model, serial, mfg, date of mfg >> %csvfile%<br />
rem the list of the computers are in the parenthesies for the following lines, if you have<br />
rem a lot of computers you can add more lines, or have multiple copies of this bat file<br />
rem with different names, and different computers listed in each<br />
for %%C in (server reception secretary manager boss comp1 comp2 comp3 comp4 ) do cscript %progpath%mon-serial-num-v2.vbs %%C >> %csvfile% //nologo<br />
for %%C in (comp5 comp6 video guard) do cscript %progpath%mon-serial-num.vbs %%C >> %csvfile% //nologo<br />
rem --------------------------------------------------<br />
<div>
<br /></div>
<div>
<br />
The following is the core vb script that is based in large part on a script from: <a href="http://social.technet.microsoft.com/Forums/da-DK/ITCG/thread/18f72e8d-d3ee-4e51-a55d-aa5fd26db974">http://social.technet.microsoft.com/Forums/da-DK/ITCG/thread/18f72e8d-d3ee-4e51-a55d-aa5fd26db974</a></div>
<div>
Some modifications were made to make it work with my batch file above. <br />
<br />
<br />
'--------------------------------------------------------------<br />
<br />
Option Explicit<br />
Dim WshShell<br />
Set WshShell = WScript.CreateObject("WScript.Shell")<br />
Dim strComputer, message<br />
<br />
<br />
Dim intMonitorCount<br />
Dim oRegistry, sBaseKey, sBaseKey2, sBaseKey3, skey, skey2, skey3<br />
Dim sValue<br />
dim i, iRC, iRC2, iRC3<br />
Dim arSubKeys, arSubKeys2, arSubKeys3, arrintEDID<br />
Dim strRawEDID<br />
Dim ByteValue, strSerFind, strMdlFind<br />
Dim intSerFoundAt, intMdlFoundAt, findit<br />
Dim tmp, tmpser, tmpmdl, tmpctr<br />
Dim batch, bHeader<br />
batch = True<br />
'most of this script is stolen from: http://social.technet.microsoft.com/Forums/da-DK/ITCG/thread/18f72e8d-d3ee-4e51-a55d-aa5fd26db974<br />
<br />
<br />
If WScript.Arguments.Count = 1 Then<br />
strComputer = WScript.Arguments(0)<br />
'batch = True<br />
Else<br />
strComputer = wshShell.ExpandEnvironmentStrings("")<br />
strComputer = InputBox("Check Monitor info for what PC","PC Name?",strComputer)<br />
End If<br />
<br />
<br />
If strcomputer = "" Then WScript.Quit<br />
strComputer = UCase(strComputer)<br />
<br />
<br />
If batch Then<br />
Dim fso,logfile, appendout<br />
logfile = wshShell.ExpandEnvironmentStrings("%userprofile%") & "\desktop\MonitorInfo.csv"<br />
<br />
<br />
'setup Log<br />
Const ForAppend = 8<br />
Set fso = CreateObject("Scripting.FileSystemObject")<br />
If Not fso.FileExists(logfile) Then bHeader = True<br />
set appendout = fso.OpenTextFile(logfile, ForAppend, True)<br />
<br />
<br />
If bHeader Then<br />
appendout.writeline "Computer,Model,Serial #,Vendor ID,Manufacture Date,Messages"<br />
End If<br />
End If<br />
<br />
<br />
Dim strarrRawEDID()<br />
intMonitorCount=0<br />
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE<br />
'get a handle to the WMI registry object<br />
On Error Resume Next<br />
Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "/root/default:StdRegProv")<br />
<br />
<br />
If Err <> 0 Then<br />
If batch Then<br />
EchoAndLog strComputer & ",,,,," & Err.Description<br />
Else<br />
MsgBox "Failed. " & Err.Description,vbCritical + vbOKOnly,strComputer<br />
WScript.Quit<br />
End If<br />
End If<br />
<br />
<br />
<br />
<br />
sBaseKey = "SYSTEM\CurrentControlSet\Enum\DISPLAY\"<br />
'enumerate all the keys HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\<br />
iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)<br />
For Each sKey In arSubKeys<br />
'we are now in the registry at the level of:<br />
'HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\<VESA_Monitor_ID\<br />
'we need to dive in one more level and check the data of the "HardwareID" value<br />
sBaseKey2 = sBaseKey & sKey & "\"<br />
iRC2 = oRegistry.EnumKey(HKLM, sBaseKey2, arSubKeys2)<br />
For Each sKey2 In arSubKeys2<br />
'now we are at the level of:<br />
'HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\<VESA_Monitor_ID\<PNP_ID>\<br />
'so we can check the "HardwareID" value<br />
oRegistry.GetMultiStringValue HKLM, sBaseKey2 & sKey2 & "\", "HardwareID", sValue<br />
for tmpctr=0 to ubound(svalue)<br />
If lcase(left(svalue(tmpctr),8))="monitor\" then<br />
'If it is a monitor we will check for the existance of a control subkey<br />
'that way we know it is an active monitor<br />
sBaseKey3 = sBaseKey2 & sKey2 & "\"<br />
iRC3 = oRegistry.EnumKey(HKLM, sBaseKey3, arSubKeys3)<br />
For Each sKey3 In arSubKeys3<br />
'Kaplan edit<br />
strRawEDID = ""<br />
If skey3="Control" Then<br />
'If the Control sub-key exists then we should read the edid info<br />
oRegistry.GetBinaryValue HKLM, sbasekey3 & "Device Parameters\", "EDID", arrintEDID<br />
If vartype(arrintedid) <> 8204 then 'and If we don't find it...<br />
strRawEDID="EDID Not Available" 'store an "unavailable message<br />
else<br />
for each bytevalue in arrintedid 'otherwise conver the byte array from the registry into a string (for easier processing later)<br />
strRawEDID=strRawEDID & chr(bytevalue)<br />
Next<br />
End If<br />
'now take the string and store it in an array, that way we can support multiple monitors<br />
redim preserve strarrRawEDID(intMonitorCount)<br />
strarrRawEDID(intMonitorCount)=strRawEDID<br />
intMonitorCount=intMonitorCount+1<br />
End If<br />
Next<br />
End If<br />
Next<br />
Next<br />
Next<br />
'*****************************************************************************************<br />
'now the EDID info for each active monitor is stored in an array of strings called strarrRawEDID<br />
'so we can process it to get the good stuff out of it which we will store in a 5 dimensional array<br />
'called arrMonitorInfo, the dimensions are as follows:<br />
'0=VESA Mfg ID, 1=VESA Device ID, 2=MFG Date (M/YYYY),3=Serial Num (If available),4=Model Descriptor<br />
'5=EDID Version<br />
'*****************************************************************************************<br />
On Error Resume Next<br />
dim arrMonitorInfo()<br />
redim arrMonitorInfo(intMonitorCount-1,5)<br />
dim location(3)<br />
for tmpctr=0 to intMonitorCount-1<br />
If strarrRawEDID(tmpctr) <> "EDID Not Available" then<br />
'*********************************************************************<br />
'first get the model and serial numbers from the vesa descriptor<br />
'blocks in the edid. the model number is required to be present<br />
'according to the spec. (v1.2 and beyond)but serial number is not<br />
'required. There are 4 descriptor blocks in edid at offset locations<br />
'&H36 &H48 &H5a and &H6c each block is 18 bytes long<br />
'*********************************************************************<br />
location(0)=mid(strarrRawEDID(tmpctr),&H36+1,18)<br />
location(1)=mid(strarrRawEDID(tmpctr),&H48+1,18)<br />
location(2)=mid(strarrRawEDID(tmpctr),&H5a+1,18)<br />
location(3)=mid(strarrRawEDID(tmpctr),&H6c+1,18)<br />
<br />
<br />
'you can tell If the location contains a serial number If it starts with &H00 00 00 ff<br />
strSerFind=chr(&H00) & chr(&H00) & chr(&H00) & chr(&Hff)<br />
'or a model description If it starts with &H00 00 00 fc<br />
strMdlFind=chr(&H00) & chr(&H00) & chr(&H00) & chr(&Hfc)<br />
<br />
<br />
intSerFoundAt=-1<br />
intMdlFoundAt=-1<br />
for findit = 0 to 3<br />
If instr(location(findit),strSerFind)>0 then<br />
intSerFoundAt=findit<br />
End If<br />
If instr(location(findit),strMdlFind)>0 then<br />
intMdlFoundAt=findit<br />
End If<br />
Next<br />
<br />
<br />
'If a location containing a serial number block was found then store it<br />
If intSerFoundAt<>-1 then<br />
tmp=right(location(intSerFoundAt),14)<br />
If instr(tmp,chr(&H0a))>0 then<br />
tmpser=trim(left(tmp,instr(tmp,chr(&H0a))-1))<br />
Else<br />
tmpser=trim(tmp)<br />
End If<br />
'although it is not part of the edid spec it seems as though the<br />
'serial number will frequently be preceeded by &H00, this<br />
'compensates for that<br />
If left(tmpser,1)=chr(0) then tmpser=right(tmpser,len(tmpser)-1)<br />
else<br />
tmpser="Not Found"<br />
End If<br />
<br />
<br />
'If a location containing a model number block was found then store it<br />
If intMdlFoundAt<>-1 then<br />
tmp=right(location(intMdlFoundAt),14)<br />
If instr(tmp,chr(&H0a))>0 then<br />
tmpmdl=trim(left(tmp,instr(tmp,chr(&H0a))-1))<br />
else<br />
tmpmdl=trim(tmp)<br />
End If<br />
'although it is not part of the edid spec it seems as though the<br />
'serial number will frequently be preceeded by &H00, this<br />
'compensates for that<br />
If left(tmpmdl,1)=chr(0) then tmpmdl=right(tmpmdl,len(tmpmdl)-1)<br />
else<br />
tmpmdl="Not Found"<br />
End If<br />
<br />
<br />
'**************************************************************<br />
'Next get the mfg date<br />
'**************************************************************<br />
Dim tmpmfgweek,tmpmfgyear,tmpmdt<br />
'the week of manufacture is stored at EDID offset &H10<br />
tmpmfgweek=asc(mid(strarrRawEDID(tmpctr),&H10+1,1))<br />
<br />
<br />
'the year of manufacture is stored at EDID offset &H11<br />
'and is the current year -1990<br />
tmpmfgyear=(asc(mid(strarrRawEDID(tmpctr),&H11+1,1)))+1990<br />
<br />
<br />
'store it in month/year format<br />
tmpmdt=month(dateadd("ww",tmpmfgweek,datevalue("1/1/" & tmpmfgyear))) & "/" & tmpmfgyear<br />
<br />
<br />
'**************************************************************<br />
'Next get the edid version<br />
'**************************************************************<br />
'the version is at EDID offset &H12<br />
Dim tmpEDIDMajorVer, tmpEDIDRev, tmpVer<br />
tmpEDIDMajorVer=asc(mid(strarrRawEDID(tmpctr),&H12+1,1))<br />
<br />
<br />
'the revision level is at EDID offset &H13<br />
tmpEDIDRev=asc(mid(strarrRawEDID(tmpctr),&H13+1,1))<br />
<br />
<br />
'store it in month/year format<br />
tmpver=chr(48+tmpEDIDMajorVer) & "." & chr(48+tmpEDIDRev)<br />
<br />
<br />
'**************************************************************<br />
'Next get the mfg id<br />
'**************************************************************<br />
'the mfg id is 2 bytes starting at EDID offset &H08<br />
'the id is three characters long. using 5 bits to represent<br />
'each character. the bits are used so that 1=A 2=B etc..<br />
'<br />
'get the data<br />
Dim tmpEDIDMfg, tmpMfg<br />
dim Char1, Char2, Char3<br />
Dim Byte1, Byte2<br />
tmpEDIDMfg=mid(strarrRawEDID(tmpctr),&H08+1,2)<br />
Char1=0 : Char2=0 : Char3=0<br />
Byte1=asc(left(tmpEDIDMfg,1)) 'get the first half of the string<br />
Byte2=asc(right(tmpEDIDMfg,1)) 'get the first half of the string<br />
'now shift the bits<br />
'shift the 64 bit to the 16 bit<br />
If (Byte1 and 64) > 0 then Char1=Char1+16<br />
'shift the 32 bit to the 8 bit<br />
If (Byte1 and 32) > 0 then Char1=Char1+8<br />
'etc....<br />
If (Byte1 and 16) > 0 then Char1=Char1+4<br />
If (Byte1 and 8) > 0 then Char1=Char1+2<br />
If (Byte1 and 4) > 0 then Char1=Char1+1<br />
<br />
<br />
'the 2nd character uses the 2 bit and the 1 bit of the 1st byte<br />
If (Byte1 and 2) > 0 then Char2=Char2+16<br />
If (Byte1 and 1) > 0 then Char2=Char2+8<br />
'and the 128,64 and 32 bits of the 2nd byte<br />
If (Byte2 and 128) > 0 then Char2=Char2+4<br />
If (Byte2 and 64) > 0 then Char2=Char2+2<br />
If (Byte2 and 32) > 0 then Char2=Char2+1<br />
<br />
<br />
'the bits for the 3rd character don't need shifting<br />
'we can use them as they are<br />
Char3=Char3+(Byte2 and 16)<br />
Char3=Char3+(Byte2 and 8)<br />
Char3=Char3+(Byte2 and 4)<br />
Char3=Char3+(Byte2 and 2)<br />
Char3=Char3+(Byte2 and 1)<br />
tmpmfg=chr(Char1+64) & chr(Char2+64) & chr(Char3+64)<br />
<br />
<br />
'**************************************************************<br />
'Next get the device id<br />
'**************************************************************<br />
'the device id is 2bytes starting at EDID offset &H0a<br />
'the bytes are in reverse order.<br />
'this code is not text. it is just a 2 byte code assigned<br />
'by the manufacturer. they should be unique to a model<br />
Dim tmpEDIDDev1, tmpEDIDDev2, tmpDev<br />
<br />
<br />
tmpEDIDDev1=hex(asc(mid(strarrRawEDID(tmpctr),&H0a+1,1)))<br />
tmpEDIDDev2=hex(asc(mid(strarrRawEDID(tmpctr),&H0b+1,1)))<br />
If len(tmpEDIDDev1)=1 then tmpEDIDDev1="0" & tmpEDIDDev1<br />
If len(tmpEDIDDev2)=1 then tmpEDIDDev2="0" & tmpEDIDDev2<br />
tmpdev=tmpEDIDDev2 & tmpEDIDDev1<br />
<br />
<br />
'**************************************************************<br />
'finally store all the values into the array<br />
'**************************************************************<br />
'Kaplan adds code to avoid duplication...<br />
<br />
<br />
If Not InArray(tmpser,arrMonitorInfo,3) Then<br />
arrMonitorInfo(tmpctr,0)=tmpmfg<br />
arrMonitorInfo(tmpctr,1)=tmpdev<br />
arrMonitorInfo(tmpctr,2)=tmpmdt<br />
arrMonitorInfo(tmpctr,3)=tmpser<br />
arrMonitorInfo(tmpctr,4)=tmpmdl<br />
arrMonitorInfo(tmpctr,5)=tmpVer<br />
End If<br />
End If<br />
Next<br />
<br />
<br />
'For now just a simple screen print will suffice for output.<br />
'But you could take this output and write it to a database or a file<br />
'and in that way use it for asset management.<br />
i = 0<br />
for tmpctr = 0 to intMonitorCount-1<br />
If arrMonitorInfo(tmpctr,1) <> "" And arrMonitorInfo(tmpctr,0) <> "PNP" Then<br />
If batch Then<br />
EchoAndLog strComputer & "," & arrMonitorInfo(tmpctr,4) & "," & _<br />
arrMonitorInfo(tmpctr,3)& "," & arrMonitorInfo(tmpctr,0) & "," & _<br />
arrMonitorInfo(tmpctr,2)<br />
Else<br />
message = message & "Monitor " & chr(i+65) & ")" & VbCrLf & _<br />
"Model Name: " & arrMonitorInfo(tmpctr,4) & VbCrLf & _<br />
"Serial Number: " & arrMonitorInfo(tmpctr,3)& VbCrLf & _<br />
"VESA Manufacturer ID: " & arrMonitorInfo(tmpctr,0) & VbCrLf & _<br />
"Manufacture Date: " & arrMonitorInfo(tmpctr,2) & VbCrLf & VbCrLf<br />
'wscript.echo ".........." & "Device ID: " & arrMonitorInfo(tmpctr,1)<br />
'wscript.echo ".........." & "EDID Version: " & arrMonitorInfo(tmpctr,5)<br />
i = i + 1<br />
End If<br />
End If<br />
Next<br />
<br />
<br />
If not batch Then<br />
MsgBox message, vbInformation + vbOKOnly,strComputer & " Monitor Info"<br />
End If<br />
<br />
<br />
Function InArray(strValue,List,Col)<br />
Dim i<br />
For i = 0 to UBound(List)<br />
If List(i,col) = cstr(strValue) Then<br />
InArray = True<br />
Exit Function<br />
End If<br />
Next<br />
InArray = False<br />
End Function<br />
<br />
<br />
Sub EchoAndLog (message)<br />
'Echo output and write to log<br />
Wscript.Echo message<br />
AppendOut.WriteLine message<br />
End Sub</div>
ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-9916610019495139292013-04-27T19:44:00.002-04:002013-04-27T20:15:43.811-04:00dhclient and /etc/resolv.conf being overwritten.In ubuntu 12.12 (the one I'm currently using), dhclient is used to get a dhcp lease. For most people this works just dandy. However if you use it for routing, and/or running your own dns server inside your network, or just want to have some dns servers used for whatever reason that the dhcp server doesn't issue you can do the following. <br />
<div>
<br /></div>
<div>
If you go into the /etc/dhcp directory you will see a file called dhclient.conf</div>
<div>
somewhere (anywhere really), in the file put the following line:</div>
prepend domain-name-servers 8.8.8.8;<br />
<div>
<br />
if you want just your custom dns server:<br />
supersede domain-name-servers 8.8.8.8;<br />
<br /></div>
<div>
<br /></div>
<div>
This will put the 8.8.8.8 dns server at the top of the list of dns servers in the /etc/resolv.conf file, in addition the to usual ones that the dhcp server gave to your computer. </div>
<div>
<br /></div>
<div>
Of course for your network you will probably replace 8.8.8.8 with the ip address of another dns server (unless you really want to use one of google's dns servers). </div>
<div>
<br /></div>
<div>
<br />
In fedora you have to go to /etc/sysconfig/network-scripts/, and find the file for your network device (something like ifcfg-ethX, where X is a number usually 0). <br />
<br />
change the line PEERDNS=yes to =no. <br />
<br /></div>
<div>
<br /></div>
ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-32516093132189973692013-04-26T22:07:00.000-04:002013-04-26T22:07:36.493-04:00installing ssh fedoraFedora nowadays doesn't have the ssh server by default, if you want it here's how (fedora no longer uses /etc/init.d):<br />
<br />
yum install openssh<br />
service sshd start<br />
service sshd enable<br />
<br />
note: if you want to start/enable other services on fedora you can replace sshd with the name of the other service. ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-62215290329333621852013-04-24T21:18:00.000-04:002015-03-24T23:26:51.828-04:00proxmox tipsTo force a vm to shutdown you can't do it from the web interface so instead you'll have to ssh in and use your root username and password. Once you're ssh'd in type:<br />
qm shutdown <vmid> -forceStop<br />
more details at: <a href="http://pve.proxmox.com/wiki/Manual:_qm">http://pve.proxmox.com/wiki/Manual:_qm</a><br />
<br />
<br />
<br />
<br />
Proxmox is a nice setup overall, but the java vnc interface to view the desktop of the vm is just lousy. A way around that is to ssh in and go to the /etc/pve/nodes/proxmox/qemu-server directory. In the 1##.conf file (where 1## is the id of the VM), put the following lines:<br />
args: -vnc 0.0.0.0:10 <br />
You can do this with each vm, just make sure the change the number after the last colon, as<br />
each vnc connection has to be on it's own port. Then you can vnc using your favorite vnc viewer, and use the ip address/hostname of the proxmox server followed by a : and the number that's at the end of the line you put in the VM's config file. In this case it would be "vncviewer proxmox-machine:10"<br />
<br />
More details on your vnc options and proxmox are at: <a href="http://pve.proxmox.com/wiki/Vnc_2.0">http://pve.proxmox.com/wiki/Vnc_2.0</a><br />
<br />
<br />
For tips on how to deal with the screen resolution of linux in a VM (both X and console): <br />
<a href="http://thescriptingadmin.blogspot.com/2013/04/fedora-too-high-resolution-in-vm.html">http://thescriptingadmin.blogspot.com/2013/04/fedora-too-high-resolution-in-vm.html</a><br />
<br />
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-10546988654029188542013-04-05T19:11:00.000-04:002013-04-05T19:11:52.578-04:00ssh-agent in cygwinIf you do command line work like I do, and remote into a linux machine via ssh, you may or may not be aware of ssh keys. If you use an ssh key you can log into the machine without a password. However to keep things secure, you really should use a password on your ssh key, but if you had to type in the password every time you used the key, that would sort of defeat the purpose of the ssh key. So they have ssh-agent for linux and cygwin (if you're using putty use pagent instead). <br />
<br />
Normally you first run ssh-agent, then run ssh-add (or just have it loaded via kde, gnome, or<a href="http://mah.everybody.org/docs/ssh" target="_blank"> .bash_profile</a> if you don't use a gui at all on linux). On cygwin though you might encounter the error message "Could not open a connection to your authentication agent" when you type in ssh-add. The solution is apparently to run the following command: "exec ssh-agent bash", and once you get a new bash shell then type ssh-add. <br />
<br />
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-45911413500511502582013-04-05T10:08:00.000-04:002013-07-28T20:23:58.836-04:00enable remote registry service on windows 7 Windows 7 by default disables the remote registry service (probably for security reasons). To enable it from the command line type the following:<br />
<br />
sc \\computername config remoteregistry start= auto<br />
make sure you have a space between the = sign and auto<br />
if you're doing this on your local computer you can drop the \\computername part<br />
you can also replace "remoteregistry" with the name of another service to enable or disable it.<br />
<br />
<br />
once you've enabled the service you can either reboot the computer, or just start it now with:<br />
<br />
sc \\computername start remoteregistry<br />
<br />
<br />
If you want to know why we want to enable this service, it's so that you can pull up the registry of a remote computer that's currently in use (normally hkey_local_machine) via regedit on your local machine. This way you don't have to interrupt whoever is currently at the computer by using <a href="http://thescriptingadmin.blogspot.com/2013/02/enable-remote-desktop.html" target="_blank">RDP</a>, VNC, or kicking the user out of their chair, at most you may have to tell them to reboot their machine at some point. <br />
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com15tag:blogger.com,1999:blog-6474827098489077555.post-25451960503532481412013-03-21T18:30:00.000-04:002013-04-01T22:19:55.319-04:00printer statistics via SNMPAt work we have some multi-function copiers that do the whole print, scan, copy, deal. What do you do if you want to track printer usage?. You can either enable monitoring of print jobs on the print server, if your users go through a print server, or you can track the page counts on the printers themselves, if they are network printers. <br />
<br />
In addition to tracking page counts, this script tracks how many sheets of paper are left in each of the trays (if your network printer is advanced enough to do that), and dumps all the information to a csv file. Right now I'm running the script every hour or so to track what happens if I adjust some default settings. <br />
<br />
For this you will need net-snmp, which you can get at: <a href="http://sourceforge.net/projects/net-snmp/files/net-snmp%20binaries/">http://sourceforge.net/projects/net-snmp/files/net-snmp%20binaries/</a> if you're using windows, if you're using linux do apt-get install snmp or yum install net-snmp depending on your distro so that you get snmpwalk installed. <br />
<br />
For linux you'll probably need to create a bash script of your own, based on the nagios script I used at: <a href="http://exchange.nagios.org/directory/Plugins/Hardware/Printers/SNMP-Printer-Check/details">http://exchange.nagios.org/directory/Plugins/Hardware/Printers/SNMP-Printer-Check/details</a><br />
<br />
Without further ado here's my batch script (for windows):<br />
<br />
<br />
<br />
@echo off <br />
set snmpexe=c:\usr\bin\snmpwalk.exe<br />
rem make sure to include the .exe at the end<br />
rem netsnmp binaries are available from:<br />
rem http://sourceforge.net/projects/net-snmp/files/net-snmp%20binaries/<br />
rem shouldn't need to change anything between this and ":appendfile"<br />
set prnip=%1<br />
echo checking on the amount of paper left in the trays for printer %prnip%<br />
for /f "tokens=2" %%W in ('date /t') do set dater=%%W<br />
for /f "tokens=1,2 delims=:" %%t in ('echo %time%') do set timer=%%t:%%u<br />
for /f "tokens=1-3 delims=/" %%d in ('echo %dater%') do set curdate=%%f%%d%%e<br />
for /f "tokens=3 delims=/" %%y in ('echo %dater%') do set curyear=%%y<br />
rem reset variables for when we run this multiple times (usually on different printers), <br />
rem in the same enviroment (don't want previous valuse affecting this run). <br />
set tray0=x<br />
set tray1=x<br />
set tray2=x<br />
set tray3=x<br />
set tray4=x<br />
set pgcount=x<br />
if "%1" == "" goto usage<br />
if NOT exist %snmpexe% goto usage<br />
<br />
if exist prn-%prnip%-%curyear%.csv goto appendfile<br />
:newfile<br />
echo this tells you how many sheets are still in each input tray/cassette in a printer<br />
echo date ,time ,envelope ,tray1 ,tray2 ,tray3 ,tray4 ,pagecount >> prn-%prnip%-%curyear%.csv<br />
<br />
<br />
:appendfile<br />
rem this is for a printer with 4 regular trays and a "multi-purpose" tray, you<br />
rem many need to change this a bit if your printer hardware is a little different<br />
rem this is based on code from<br />
rem http://exchange.nagios.org/directory/Plugins/Hardware/Printers/SNMP-Printer-Check/details<br />
for /f "tokens=4" %%c in ('%snmpexe% -v1 -c public %prnip% 1.3.6.1.2.1.43.8.2.1.10.1.1') do set tray0=%%c<br />
for /f "tokens=4" %%c in ('%snmpexe% -v1 -c public %prnip% 1.3.6.1.2.1.43.8.2.1.10.1.2') do set tray1=%%c<br />
for /f "tokens=4" %%c in ('%snmpexe% -v1 -c public %prnip% 1.3.6.1.2.1.43.8.2.1.10.1.3') do set tray2=%%c<br />
for /f "tokens=4" %%c in ('%snmpexe% -v1 -c public %prnip% 1.3.6.1.2.1.43.8.2.1.10.1.4') do set tray3=%%c<br />
for /f "tokens=4" %%c in ('%snmpexe% -v1 -c public %prnip% 1.3.6.1.2.1.43.8.2.1.10.1.5') do set tray4=%%c<br />
for /f "tokens=4" %%c in ('%snmpexe% -v1 -c public %prnip% 1.3.6.1.2.1.43.10.2.1.4.1.1') do set pgcount=%%c<br />
<br />
echo %date% ,%timer% ,%tray0% ,%tray1% ,%tray2% ,%tray3% ,%tray4% ,%pgcount% >> prn-%prnip%-%curyear%.csv<br />
<br />
goto end<br />
<br />
:usage<br />
echo usage: input-tray-count.bat ip-of-printer <br />
echo this requires snmpwalk in the specified location<br />
echo this will tell you how many sheets you have left in each input tray/cassette in a printer<br />
<br />
:endncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-48319923502868202542013-03-18T19:30:00.000-04:002013-12-18T11:05:32.281-05:00company CA without a cert serverFor those who administer a network, sometimes you need to create a root certificate. This can be for an internal web-server, or for deploying internal software, or for other reasons. In many places you have a server setup who's sole purpose it get generate SSL and maybe other certificates for the company. If you don't wan't to dedicate an entire server to this task though because you don't need to be constantly generating new certificates there is an alternative. <br />
<br />
OpenSSL is an open source program (hence the Open part), that allows you to generate SSL certificates, everything from a root certificate (for your company root CA), to a regular certificate that's signed by the root CA. <br />
<br />
If you're on a linux machine do your usual apt-get install openssl or yum install openssl, and skip the next paragraph for windows. <br />
<br />
If you're on windows, you'll need to go to: <a href="http://www.openssl.org/related/binaries.html">http://www.openssl.org/related/binaries.html</a>, and follow the links till you can download the openssl binary (full version) for window at <a href="http://slproweb.com/products/Win32OpenSSL.html">http://slproweb.com/products/Win32OpenSSL.html</a> (you may need to download and install the visual C++ redistrutable). You'll also want to add c:\openssl-win32\bin to your system's path or have the DLL's installed to the c:\windows\system32 directory. <br />
<br />
To create a root certificate go to the c:\openssl-win32\bin directory and type:<br />
openssl req -nodes -new -x509 -keyout my-ca.key -out my-ca.crt -days 3650 -config openssl.cfg<br />
-leave the e-mail address blank. <br />
-the above root ca will be valid for 13 years. <br />
<br />
make the following directories, demoCA, demoCA\newcerts, and demoCA\private<br />
under c:\openssl-win32\bin?<br />
so you should have c:\openssl-win32\bin\demoCA\newcerts as one of your paths<br />
<br />
<br />
<br />
move the *-ca.crt file to demoCA<br />
the *-ca.key file to demoCA\private<br />
in the openssl.cnf file go to the CA_default section and make sure that private_key = $dir/private/my-ca.key<br />
and change certificate = $dir/my-ca.crt<br />
(change my-ca.key to whatever you typed in the openssl command above)<br />
<br />
<br />
type echo 01 > \demoCA\serial<br />
and in explorer navigate to the demoCA folder and create a new text file<br />
and name it index.txt (don't put anything in it).<br />
<br />
<br />
<br />
to create server certificates for wsus:<br />
openssl req -nodes -new -keyout servername.key -out servername.csr -days 1825 -config openssl.cfg<br />
for Common Name enter servername.company.com<br />
leave email address blank, and hit enter for challenge password and optional company name.<br />
<br />
then sign it using the ca (certifies for 5 yesrs)<br />
openssl ca -out server.crt -in server.csr -days 1825 -config openssl.cfg<br />
<div>
<br /></div>
then export it to pfx format for iis:<br />
openssl pkcs12 -export -out server.pfx -inkey server.key -in server.crt -certfile my-ca.crt<br />
type in a password for the pfx<br />
ignore message about "unable to write 'random state'<br />
<br />
<br />
<br />
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-16447695598754208382013-03-07T18:30:00.000-05:002013-03-08T08:48:15.823-05:00rrd illegal time fix, and editing xml with sed<br />
<pre>And now for some BASHing...</pre>
<pre></pre>
<pre>If you use rrd, and do a reboot of your computer, on rare occasion you might run into an error like the following (I put xxx in some places for privacy). </pre>
<pre></pre>
<pre>ERROR: Cannot update /var/www/mrtg/xxx/10.x.x.5_xx.rrd with '1359389221:4100149299:563322753' /var/www/mrtg/xxx/10.x.x.5_xx.rrd: illegal attempt to update using time 1359389221 when last update time is 1359402962 (minimum one second step)
</pre>
<div>
<br /></div>
<div>
That long 10 digit number starting with 1359... is a unix time stamp, which is just the number of seconds that have elapsed since january 1st 1970. If you can't figure out the cause of this error, you can edit the rrd files. Unfortunately they are in a binary format and need to first be exported to xml, edited, and then converted back to binary format. While there is a python script for editing xml files exported from rrd databases, it required a library which I was unable to properly install on my linux machine. So I decided to create a bash script using sed, and not bother with python (or it's libraries)</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Remember this is a BASH script, not a BATCH script. So if you're going to run this on a windows machine you'll need to install cygwin first, and run it from inside of cygwin. </div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
#!/bin/bash</div>
# you will probably want to run this as<br />
# find . -iname "*.rrd" -print0 |xargs -0 -I {} rrd-fixer.sh {}<br />
<br />
#first we convert the rrd file to xml format<br />
rrdtool dump $1 > $1.xml<br />
#we need to figure out the current unix date (epoc format, number of seconds <br />
#since 1970)<br />
udate=`date +%s`<br />
#the heart and soul, take out the bad last update stamp, and replace it with <br />
# one mrtg (or other rrd based tools), won't barf on<br />
sed -e "s/<lastupdate>1[0-9]\{9\}/<lastupdate>$udate/" $1.xml > $1.fixed.xml<br />
#rrdtool won't overwrite the bad rrd file on it's own, so have to remove <br />
#it ourselves<br />
rm $1<br />
#convert the .xml file back to .rrd format<br />
rrdtool restore $1.fixed.xml $1<br />
#cleanup the xml files<br />
rm $1.xml<br />
rm $1.fixed.xml<br />
<br />
# ---------- end of bash script --------------------------<br />
<br />
note: if you want to run this on a folder with many rrd files (like mrtg or smokeping will often create), you will probably want to run the script in the following manner:<br />
find . -name "*.rrd" -print0 |xargs -0 -I {} rrd-fixer.sh {}<br />
or if you want to simplify it:<br />
ls -1 *.rrd |xargs rrd-fixer.sh<br />
<br />
<br />
<br />
fyi, the python script I came across is at: <a href="http://pierre.palatin.fr/old/rrd-repair">http://pierre.palatin.fr/old/rrd-repair</a><br />
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com1tag:blogger.com,1999:blog-6474827098489077555.post-70646620650645840922013-02-28T18:30:00.000-05:002013-02-28T18:47:12.921-05:00net send for windows vista/7/8Remember back in the day of NT/2000/XP, where you could type<br />
net send computername some message here?<br />
<br />
If you tried to do a net send with any version of windows since xp (vista/7/8), you've probably noticed that Microsoft removed net send entirely (with xp sp2, they disabled the service, but you could easily re-enable it). <br />
<br />
Microsoft probably did this for security/anti-spam. Back in the days when I was in college, I would often be getting net send spam. <br />
<br />
You can use msg.exe which will send a message to a terminal server (has to be a server vision of windows), or to display a popup on your local computer. If we combine that with psexec we have a way to replicate the functionality, <br />
<br />
psexec \\remotecomputer msg.exe * /server:remotecomputer some message here<br />
<br />
However this doesn't work very well if you have many computers (say a whole office?) that you need to send a message to. <br />
So here's a script to make it easier if you have multiple computers:<br />
<br />
rem --------beginning of netsend7.bat-------------------------<br />
<br /><br />@echo off<br /><br />rem this is for sending messages to computers using psexec and msg.exe<br /><br />rem instead of net send. as net send doesn't exist in windows after xp<br /><br />rem NEEDS PSEXEC.EXE in the the path or same folder. <br /><br /><br /><br /><br />if "%~1" == "" goto error<br /><br /><br /><br /><br />rem need to convert the list of computers<br /><br />rem from comma to space delimited<br /><br />for /f "tokens=*" %%c in ('echo %~1') do set comps=%%c<br /><br />echo the computers are %comps%<br /><br /><br /><br /><br />rem extract the message from the command line<br /><br />for /f "tokens=1,* delims= " %%p in ('echo %*') do set msg=%%q<br /><br />echo the message is: %msg%<br /><br /><br /><br /><br />rem call the subroutine for each message. <br /><br />for %%c in (%comps%) do call :submsg %%c<br /><br /><br /><br /><br /><br /><br /><br />goto end<br /><br /><br /><br /><br />:submsg<br /><br />set subcomp=%1<br /><br />rem echo messaging %subcomp%, with message %msg%<br /><br />psexec \\%subcomp% msg.exe * /server:%subcomp% %msg%<br /><br />exit /b<br /><br /><br /><br /><br />:error<br /><br />echo make sure to include quotes at the beginning and<br /><br />echo end of the list of computers, but not the message, <br /><br />echo usage "comp1,comp2,comp3,etc..." some message to the computers<br /><br /><br /><br /><br />rem check for psexec<br /><br />where /q "$path:psexec.exe"<br /><br />if %errorlevel% == 0 goto end<br /><br />echo .<br /><br />if not exist psexec.exe echo you need to have psexec.exe somewhere in the path. <br /><br /><br /><br /><br />:end<br /><br /><br />rem --------end of netsend7.bat-------------------------<br /><br /><br /><div>
<br /></div>
<div>
If you want to accomplish the same thing without psexec, there is a guy who figured out a method using vbscript and setting a remoteRPC key in the registry on every computer you're messaging to:</div>
<div>
<a href="http://pedrofln.blogspot.com/2011/08/net-messenger-script-for-windows-72008.html">http://pedrofln.blogspot.com/2011/08/net-messenger-script-for-windows-72008.html</a></div>
<div>
<a href="http://gallery.technet.microsoft.com/scriptcenter/A-net-messenger-script-for-810f8331">http://gallery.technet.microsoft.com/scriptcenter/A-net-messenger-script-for-810f8331</a></div>
<div>
<br /></div>
<div>
<br /></div>
ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-5321377759832971692013-02-27T22:03:00.000-05:002013-02-27T22:03:33.660-05:00synchronizing cross platformIf you've been in the computer field at all for the past few years, you've heard of the cloud, amazon s3, ec2, dropbox, windows live, carbonite, google docs, etc....<br />
<br />
What if you don't want to store everything in the cloud, either it's too private, or don't want to run afoul of some data privacy laws (hippa?), or it would just cost too much to store all of the hours of baby videos you took. <br />
<br />
Now you could use robocopy, or rsync, but these are both one direction. If you have a laptop that you edit information on along with a desktop (or another laptop?), you probably want to sync your information between the two not just do a one direction backup. <br />
<br />
Unison is the program I've been using to keep various repositories of information in sync. It's cross platform, bi-directional, and doesn't involve the cloud, you control where everything is. <br />
<br />
my usage is:<br />
unison -batch profile.prf<br />
<br />
the -batch option automates the synchronization process, without it, unison will ask about each and every file that it's copying, should it copy, delete, overwrite one, etc..., so you should probably run it just the first time without the -batch option (if at all).<br />
<br />
profile.prf is the name of the configuration file (in the .unison folder if you don't specify a path to it), it can be any name though (pro.prf, home-sync.prf, etc...). <br />
<br />
it'll also run over ssh like rsync does, or run a server also like rsync. <br />
<br />
a unique feature of unison which I enable is for it to store previous versions of files into a separate folder (or you can store them in a hidden folder in the listing of folders being synchronized).<br />
<br />
one of my .prf files, this is for windows, but unison on linux works just as well, just change the folders. <br />
<br />
#######------start of prf file--------------<br />
<br />
root = //server1/share/synced-folder1<br />
root = //server2/share/synced-folder2<br />
<br />
path = subfolder1<br />
path = subfolder2<br />
path = subfolder3<br />
<br />
#as this is for windows, don't use fastcheck for unix usually<br />
fastcheck = true<br />
backup = Name *<br />
#ignore any hidden folders, and cd images<br />
ignore = Name {,.}*{.iso}<br />
#where unison stores it's previous versions<br />
backupdir = c:\Users\user1\unison-bak<br />
#where to store the logs<br />
logfile = c:\Users\user1\unison-logs\info-db<br />
#the maximum number of previous versions<br />
maxbackups = 10<br />
#######------end of prf file--------------<br />
<br />ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-45308988874610034692013-02-26T18:30:00.000-05:002013-02-26T22:45:26.992-05:00sysinternals tools hanging due to licenseYou probably have come across (either in this blog or on other sites), various tools from <a href="http://www.sysinternals.com/">sysinternals </a>(psexec, psinfo, pskill, etc...). <br />
<br />
While these are great tools, for the sysadmin, especially when it comes to automating and scripting, you may have noticed that they been absorbed my microsoft. On it's own, being acquired by microsoft isn't necessarily a bad thing, however microsoft does now insist that you agree to a license the first time you use a sysinternals tool as a particular user on a particular machine. This can be very problematic when running scripts on remote machines via psexec (the sysinternals tool will hang and not give you any indication that it's because you need to agree to a license). <br />
<br />
One way to get around this is to put in registry keys onto the remote computer that you already accepted the eula, <br />
reg.exe ADD HKCU\Software\Sysinternals\PsKill /v EulaAccepted /t REG_DWORD /d 1 /f<br />
reg.exe ADD HKCU\Software\Sysinternals\PsList /v EulaAccepted /t REG_DWORD /d 1 /f<br />
reg.exe ADD HKCU\Software\Sysinternals\PsInfo /v EulaAccepted /t REG_DWORD /d 1 /f<br />
reg.exe ADD HKCU\Software\Sysinternals\PSexec /v EulaAccepted /t REG_DWORD /d 1 /f<br />
reg.exe ADD "HKCU\Software\Sysinternals\Process Explorer" /v EulaAccepted /t REG_DWORD /d 1 /f<br />
reg.exe ADD "HKCU\Software\Sysinternals\Process Monitor" /v EulaAccepted /t REG_DWORD /d 1 /f<br />
reg.exe ADD "HKCU\Software\Sysinternals\Autoruns" /v EulaAccepted /t REG_DWORD /d 1 /f<br />
reg.exe ADD "HKCU\Software\Sysinternals\TCPView" /v EulaAccepted /t REG_DWORD /d 1 /f<br />
reg.exe ADD "HKCU\Software\Sysinternals\RootkitRevealer" /v EulaAccepted /t REG_DWORD /d 1 /f <br />
<pre></pre>
<pre>many thinks to <a href="http://peter.hahndorf.eu/blog/post/2010/03/07/WorkAroundSysinternalsLicensePopups">http://peter.hahndorf.eu/blog/post/2010/03/07/WorkAroundSysinternalsLicensePopups</a> for the information, please go there for a more complete listing of registry entries for each of the sysinternals tools. </pre>
ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-8767842517901552412013-02-25T18:30:00.000-05:002013-02-26T10:21:10.303-05:00Monitoring free spacePreviously I described one unusual method to help clear out space on windows, <a href="http://thescriptingadmin.blogspot.com/2013/02/freeing-space-move-uninstall-packs.html">details are here</a>, If you want to make sure your windows server (or workstation), doesn't get too low on free space you can use some of the many monitoring tools out there which eat up system resources when you use them and/or cost an arm and a leg. My solution is to have a script which goes out and checks the drives, and saves the information to a csv file so you can check for trends using any spreadsheet program. It will also send out an e-mail if the space is too low. I run this script from the windows task scheduler at 7am and 7pm, against all the different servers. <br />
<div>
<br /></div>
<div>
Usage: drv-space.bat servername</div>
<div>
<div>
<br /></div>
<div>
note: e-mail functionality requires blat.exe which you can get at <a href="http://www.blat.net/">http://www.blat.net/</a>, and you will have to set some variables in the script also.</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
rem -----begin script --------</div>
<div>
<br /></div>
<div>
<div>
@echo off</div>
<div>
set tech=network.admin</div>
<div>
set techdom=company.com</div>
<div>
set mailserver=mail.company.com</div>
<div>
set machinednsdomain=company.com</div>
<div>
set blatexe=c:\utils\blat.exe</div>
<div>
set freespacenum=1000000000</div>
<div>
rem shouldn't need to change any variable below here</div>
<div>
rem usage drv-space.bat servername</div>
<div>
set server=%1</div>
<div>
echo processing server %server% at %date% %time%</div>
<div>
for /f "tokens=2" %%W in ('date /t') do set dater=%%W</div>
<div>
for /f "tokens=1,2 delims=:" %%t in ('echo %time%') do set timer=%%t:%%u</div>
<div>
for /f "tokens=1-3 delims=/" %%d in ('echo %dater%') do set curdate=%%f%%d%%e</div>
<div>
for /f "tokens=3 delims=/" %%y in ('echo %dater%') do set curyear=%%y</div>
<div>
echo checking drive space</div>
<div>
for /f "tokens=3" %%s in ('dir \\%server%\c$ ^|find "free"') do set drvct=%%s</div>
<div>
for /f "tokens=3" %%s in ('dir \\%server%\d$ ^|find "free"') do set drvdt=%%s</div>
<div>
for /f "tokens=3" %%s in ('dir \\%server%\e$ ^|find "free"') do set drvet=%%s</div>
<div>
rem strip out the commas from the values</div>
<div>
set drvc=%drvct:,=%</div>
<div>
set drvd=%drvdt:,=%</div>
<div>
set drve=%drvet:,=%</div>
<div>
echo checking if we have at least a gig on drive c. </div>
<div>
if %drvc% LSS %freespacenum% goto emailwarning</div>
<div>
goto savetocsv</div>
<div>
:emailwarning</div>
<div>
echo on </div>
<div>
echo we got less then 1 gig</div>
<div>
rem if we have less then one gig we need to send an e-mail, but only if we haven't already done so today. </div>
<div>
if exist %temp%\%server%-%curdate%-low-space-msg.txt goto savetocsv</div>
<div>
echo apparently need to email about %server% at %time%, only %drvc% bytes free</div>
<div>
echo drive c on %server% has only %drvct% bytes of free space on it as of %date% %time% > %temp%\%server%-%curdate%-low-space-msg.txt</div>
<div>
%blatexe% %temp%\%server%-%curdate%-low-space-msg.txt -to %tech%@%techdom% -server %mailserver% -f %COMPUTERNAME%_drv-space-check@%machinednsdomain% -s "%server% low on free space"</div>
<div>
:savetocsv</div>
<div>
if not exist %server%-free-space-%curyear%.csv echo date ,time ,drive c ,drive d ,drive e >> %server%-free-space-%curyear%.csv</div>
<div>
echo saving to csv %time%</div>
<div>
echo %date% ,%timer% ,%drvc% ,%drvd% ,%drve% >> %server%-free-space-%curyear%.csv</div>
</div>
<div>
<br /></div>
<div>
rem -----------------end of script----------------</div>
<div>
<br /></div>
</div>
ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com0tag:blogger.com,1999:blog-6474827098489077555.post-74150376231306143302013-02-21T18:30:00.000-05:002013-02-28T14:22:48.899-05:00freeing space, move uninstall packsAny modern version of windows has many, many, updates over the course of its lifetime (2000, xp, vista, 7, etc...). While you probably knew this already, you may not know that every time you install the windows updates (which are vital to keeping your system secure, and hopefully more stable), there is a folder created which stores some files in case you need to uninstall them. This folder is under the windows system directory (usually c:\windows), and looks like $NtUninstalllKB######$ where ###### is some 6 digit number (and it may become 7 digits some years from now). <br />
<br />
On server 2003, if you keep it up to date these files now take up a little less then a gig worth of space. For most desktops this isn't an issue especially in an office, unless the person is filling up their hard drive with huge multi-media files. On our servers at work though, drive C (where we have windows), was for some strange reason set to only 12gigs, and as some of these servers are in remote locations (I support offices in 7 different cities across the state), I can't just re-size the partition, and as it's a 6 year old server still under a support contract, I can't just add a drive, so I have to move whatever I can off of the drive. There's the usual items of course, uninstall programs you don't need, move unneeded files, clear out the temp directories, empty the recycle bin, etc...., but I needed to be more aggressive, as some things just had to be on drive C that took up a huge amount of space. <br />
<br />
If you do some checking, various sites, and Microsoft say that you should be able to remove the $NtUninstalllKB######$ folders, but me being the overly cautious sort, didn't want to just delete them, so I decided I want to move them to a different drive, but also still have windows be able to use them via junctions. A junction is like a hard link for a directory under linux. You can have a folder on a drive and you can have multiple junctions that also point to that folder, but as far as any programs are concerned they don't realize it's a junction they went through it just looks like another copy of the folder. <br />
<br />
My script will move the $NtUninstalllKB######$ folders from c:\windows to a folder on another ntfs drive on the local machine and then create identical junctions for each of the folders on c:\windows that point to the new location. <br />
<br />
<a href="http://thescriptingadmin.blogspot.com/2013/02/monitoring-free-space.html" target="_blank">Once you've cleared out a good amount of space on your drive, check out my script to alert you before you run out of space. </a><br />
<br />
You will need the sysinternals tool junction.exe<br />
<a href="http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx">http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx</a><br />
about junctions: <a href="http://en.wikipedia.org/wiki/NTFS_junction_point">http://en.wikipedia.org/wiki/NTFS_junction_point</a><br />
<br />
about the $NTUninstallKB##### folders<br />
<a href="http://support.microsoft.com/kb/956324/en-us">http://support.microsoft.com/kb/956324/en-us</a><br />
<a href="http://seanconnolly.com/archive/2009/07/31/can-i-delete-ntuninstall-folders-in-the-windows-directory.aspx">http://seanconnolly.com/archive/2009/07/31/can-i-delete-ntuninstall-folders-in-the-windows-directory.aspx</a><br />
<br />
<br />
<br />
rem ----------------------script starts here-------------<br />
<br />
@echo off<br />
<br />
rem this is meant to make room on drive c for older servers<br />
rem that have drive c be too small, but other drives where<br />
rem drive c files can be moved to.<br />
<br />
<div>
set junexe=d:\mis\single-progs\junction.exe<br />
if not exist %junexe% goto error</div>
<div>
rem no trailing backslash<br />
set dstloc=e:\windows<br />
if not exist %dstlock% goto error<br />
<br />
echo processing %computername% at %date% %time%<br />
<br />
rem extract current month, year, date, etc...<br />
for /f "tokens=2" %%W in ('date /t') do set dater=%%W<br />
rem for /f "tokens=1,2 delims=:" %%t in ('echo %time%') do set timer=%%t:%%u<br />
for /f "tokens=1-3 delims=/" %%d in ('echo %dater%') do set curdate=%%f%%d%%e<br />
for /f "tokens=3 delims=/" %%y in ('echo %dater%') do set curyear=%%y<br />
for /f "tokens=1-3 delims=/" %%d in ('echo %dater%') do set curmonth=%%d<br />
for /f "tokens=1-3 delims=/" %%d in ('echo %dater%') do set DOMC=%%e</div>
<div>
rem only if the current month is february or later do we compute the last month<br />
rem and set the lastmonth variable to year.<br />
if %curmonth% GTR 1 set /a lastmonth=%curmonth% - 1<br />
if "%curmonth%" == 01 set lastmonth=year<br />
rem if the lastmonth is before november, add a zero in front of it<br />
if %lastmonth% LSS 10 set lastmonth=0%lastmonth%<br />
<br />
<br />
<br />
:uninstallpacks<br />
<br />
rem uninstall packs, take up almost 1gb on the server when uncompressed (compression can only do so much). <br />
<br />
if exist %temp%\ntupdateuninstalls.lst del %temp%\ntupdateuninstalls.lst</div>
<div>
for /f "tokens=5" %%d in ('dir /a:d c:\windows\?NtUninstallKB* ^|find /v "JUNCTION" ^|find /v "%curyear%"') do echo %%d >> %temp%\ntupdateuninstalls.lst</div>
<div>
if "%lastmonth%" == "year" goto copyandlink<br />
rem if we're in january just do last years stuff.<br />
rem if we're in a latter month and it's less then 10 days into the current month, we don't want to move<br />
rem last month's items, otherwise we'll move everything except for this months.<br />
<br />
if %curdate% LSS 10 for /f "tokens=5" %%d in ('dir /a:d c:\windows\?NtUninstallKB* ^|find /v "JUNCTION" ^|find /i "%curyear%" ^|find /v "%curmonth%" ^|find /v "%lastmonth%"') do echo %%d >> %temp%\ntupdateuninstalls.lst<br />
<br />
if %curdate% GEQ 10 for /f "tokens=5" %%d in ('dir /a:d c:\windows\?NtUninstallKB* ^|find /v "JUNCTION" ^|find /i "%curyear%" ^|find /v "%curmonth%"') do echo %%d >> %temp%\ntupdateuninstalls.lst<br />
<br />
:copyandlink<br />
<br />
for /f %%l in ('type %temp%\ntupdateuninstalls.lst') do robocopy c:\windows\%%l %dstloc%\%%l /e /z /move<br />
<br />
for /f %%l in ('type %temp%\ntupdateuninstalls.lst') do %junexe% c:\windows\%%l %dstloc%\%%l<br />
<br />
rem for /f %%l in ('type %temp%\ntupdateuninstalls.lst') do compact /c %dstloc%\%%1<br />
<br />
del %temp%\ntupdateuninstalls.lst<br />
echo finished at %time%<br />
pause<br />
goto end<br />
<br />
:error<br />
echo you need to have junction.exe from sysinternals, and set<br />
echo the junexe variable to point to the file, currently it's %junexe%<br />
if exist %dstloc% goto end<br />
echo make sure that you create a destination folder (perferably on a different drive<br />
echo on a separate drive from your windows install) and set the dstloc variable<br />
echo to reflect that location, currently it's %dstloc%<br />
echo make sure to not end with a backslash</div>
<div>
set /p mkdstloc=should I try to create %dstloc% (y/n):<br />
if /i "%mkdstloc%" == "y" mkdir %dstloc%<br />
<br />
:end<br />
<br />
rem ----------------------script ends here-------------</div>
ncc usshttp://www.blogger.com/profile/03064193027716876372noreply@blogger.com1