This is going to be a quick one. I'm working on a new Powershell script (my second) and I'm doing some sanity checks before I actually try to continue the workflow.
If you run the command below and it returns only one item and then either try to print out $fileCount or run an if statement or something against it like if ($fileCount -gt 0){do some stuff} the "do some stuff" won't happen.
#$fileCount = $(get-childitem C:\ -filter *.zip).count
This is because the count method returns an array, which if only one item is in it doesn't get created and thus is 0. To get around this you must create the array first. You can do this in the same line of code as shown below.
#$fileCount = @(get-childitem C:\ -filter *.zip).count
The at sign there will create the array and you will have one item in it.
Showing posts with label Windows 2008 Server R2. Show all posts
Showing posts with label Windows 2008 Server R2. Show all posts
Tuesday, September 20, 2011
Tuesday, September 13, 2011
File Checksum Integrity Verifier utility or SHA1 / MD5 checksum utility for Windows
On Linux if you need to verify the file you just downloaded is untouched you run either sha1sum or md5sum on the file to get the checksum and verify it against the published checksum. There are some utilities available for Windows, but today I'm going to point the spotlight at a Microsoft offering, File Checksum Integrity Verifier or fciv for short. You can grab the download from Microsoft's site.
There are a few options available when you run the command, such as -md5 to get the md5 checksum of a file or -sha1 to get the sha1 checksum of a file. But you can also use the -both flag to get both checksums of a given file. You can even create you own database of checksums to verify the files later.
To generate the checksums and store them in the database (xml file) run:
>fciv -both -xml fcdatabase.xml filetocheck.txt
The command above will obviously store both checksums and on a large file could take a while to run, as it needs to run twice on the file, once for the sha1 sum and once for the md5 sum. You of course can use one or the other check sum algorithm if you prefer (I prefer sha1 for the time being).
To later verify a file against the database you run the command shown below:
>fciv -sha1 -xml fcdatabase.xml filetocheck.txt
Now if you make changes to filetocheck.txt and run the command below you will see that verifying the file against the database it has changed. If this where an executable it may either be corrupt or compromised. If it was the project you've been working on for weeks, now is a good time to restore from backup, if the change wasn't expected of course.
>fciv -v -xml fcdatabase.xml filetocheck.txt
You'll see something like:
c:\users\mymcp\fcdatabase.xml
Hash is : 48a5967227b85c6805f3210832a155da
It should be : 04518689efadfdf2393b533dc9c7c8b5
My only real complaint is that fciv doesn't show any sort of progress while processing a large directory. It would be nice to see a file names flying by the screen or something. All in all though this is a tool worth checking out if you run Windows and don't have another tool already in your arsenal.
I would like to know if any of you have a tool in your arsenal already for this purpose and what it is / where I can find it. Sadly I don't recall any of the tools I've used in the past, but this one may become my tool of choice for this job.
There are a few options available when you run the command, such as -md5 to get the md5 checksum of a file or -sha1 to get the sha1 checksum of a file. But you can also use the -both flag to get both checksums of a given file. You can even create you own database of checksums to verify the files later.
To generate the checksums and store them in the database (xml file) run:
>fciv -both -xml fcdatabase.xml filetocheck.txt
The command above will obviously store both checksums and on a large file could take a while to run, as it needs to run twice on the file, once for the sha1 sum and once for the md5 sum. You of course can use one or the other check sum algorithm if you prefer (I prefer sha1 for the time being).
To later verify a file against the database you run the command shown below:
>fciv -sha1 -xml fcdatabase.xml filetocheck.txt
Now if you make changes to filetocheck.txt and run the command below you will see that verifying the file against the database it has changed. If this where an executable it may either be corrupt or compromised. If it was the project you've been working on for weeks, now is a good time to restore from backup, if the change wasn't expected of course.
>fciv -v -xml fcdatabase.xml filetocheck.txt
You'll see something like:
c:\users\mymcp\fcdatabase.xml
Hash is : 48a5967227b85c6805f3210832a155da
It should be : 04518689efadfdf2393b533dc9c7c8b5
My only real complaint is that fciv doesn't show any sort of progress while processing a large directory. It would be nice to see a file names flying by the screen or something. All in all though this is a tool worth checking out if you run Windows and don't have another tool already in your arsenal.
I would like to know if any of you have a tool in your arsenal already for this purpose and what it is / where I can find it. Sadly I don't recall any of the tools I've used in the past, but this one may become my tool of choice for this job.
Thursday, March 03, 2011
Update to Promiscous Mode on vSphere 4
A few months back I wrote about Enabling Promiscuous Mode on vSphere 4. Well, I have learned some more since then. There isn't much information out there about recording a VoIP stream in a virtual machine environment. I hope to change that today.
First thing is first. If you are using VLANS on your physical network set your Virtual Machine Port Group to be a trunk. Also set the port on the physical switch to be a trunk instead of an access port.

Second thing, if you are using the E1000 NIC driver in your guest OS, turn off VLAN support. The screen shot is from Windows 2008 R2 64-bit, but it is similar in every other Windows OS.

Performance Best Practices for vSphere 4
First thing is first. If you are using VLANS on your physical network set your Virtual Machine Port Group to be a trunk. Also set the port on the physical switch to be a trunk instead of an access port.

Second thing, if you are using the E1000 NIC driver in your guest OS, turn off VLAN support. The screen shot is from Windows 2008 R2 64-bit, but it is similar in every other Windows OS.
Performance Best Practices for vSphere 4
Wednesday, February 09, 2011
Adding a vCPU to a Windows 2008 R2 guest
Last night I had to add an additional vCPU to a Windows 2008 R2 guest. I tried and tried to research doing this, but all I was able to find was how to Hot add a vCPU, which I didn't care to do. Also all of the VMWare documentation said to view a certain PDF to see what OSes could even take a Hot CPU addition, but I was unable to find anywhere in the PDF what OSes could handle it and which ones couldn't.
So I installed the newest patches (being patch Tuesday and all) and I shut down the server. I then went from one vCPU to two vCPUs. I ignored the warning that adding CPUs to an already installed system may cause it to be unstable.
So far the server has been stable and everything worked like I had hoped. I don't know if this would work on any of our Windows 2008 servers, or for that matter the CentOS 5.5 servers, but all of them already have two vCPUs.
If you are wondering why I needed to do this, well, it is because our VoIP recording solution uses MySQL, and for some reason it has been using 100% of the CPU for weeks now. This despite a mostly empty process list in MySQL.
So I installed the newest patches (being patch Tuesday and all) and I shut down the server. I then went from one vCPU to two vCPUs. I ignored the warning that adding CPUs to an already installed system may cause it to be unstable.
So far the server has been stable and everything worked like I had hoped. I don't know if this would work on any of our Windows 2008 servers, or for that matter the CentOS 5.5 servers, but all of them already have two vCPUs.
If you are wondering why I needed to do this, well, it is because our VoIP recording solution uses MySQL, and for some reason it has been using 100% of the CPU for weeks now. This despite a mostly empty process list in MySQL.
Subscribe to:
Posts (Atom)