You are currently browsing the archive for the Scripts category.

I had to lately migrate some hidden shares from one server to another.
I wanted to use “File Server Migration Wizard”, but could not, as Windows 2008 R2 Standard edition will not let you do it, because you do not run enterprise or data-center edition. I got a little annoyed about this and quickly googled for solution. I found the solution described below here posted by Doug_H.

First thing, copy your folders, just use ROBOCOPY to do it for you and it will copy your security attributes too, like in example below:

SET _source="\\server01\d$\Users"
SET _dest="D:\Users"
SET _options=/R:0 /W:0 /LOG:C:\temp\Users_log.txt /NFL /NDL
ROBOCOPY %_source% %_dest% %_what% %_options%

Then we share the folders. My share names are the same as folders names, and hidden $.
So first you populate a file with the folder names, use cmd:

 DIR /A:D /B > c:\temp\dir_list.txt 

and then you query thru the file and use net share to share your folders with permissions you want like in example below:

 for /F %%X in (c:\temp\dir_list.txt) do (net share %%X$=d:\Users\%%X /GRANT:AdminGroup,FULL /GRANT:%%X,CHANGE) 

The command above has to be run in .bat file, so you need to create one, for example: sharefolders.bat and have the command entered in there, then you run it.

And we are done. Pretty simple, obvious and useful, so sharing.

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.

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.

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.

Locations of visitors to this page