Archive for the ‘Documentation’ Category

Limit bandwidth utilization using iptables.

I used the following in an attempt to the limit bandwidth utilization of the few IP address on my network. Used this on a CentOS6 firewall. I will see how it works over time. It seems to work fine, but I need to do more testing. I used the limit numbers I did based on the total amount of bandwidth available, and how much I wanted to limit it. I basically tested different settings to get the numbers right. Now, I just need to see how it impacts the usage. In other words, is it usable as a solution for a small network?

Create the chain:
iptables -N MYCHAIN

Send traffic I want to the chain:

iptables -I INPUT -s IPSorSUBNET -j MYCHAIN
iptables -I FORWARD -s IPSorSUBNET -j MYCHAIN

Configure the limit module to limit bandwidth in the chain:
iptables -A MYCHAIN -m limit –limit 5/second –limit-burst 10 -j ACCEPT

Drop any traffic that exceeds the limit:
iptables -A MYCHAIN -j DROP

Update: I found using a different limit-burst unusable. However, keeping the limit and the limit-burst equal seems to actually be working well thus far. I have found that having the limit and limit-burst equal to 10 per second on my 1.3Mb/s connection works well.

Display all Active Directory attributes for a single object.

Here is how to list all the Active Directory attributes for an object from the command line using the ldifde command:

Object path as found in dsa.msc: domain.com/someOU/objectname

ldifde -d “CN=objectname,OU=someOU,DC=domain,DC=com” -f con

PowerShell notes.

Check execution policy to allow you to run PowerShell scripts:

Get-ExecutionPolicy
To allow yourself to execute powershell script:
Set-ExecutionPolicy RemoteSigned
or
Set-ExecutionPolicy AllSigned
or
Set-ExecutionPolicy Unrestricted

Display all users login script:
PS> Get-Aduser -Filter * -Properties ScriptPath

Map a network drive using PowerShell:
(New-Object -com WScript.Network).MapNetworkDrive(“Y:”,”\\servername\sharename”)

Help New-PSDrive -full

Manage PowerShell drives:
Get-PSDrive

PS C:\Scripts> Get-PSDrive

Name Used (GB) Free (GB) Provider Root
—- ——— ——— ——– —-
Alias Alias
C 45.88 187.01 FileSystem C:\
cert Certificate \
Env Environment
Function Function
G 1113.88 282.94 FileSystem G:\
HKCU Registry HKEY_CURRENT_USER
HKLM Registry HKEY_LOCAL_MACHINE
I 1113.88 282.94 FileSystem I:\
S 1113.88 282.94 FileSystem S:\
U 302.15 47.85 FileSystem U:\
V 1113.88 282.94 FileSystem V:\
Variable Variable
WSMan WSMan
Y 592.14 431.73 FileSystem Y:\
Z 592.14 431.73 FileSystem Z:\

This only remove drives available in the PowerShell environment.

Remove-PSDrive -Name name
PS C:\Scripts> Remove-PSDrive -Name Y

To determine the PowerShell version:
PS H:\> $Host.Version

Hyper-V Related Commands
To display all VMs:
PS> get-VM

To shutdown all VMs:
PS> get-VM | stop-VM

Or, shutdown one VM:
PS> stop-VM -Name VMNAME

You can even use an * wildcard.
This will only stop all VMs with CANADA in the name:
PS> stop-VM -Name ‘*CANADA*’

To export all VMs:
PS> export-VM VMNAME -Path ‘EXPORTDIRECTORY

Example:
PS> Export-VM VMWIN2012 -Path ‘D:\Exports’

Or, you can use the following to export all your VMs ( After you stop them, of course.):
PS> Get-VM | Export-VM -Path ‘EXPORTDIRECTORY

To import/restore a VM:
PS C:\> Import-VM -Path ‘XMLfile

Example:
PS E:\> Import-VM -Path ‘E:\MYVMs\Virtual Machines\5FBF3F53-0A55-4124-883E-6F149A1E731E.XML’

To start a VM:
PS> Start-VM -Name VMNAME

Wildcard to start as well:
PS> start-VM -Name ‘*CANADA*’

