Archive for July, 2012

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

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 = “\\MO-DC01\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.

Return top

INFORMATION