Articles by Mariusz

You are currently browsing Mariusz’s articles.

Quick script  that I put together to Shutdown my VMware Server VM, copy it to a different spot, and then start it again. It  sends me an email in the end to let me know that the script ran. Using: vmrun.

Click HERE to see.

PS: Create new user in VMWare Server for backup purposes with specific permissions. Then modify the script.

I’ve been for quite some time studying Android programming, creating simple applications based on tutorials around the net. If you want to create apps for Android devices, for sure you have to start with JAVA, but… well… as soon as you start your research, you will find out about App Inventor for Android by Google. If you do not know anything about programming, and go over the documentation and follow a few tutorials for App Inventor, you will be creating “simple” applications pretty much very quickly, there are limits but … you can read about those.
After I went thru all the tutorials I could find on this topic, I got a request to create a simple application that Calculates Sale Price of a product for sale, based on specific chosen percentage Markup. Nothing complicated, I just had to find out mathematical equation that can do that and get a few blocks doing certain tasks.

So here it is for download… Calculate Sell Price. If you work for some Stores out there, and you are a person in charge of prices, it can be helpful.

If you are looking for info about FSRM then you might want to check out Microsoft website HERE first.

Some of you might be using it in your environment, so probably when you will be migrating data to some other server(s) then you would like to for sure migrate your Quota and File Screen templates quickly.

You will need to use DIRQUOTA and FILESCRN tools to perform those tasks.

Example of DIRQUOTA export/import command:

 dirquota template export /File:d:\DirQuotaTemplate.xml 
 dirquota template import /File:d:\DirQuotaTemplate.xml 

Example of FILESCRN export/import command:

 filescrn template export /File:d:\FileScrnTemplate.xml 
 filescrn template import /File:d:\FileScrnTemplate.xml 

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 _what=/COPYALL /B /SEC /MIR
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 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.

Friend of mine found it, online, somewhere… :) … but here it is, Very useful for me at this moment

For download: MDTAppsSort

It is so amazing that nVidia creates those drivers this way. It took me some time to find how it is done … and here it goes:

Record an answer file first by going:

  • setup.exe -r -f1C:\nvidia.iss

and do a install with all the options you want.
then save the answer file and you can silently install every time thereafter with:

  • setup.exe -s -f1C:\PATHTO.ISS

Found here

I am setting up Hyper-V on Dell PE 2950 with Windows 2008 Enterprise Server. Installed all needed roles and I created the first virtual machine. I tried to start it and I got this error:
“The virtual machine could not be started because the hypervisor is not running.”
What I found out is that in BIOS of this machine, under “CPU information” by default Virtualization is Disabled. All I had to do was to Enable it.

:) fun as always :)

Found this info on another forum, posted by jWeb. It worked for me, and as longs as it works for me I like it :)
So …. here it goes:
I used this open source player:

http://www.trenttompkins.com/Downloa…yer-2-RC1.html

I placed the following files in the same folder where my video files and my html page are:
AC_RunActiveContent.js
player8.swf
player.swf

My video file is arthur.flv and this is the code I placed in the html file:

The-Code-Is-Here



Thank you.

Yeah, I found it somewhere out there, but who knows where at this moment.
Anyways, good info so … here it goes:

The Windows Automated Installation Kit (WAIK) includes the Imagex utility, which, in addition to facilitating the capture and deployment of WIM images, can also be used to mount a WIM file so that you can access its content.

But before you can mount a WIM file, you need to install the WIM File System Filter, which is responsible for handling all file system requests to the mounted WIM file, enabling browsing and editing of its contents. To install the WIM File System Filter, navigate to the C:\Program Files\Windows AIK\Tools\x86 folder, right-click wimfltr.inf, and select Install. This will install and activate the wimfltr.sys file system filter.

After you install the WIM File System Filter, you can mount a WIM by following these steps:

1. Create a folder on the file system that will be used to access the WIM file content (e.g., d:\vistamount).

2. Start a command prompt with Administrative credentials (Start, Programs, Accessories; right-click Command Prompt and select “Run as administrator”).

3. Navigate to the C:\Program Files\Windows AIK\Tools\x86 folder on a machine with WAIK installed (assuming you’re running on an x86 architecture box).

4. Run the Imagex command with the /mount switch to open the WIM file in read-only mode or the /mountrw switch to open with full read and write abilities. Use the following command syntax: imagex
For example, to mount the first image of the standard Vista install.wim file to path d:\vistamount, use the following command:

C:\Program Files\Windows AIK\Tools\x86>imagex /mountrw d:\Sources\install.wim 1 d:\vistamount

You can then modify the WIM file via standard file system manipulation tools, such as the command prompt and Windows Explorer.

Once editing is complete, unmount using the Imagex utility with the /unmount switch, and if you wish to keep the changes made also add the /commit switch (if you don’t specify the /commit switch, all changes will be lost, and you won’t be prompted for confirmation). Unmounting without the /commit switch is significantly faster because it doesn’t have to convert file system changes to the relevant area inside the WIM file.

When you deploy your image using WinPE, it creates nice log under:
c:\Windows\temp\DeploymentsLogs

One TIP for whoever will read this, is:
Download “SMS 2003 Toolkit 2″ and check out “SMS Trace”.

If you want to analyze any of the logs, they are presented to you in human-readable form.

You will find out more small little useful applications, once you install the toolkit.

Ok, It took me, 4h to google for answer… but finally I found something what made me happy.

I installed Windows DS on my Win2003 server. Configured. As I have already WinPE .wim, we created it using MDT, I just imported it to WDS.

When I booted my client machine, I got this error:
TFTP
PXE-T01: File not found
PXE-E3B: TFTP Error - File Not Found

Was not sure what is going on, I tried a few things, solution/comments I found googling…