Access information about files and directories:
This will display the file/directory name and what has access to it:
PS> Get-Childitem -LiteralPath somedirectory -Recurse | Get-Acl | Format-List -Property PSPath,AccessToString

To list all the Properties, use:
-Property *

Another way to determine disk size and free space:
PS> Get-WmiObject Win32_LogicalDisk -ComputerName remotecomputer | Select-Object DeviceID,Size,FreeSpace

To determine physical memory installed:
PS> Get-WmiObject CIM_PhysicalMemory

To determine processor installed:
PS> Get-WmiObject CIM_Processor

To list local user accounts on a machine:
PS> Get-WmiObject -Class Win32_UserAccount -Filter “LocalAccount=’True'” -Computername computername

Send email:
PS> Send-MailMessage -to ToEmailAddress -Subject “SomeSubject” -body “BodyTest” -smtpserver EmailServer -from FromEmailAddress

To run from a script or Task Scheduler, put the command in a ps1 file like Email.ps1, then in the script put: powershell c:\…\Email.ps1. Works great. You could associate ps1 with powershell and forgo the powershell command as well.

Get a list of computers from AD:
This will display all computers in AD that begin with the letter A:
PS> Get-ADComputer -Filter ‘samAccountName -like “A*$”‘ | Select Name

This will give you a list of all computers and their operating system, version and service pack level:
PS> Get-ADComputer -Filter ‘samAccountName -like “*$”‘ -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion

PowerShell to access a remote machine’s registry:
Note: I did this on a Windows 10 machine. Everything needed to be done from an elevated PowerShell prompt.
You need to download and install the PSRemoteRegistry powershell module from https://psremoteregistry.codeplex.com/.
Once installed, you need to import the module:
PS> Import-Module PSRemoteRegistry

PS> Get-RegValue -ComputerName COMPUTERNAME -Key “KEYNAME” -Value VALUENAME

Here is an example. This will pull the value from the LOCAL MACHINE hive:
PS> Get-RegValue -ComputerName COMPUTERNAME -Key “SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon” -Value CachedLogonsCount
Set a Value on a remote computer using the same PSRemoteRegistry module:
PS> Set-RegString -Computer COMPUTERNAME -Key “SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon” -Value CachedLogonsCount -Data “0”

How to find all LockedOut ADS accounts:
PS> Get-ADUser -LDAPFilter “(objectClass=User)” -Properties Name,LockedOut | Select Name,LockedOut | findstr “True”

To unlock and account:
PS> Unlock-ADAccount -Identity SamAccountName

Unlock script sample:

CLS
$logfile = “\\servername\C$\Tools\UnlockAccounts-$(Get-Date -Format `”yyyyMMdd`”).log”
function MyLog($somestring)
{
$somestring | Out-File -Filepath $logfile -append
}
Write-Host “Below is a list of currently locked out accounts:”
Get-AdUser -LDAPFilter “(objectClass=User)” -Properties SamAccountName,LockedOut | Select SamAccountName,Lockedout | findstr “True”
$Acct = Read-Host -Prompt ‘Which account would you like to unlock’
If ($Acct)
{
Write-Host “Attempting to unlock ‘$Acct'”
Unlock-ADAccount -Identity $Acct
MyLog “$(Get-Date -Format `”MM/dd/yyyy hh:mm:ss tt`”) Unlock attempted for account: $Acct.”j
}
Else
{
Write-Host “No account was entered.”
}
PAUSE

To list the file permissions of all files and directories under a directory:

PS> Get-ChildItem -Recurse directory | Get-Acl | Format-List

Windows 7 and large tiff files.

The default Windows Photo Viewer does not give you the same printer options when dealing tiff files containing many pages.

The solution I have used on a Windows 7 machine with Office 2010 already installed is to download and install the Microsoft Office Document Imaging portion of .

I started by choosing a custom installation and setting everything to Not Available. Then, under Office Tools I chose Microsoft Office Document Imaging and selected Run all from My Computer, and proceeded through the installation.

