I know, I know… why don’t you just go to the Illinois Lottery website and check the numbers? Yes you can, but as I am playing with Powershell and looking for something interesting to do and research, I got this idea (It came to me after I checked my ticket and realized that I did not win anything, again.) to create a script to get all info I needed from Illinois Lottery website and send it to my email. The sending email portion is not in this piece of code, but this part you can figure out on your own :) , and you can even probably send the final output thru some SMS gateway.
You can schedule it to run on daily basis. The Illinois Lottery website is updated ~one hour after the numbers are picked.

Here is the Code.

One way of doing it.

I like the way it is done. I hope this will be useful to someone, and you can use it in a lot of ways.
You can fin it here: ConvertTo-HTML example

Good luck :)

Recently I had to setup a system that would let me know if my servers, switches, printers are up and running. Any more information that I could get from the monitoring system would be a huge PLUS. Status of the services, hard drive sizes, memory usage, Uptime, CPU Usage, Printers status, etc… if anything happens, then system sends me an email so I could start troubleshooting the problem shortly after error/issue occures.
I looked as always for a system that could be open source, community supported and the best in what it supposed to do.

I found NAGIOS.

If you look for somthing free, this is the best thing you can get there, as far as I am aware at this moment.
You can install/configure a lot of different plugins that will allow NAGIOS to monitor a lot of different devices.

Easily, once installed, you can configure monitoring of your servers, printers, switches, using Templates/Examples that are included.

One of the problems that I had to look into was monitoring of CANON printers, and properly modifying Nagios config files for that:
Once you understand a little how NAGIOS works you will understand what I am trying to show you here in example:

in /usr/local/nagios/etc/objects/commands.cfg I added a command:

define command{
          command_name check_snmp_canon
          command_line $USER1$/check_snmp -H $HOSTADDRESS$ -l STATUS -C public $ARG1$ $ARG2$
          }

then in: /usr/local/nagios/etc/objects/printer.cfg you define host and service like this:

define host{
          use          generic-printer
          host_name    SOMECANONPRINTER
          alias        SOMECANONPRINTER Alias
          address      "IP of the printer goes here"
          hostgroups   network-printers
          }
define service{
          use                   generic-service
          host_name             SOMECANONPRINTER
          service_description   Printer Status
          check_command         check_snmp_canon!-o hrDeviceStatus.1 -r "2|3"
          normal_check_interval   10
          retry_check_interval  1
          }

That should work. Make sure you check file configuration the way Nagios suggest to do it, before you attempt to restart nagios.

Right now, I am in a process of configuring a plugin that will allow me to use data that Dell Openmanage gathers on server, and once there is something wrong with hardware nagios will notify me. If you interested in looking into it then take a look at this link.

PS:.
There is one cool product out there: Microsoft System Center Operations Manager. Once I get my hands on it, and will have a chance to play in the system I will write probably a few good words about that.

The time has came, it is now time to migrate one of my File Servers from Microsoft Windows Server 2003 Enterprise to a new server with Microsoft Windows Server 2008 Enterprise. I want to migrate all my shares including share and folder permissions. To minimize time spent on this project I had to find a tool that could do it for me fairly easily. I know that there are tools you can purchase online that can do this for you, like for example: “Secure Copy”, but who wants to spend money those days for such a tools, and as always there are for sure alternative free tools somewhere out there to do it for you. After googling for a minute, I found a tool that Microsoft created for us for this scenario: “Microsoft Server Migration Toolkit“.
You can install it on your new Windows Server 2008 and run a File Server Migration Wizard that will guide you thru the whole process. One thing to mention is that, this tool is not perfect, unless I was maybe doing something wrong :)
When you add your shares, from a specific server, you have to make sure that for each share you check, the appropriate “Target Volume” is set, including share name and share location. If you will not do it, the shares copied will not be as identical as on your original server. Correcting each share might take some time, it all depends on how many of them you have.

So If you don’t want to bother to copy folders, and share them again, and set permissions on those folder again manually for a few hours, you can use that tool and save some time.

File Server Migration Wizard

File Server Migration Wizard

Or… You can always read this HOWTO
.

Calling Powershell scripts (.ps1) using Batch (.bat) files. As you can tell, I have SomeScript.ps1 in the same directory as .bat file I launch.

"C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe" -File "%~dp0SomeScript.ps1"

… and when I goolged, there were some other solutions as well for this… This way works for me so far.

The idea was to call any powershell script (.ps1),  located in the same folder as that .vbs script:

Code:

Dim sCurPath
sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
'WScript.Echo sCurPath

Set objShell = CreateObject("Wscript.Shell")
objShell.Run("powershell.exe –noexit &'" & sCurPath & "\SomeScript.ps1'")

I hope it helps someone.

Something new got created in PowerShell 2.0 for users who create scripts. It is called PowerShell Integrated Scripting Environment (ISE) and you can find executable where you have powershell installed, “powershell_ise.exe” and I found it in “C:\WINDOWS\system32\windowspowershell\v1.0″.
After you start it, you will see window looking like this:
ps20ise

Someone already online created some aliases that you can add to your powershell profile, so when you type let’s say: “ise” in powershell it will open ISE.
So yeah, if you google it, you will find somewhere a note on that code:

function Invoke-ISE{
param (
[string[]]$file,
[string]$path="$pshome\powershell_ise.exe"
) 

if($file){
foreach($f in $file){
   & $path (resolve-path $f)
}
} else {
   & $path
}
}

Set-Alias ISE Invoke-ISE

From Microsoft site.
From a blog :)

Have fun using ISE.

Self explaining piece of code:

#———————————————————————————————————————————–
#Email options for automated emailed report
$smtpServer = “YOUR SMPT SERVER ADDRESS”
$txtFilePath = “c:\somefile.txt”
#
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($txtFilePath)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)

$msg.From = “Some Email Address”
$msg.To.Add(”Some Email Address”)
$msg.Subject = “Some Subject”
$msg.Body = “Some Body Data”
$msg.Attachments.Add($att)

$smtp.Send($msg)
#———————————————————————————————————————————–

Here is a list of special characters.

* `O – inserts a null value
* `a sends an alert (bell or beep) to the computers speaker
* `b inserts a backspace
* `f inserts a form feed
* `n inserts a new line
* `r inserts a carriage return
* `t inserts a horizontal tab
* `v inserts a vertical tab
* `’ inserts a single quote
* `” inserts a double quote

This is driving everyone crazy, and it is weird that Adobe did not fix that yet.
When you try to Export document as .jpg from IL CS3, you get the error “Insufficient memory available to complete the operation”.

Ok, so what is going on?

When you export the document to .jpg, there will show up a pop up window with some settings and you will have a choice to set default .dpi. Click CUSTOM, and enter something lower than the default value. I had to lower the value from 150 to 110 to be able to export the document to .jpg file.

Hope this works for someone.

Locations of visitors to this page