…and then from Microsoft TechNet Forums:

So, what’s probably going on here is that your x64 VM is reporting itself as x86. This is a common problem and can cause this kind of error.

You can work around it as you say by adding a 32-bit WinPE, or by turning on Architecture Discovery using
WDSUTIL /Set-Server /ArchitectureDiscovery:Yes

I turned on Architecture Discovery, and it worked for me, my client machine booted into our WinPE.

My friend from work (John B.) found something out when we experienced some problems with UAC and installing PDF printers. So, to keep note of it, adding it to the blog.

Here you go:
—————–
Looks like the GP settings for point and print are a bit tricky with Vista.
Instead of disabling Point and Print Restrictions (under User Configuration\Administrative Templates\Control Panel\Printers), it looks like you need to enable it and then configure the following settings inside:

  • Users can only point and print to these servers: Unchecked.
  • When installing drivers for a new connection: Do not show warning or elevation prompt.
  • When updating drivers for an existing connection: Do not show warning or elevation prompt.

I did this to the local group policy using gpedit.msc on two vista machines and was able to connect and print to the PDF server without any elevation prompts/access denied errors. I performed one test as an admin user and one as a standard user; both times UAC was enabled.
—————–

Trying to find out “Make and Model” of machines in your enviroment so you could correctly enter those in MDT database?

You can do this two ways:

1) Using Power shell

Get-WmiObject Win32_ComputerSystem

2) Using WMIC.EXE

wmic.exe csproduct get name,vendor

If you use DRIVERPATHS1=\\pathtoshare\%model% variable in your customsettings.ini then you have to create specific Folders with the exact name of the Model for the machine. Then you can copy to the folders the specific drivers for that Model, and later on WinPE will take care of it, its way :)

It’s nice.

Problem:
Photoshop currently does NOT let me open more than one file at a time. It crashes when I try to open more than one file, any type of file.

Solution:
I looked thru Adobe Froums and found the crazy solution: “The solution was to change the default printer in Windows to something else.”
This works and it’s a work around for the issue. Adobe does not have a fix yet as I can see :)

Thank you Google again.

Problem:
I’ve noticed that filenames are missing from Windows Explorer when looking at thumbnails. Previously they were visible.

Solution:
Hold down the shift key when switching to thumbnail view to hide the file
names. Do it again to bring them back.

Yeah, I am going crazy sometimes, because you change it once, and after a few months you forget how it’s done, and you try to find the right command again….
So… just note for me… link to a website with some good explanation:

Signing PowerShell Scripts

I googled a lot to find answer for this one, and I found one forum with the answer provided by “Stonelaughter”:

Close Outlook, and go to:

C:\Documents and Settings\\Local Settings\Application Data\Microsoft\

and rename the “Forms” folder. Then restart Outlook. The “Forms” folder is the forms cache, which apparently can become corrupt. When you rename (or delete it – not recommended) it forces Outlook to re-enumerate it. Bingo, problem solved.

Thanks man for contacting Microsoft Support :)

I needed some software/script to shutdown group of chosen computers at a time specified in windows scheduler. I Googled …. and after some research I put this script together:

$erroractionpreference = “SilentlyContinue”

$psSwitches = ” -s -f -c -t 30″
$psMessage = ” -m” + ‘ “Please press CANCEL button if you want to CONTINUE to work. DO NOT forget to shutdown your computer before you leave”‘

$strComputer = get-content “computers.txt”
$application = “psshutdown.exe”

Foreach ($i in $strComputer)
{
$arguments = “\\$i” + $psSwitches + $psMessage
[System.Diagnostics.Process]::start($application,$arguments)
# write-host $arguments
}

As you can see, I used one of the PSTools applications to do it :)
Powershell has it’s own ways to perform the task using Win32Shutdown Method of the Win32_OperatingSystem Class, and I will try it next time… ;)

I just used VMWare-Converter to pull off from a physical machine the MS Win OS.
I did not experience any problems, however when I booted the OS in VMWare Server I wanted to setup static IP address for it, and I could not do it.
System complained that there is hidden network adapter with the same(original) IP address already set for different local network adapter.
Quick search on VMWare forums and I found the comment:

First open up a command prompt, then type in:

SET DEVMGR_SHOW_NONPRESENT_DEVICES=1
START DEVMGMT.MSC

This should start up the device manager. Go into View->Show hidden devices. That should show the shadowed out nic card that needs to be removed in the Network Adapters area.

The solution worked like a charm :) and now I am up and running.

I want to mention that Ying Li created some scripts similar to this one. I just modified them to fit my needs.

I use Group Policy to add and remove Groups from Local Administrator Group, however something happened and when we modified our Group Policy to remove “Domain Users” Group(after some testing), it did not happen. We looked thru other GPOs and could not find anything. When we manually removed from test computer the “Domain Users” group from Local Adminsitrators group and we issued the command “gpupdate /force” and rebooted, the “Domain Users” group was not added back so definitelly it was not a policy.

So it was a weird behaviour and I decided to look for some VB scripts to do this for me, but as I started to learn PowerShell I decided to do some research and  at the end I came up with this script.

$erroractionpreference = “SilentlyContinue”

$domain = “yourdomain”
$username = “Domain Users”

$strComputer = get-content “computer_list.txt”

Foreach ($i in $strComputer)
{    $computer = [ADSI](“WinNT://” + $i + “,computer”)
$computer.name

$Group = $computer.psbase.children.find(“administrators”)
#    $Group.name
$Group.Remove(“WinNT://” + $domain + “/” + $username)

}

That’s it :)

I think you are going to like it:

http://blogs.msdn.com/powershell/archive/2006/04/25/583241.aspx

Note for myself:

$erroractionpreference = “SilentlyContinue”

Locations of visitors to this page