Once installed, I right moused clicked on a tiff file, and selected “Open with.” Then, I selected “Choose default program.” Click Browse, and navigate to C:\Program Files\Common Files\microsoft shared\MODI\12.0 and select MSPVIEW.EXE. Ensure that “Always use the select program to open this kind of file” is checked, if you want to open all tiff file with this application.

This will allow you print the entire tiff or select pages to print as you could previously with Windows Photo Viewer.

How to move WordPress comments using MySQL.

Used the following method to move comments in WordPress 3.

Key information needed:

Determine the post ID (comment_post_ID) for where the comment was made. You can determine this from the WordPress Dashboard. In this post, (http://jim-zimmerman.com/?p=781) 781 is the comment_post_ID.

Determine the post ID (comment_post_ID)for where the comment should go.

Determine the comment ID (comment_ID). There are many ways you could determine this, but you should probably choose something unique to the comment like the comment_author_email that you should be able to get from the comment.

Move the comment:

mysql> UPDATE wp_comments SET comment_post_id=”newcommentpostid” WHERE comment_post_ID=”oldcommentpostid” AND comment_author_email=”commentauthoremail“;

Determine the number of comments where the post has moved to:

mysql> SELECT COUNT(*) FROM wp_comments WHERE comment_post_id=”newcommentpostid“;

Determine the updated number of comments for the post where the comment was originally made:

mysql> SELECT COUNT(*) FROM wp_comments WHERE comment_post_id=”oldcommentpostid“;

Update the counts for each of the posts:

mysql> UPDATE wp_posts SET comment_count=”newcommentcountwhereadded” WHERE id=”newpostid“;

mysql> UPDATE wp_posts SET comment_count=”newcommentcountwhereremoved” WHERE id=”oldpostid“;

CyanogenMod 9 and Ice Cream Sandwich on the original Samsung Galaxy Tab (T-Mobile version).

Well, I finally got around to looking into getting Ice Cream Sandwich (Android 4.0.x) on my original Samsung Galaxy Tab. This is extremely experimental, and I can tell you that I had no 3G access using the 20120704 nightly build. However, the 20120708 build does seem to be working. I don’t believe that this due to the build, but that at some point in the process, I didn’t do a “wipe data” and “wipe cache”. From a stability perspective, you might want to stick with Gingerbread, and go with the latest Overcome version to get Android 2.3.6, however despite the rough start it does seem to be working well and I like ICS a lot.

Anyway, I am going to try recall the steps I took to get to this point. I usually try to document as I go when getting into these things, but this one was a challenge. However, I do feel that I have the basics, since I went through this several times.

There are two important things that are key. One is being able to get your Tab back to stock Ginderbread using Overcome. The other is getting the correct CWM Recovery version (5.5.0.4) installed.

I used Windows 7 64 bit to run ODIN to install the Overcome related ROMs.

Software:
Here is the source for all the Overcome software used: http://www.teamovercome.net/p1000/?page_id=17]

Stock safe Gingerbread: http://www.teamovercome.net/p1000/wp-content/plugins/download-monitor/download.php?id=1

Overcome Kernel: http://www.teamovercome.net/p1000/wp-content/plugins/download-monitor/download.php?id=4

Overcome 4.1.0 Wipe Edition ROM: http://www.teamovercome.net/p1000/wp-content/plugins/download-monitor/download.php?id=2

Modem (Modem-TMO.zip): http://www.teamovercome.net/p1000/wp-content/plugins/download-monitor/download.php?id=9

Cyanogenmod 9: http://get.cm/?device=p1 Note: There are different versions for the CDMA Tabs. The T-Mobile version is referred to as the p1 version. p1c is the CDMA version.

Google Apps: http://cmw.22aaf3.com/gapps/gapps-ics-20120317-signed.zip

Cyanogenmod 9 T-Mobile Modem software: (modem-galaxytab-t849uvjjb.zip): http://cmw.22aaf3.com/p1/p1/radio/modem-galaxytab-t849uvjjb.zip

Process used:
Ensure that your computer is able to see the device properly. Windows 7 should be able to detect the Galaxy Tab without issue.

With all the software downloaded to a working directory, unzip GB-Stock-Safe-v5.zip, and the Modem-TMO.zip files.

Put the Tab into Download mode. To put it into Download mode, power it off. Then, hold the power button and the volume down on the volume rocker. Connect the Tab to your computer via the USB cable.

Start odin. Note: I am not sure what the deal with this is, but it is not clear where you can find this. I have been using a very old version, however, I did find this link to a version from 5/25/2012: http://androidfirmwares.net/Tools/Download/8 and other file sharing sites. You will know that the drivers used to detect the Tab are sufficient, if you see “COM:#” highlighted in ODIN.

Click the PIT button, and browse to and select the gt-p1000_mr.pit from the GB-Stock-Safe-v5 directory.

Click the PDA button, and browse to and select the GB_Stock_safe_v5.tar file from the GB-Stock-Safe-v5 directory.

Next, click the PHONE button, and browse to and select the modem.bin file in the Modem-TMO directory. NOTE: It is very important that you select the correct modem software. These are the instructions I used on a U.S. T-Mobile Galaxy Tab.

Click the START button. You should see a PASS notification appear in ODIN once complete, and the Tab will reboot.

This will install a fresh stock version of Gingerbread. Next, you need to install the Overcome kernel.

Run through the wizard on the Tab, and enable Mass Storage. Unplug the device, go to Settings/Wireless and Network/USB Settings and choose Mass Storage. Plug the Tab back in, and copy the Overcome_7_Series_v4.1.0_Wipe.zip file to the root of the Tab.

Power off the Tab and put in back into Download mode.

Launch ODIN, and use the same files for the PIT option and the MODEM option. However, for the PDA option select the Overcome_Kernel_v4.0.0.tar you downloaded earlier.

Click the START button. This time when it reboots the file system will be converted. This will take some time.

Once up, you need to put the Tab in Recovery Mode. Power off the Tab. Hold the power and volume up on the volume rocker. To navigate around these menus, you the volume rocker to move up and down, and the power button to select. Navigate to the “install menu”, and select “choose zip from internal sdcard.” Select the Overcome_7_Series_v4.1.0_Wipe.zip file copied to the Tab earlier.

Once completed, navigate to the reboot menu, and reboot the Tab. At this point, you should have Gingerbread 2.3.6 on your Tab.

Once up, disconnect the Tab from the computer, run through the wizard again and enable Mass Storage.

Plug the Tab back in, and copy the download CyanogenMod (cm-9-yyyymmdd-NIGHTLY-p1.zip), the Cyanogenmod 9 T-Mobile Modem software: (modem-galaxytab-t849uvjjb.zip), and Google Apps (gapps-ics-20120317-signed.zip) to the root of the Tab.

Put the Tab back in Recovery Mode, and choose the cm-9-yyyymmdd-NIGHTLY-p1.zip copied to the root of the Tab from the “choose zip from internal sdcard” option.

Now, this is where this get a little fuzzy for me. I believe I had boot issues at this point with 20120704 nightly build, however I noticed that the CWM Recovery version was now 5.5.0.4, so I did a “wipe data/factory reset” and a “wipe cache partition”. Then, I tried again and this time I also select the Google apps zip copied earlier and the T-Mobile Modem software: (modem-galaxytab-t849uvjjb.zip). This time ICS came up, and 3G worked, and seems to be working much better than I expected.

Below is a site that lists nightly changes, so you can determine whether you want to update:

CyanogenMod9 Changelog site: http://changelog.bbqdroid.org/#tenderloin/cm9

It would appear that using a ROM Manager is really not supported on this version of the Galaxy Tab. I haven’t tried to use it, because I have found nothing that indicates that it is supported.

So, if you want to update to a newer nightly build, I would recommend downloading the build and copying it to the root of the Tab and install it from Recovery Mode via “choose zip from internal sdcard”. You should probably do a “wipe data/factory reset” and a “wipe cache partition” prior to installing the update too.

UPDATE: I did an update to a last night’s build, and did not have to “wipe data” or “wipe cache”. It just took awhile for the 3G to come up after the first boot. Since then, it has been fine. Maybe you just need a little patience when installing the nightly builds.

How to disable/modify Junk E-Mail filter in Outlook 2010

Click the Home tab.

Click the Junk drop down in the Delete section, and go to Junk E-Mail Options.

Select the “No Automatic Filtering …” option.

Note: this will work as long as you do not have a group policy that sets this.

You can also access the Junk E-Mail Options by right mouse clicking on a message, going to Junk and select Junk E-Mail Options.

Downgrade iPhone 3Gs baseband from 06.15.00 to 05.13.04.

I suppose the first question is why downgrade the baseband now? Well, I got AT&T to unlock my 06.15.00 baseband 3Gs when it was announced that they would if you phone was no longer under contract. The only reason anybody installed the iPad (06.15.00) baseband was to unlock their phone. Since, it was no longer needed I wanted to be able to update my phone without having to use redsn0w to install a custom ISPW each time.

Software used:
Redsn0w 0.9.14b1.zip
iPhone2,1_5.1_9B176_Restore.ipsw

Download redsn0w 0.9.14b1.
Unzip redsn0w.
Download the version of IOS currently running on your device. 5.1 in my case.
Launch redsn0w.
Select Extras.
Click Select ISPW..
Navigate to the downloaded ISPW for your version.
Click Back.
Select Jailbreak.

If already jailbroken, uncheck Install Cydia and select Downgrade from iPad baseband.

Ensure that the phone is connected to your computer, and put it in DFU mode or hit Next and follow the prompts on the next screen. It might take you a few times to get the timing right.

Redsn0w will begin fetching baseband files.

The phone will reboot and you will get a message in redsn0w stating that the rest of the process takes place on your device.

On your phone, you will see several message on your phone relating to disk checks and then the familiar running pineapple on screen. Be patient.

Your phone will reboot with the downgraded baseband.

Now, if you want to go back to a completely stock installation, you will need to restore the most currently supported version of IOS (5.1.1 for the 3Gs), after putting the phone back into DFU mode.

How To Remove Jailbreak from iPhone 4s

A couple things I discovered when attempting to remove the jailbreak from my iPhone 4s:

1) You cannot just delete the Cydia icon. When you press down on the icon and all the icons start wiggling, you have no option to press the “x” to delete the icon.

2) If you try to reset the phone by going to Settings/General/Erase All Content and Setting, this process will either never start or never finish. You end having to hold Power+Home to restart the phone.

So I tried to restore the phone. I was running 5.0.1 and wanted to keep it that way. Now, the simplest way to do it would have been to put the phone in DFU mode and download and restore the latest version of IOS from Apple. However, as I stated I wanted to try to keep the same version of IOS, 5.0.1 in my case. I downloaded the latest version of redsn0w , unzipped it and ran it. With the phone in DFU mode, I chose Extras/Even More/Identify. This verified that my phone was in DFU mode. Next, I went into Extras/Even More/Restore, and clicked ISPW and browsed to the version of IOS I wanted to restore. At this point, you are prompted to browse to the most current version of IOS (5.1.1 in my case). This is required to upgrade the baseband. If you do NOT want upgrade the baseband, DO NOT DO THIS! Once the latest version of IOS has been identified, you need to tell redsn0w where to find your shsh blobs. I chose remote to pull them from the Cydia servers, Once that is done, click Next and the baseband is upgraded and IOS 5.0.1 is restored. If you want to preserve your baseband, then you need to go the Extras/Custom IPSW route.

Add a Windows 2003 shared printer to a Windows 7 client.

While trying to connect to shared printer on a Windows 2003 server (32 bit) from a Windows 7 (32 bit) client, I kept getting a “Windows cannot connect to the printer. Operation failed with error 0x0000002.” I stumbled on an interesting little trick to get around this issue.

First, I created the printer locally and allowed Windows 7 to install the appropriate driver. After the printer has been created, I went into the printer Properties and clicked on the Ports tab. Then, Add Port… Select Local Port, and click New Port… Enter the UNC to the printer share name. For example, \\servername\printersharename.

Then, the printer worked an used the Windows 2003 print share. It is not the cleanest solution, but it does get the printer working using the shared printer on the Windows 2003 server.

Return top

INFORMATION