Windows screen orientation

You ever hit a series of keys on your Windows 7 keyboard and find your display orientation upside-down or side ways? Well, what you more than likely did was hit Ctl-Alt and one of your arrow keys. To get orientation right again, do Ctl-Atl-Up.

Evict MS Cluster node from the command line.

I have verified this in a Windows 2008 server cluster.

To evict a Microsoft cluster member from the command line, you need to first stop the Cluster Service.

net stop “Cluster Service”

Then, execute the following command to evict the node:
cluster clustername node nodename /evict

If really messed up and need to force the eviction, use:
cluster clustername node nodename /force

Android 4.1.1 (Jelly Bean) on a Samsung Galaxy Tab

Note: Definitely backup if you care about anything on your Tab. Also, do not do this if you are not prepared for the worse case scenario (bricking your device).

Note: This was done from a previous rooted installation of Ice Cream Sandwich on a T-Mobile Samsung Galaxy Tab. See http://jim-zimmerman.com/?p=763 for those instructions used.

Note: This is early stage stuff and an unofficial CyanogenMod10 release. One known issue I have verified is that the Camera application crashes when using the read camera. That is fine with me, since the camera is so poor that is hardly worth the effort of using.

The key is to have CWM Recovery installed, which I already had per the instructions used in the ICS documentation. Having CWM Recovery already installed meant that I just had to get the CyanogenMod10 ROM download and copied to the Galaxy Tab along with Google Apps.

CyanogenMod10 Samsung Galaxy Tab: cm-10-20120826-UNOFFICAL-p1-erezak.zip http://forum.xda-developers.com/showthread.php?t=1848555

Google App: http://goo.im/gapps/gapps-jb-20120726-signed.zip

Modem.bin downloads: http://devphone.org/files/gtab7/modems/

There any number ways to get the file to your device. I used my USB cable connected to my computer to mount the Tab as USB storage on my computer. I copied the files (cm-10-20120826-UNOFFICAL-p1-erezak.zip and gapps-jb-20120726-signed.zip) to the root directory of my Galaxy Tab.

Once copied, you need to boot in CWM Recovery.

Power off the device by holding the Power button and selecting the Power off option.

Once powered off, hold the Volume Up button and the Power button. This is a timing thing. I found if I hold the Voume Up and Power until I see the cyanogen(mod) screen, and then release them and push them again for a moment. However, I don’t think that is the key. I think it is just timing that I have not quite figured out yet. Nonetheless, you will know you are in when you get to the CWM Recovery menu.

First, choose wipe data/factory reset. (Hope you backed if you wanted to keep anything.)

Then, choose “install zip from sdcard.” Then, select “choose zip from sdcard” and browse to the cm-10-20120826-UNOFFICAL-p1-erezak.zip and install it.

Once that is complete, browse to the gapps-jb-20120726-signed.zip and install the Google Apps.

Select the “reboot the system now” from the menu to boot Jelly Bean.

So far, I have to say it isn’t bad. I hope to see more nightly builds with significant improvements. I have had a number of locks up and crashes. It seems a little slower than ICS, but I am looking forward to more improvements.

Update 1: The best place to find these UNOFFICIAL nightly builds is http://romsbuild.appspot.com/

Update 2: Now it is in the official p1 downloads: http://get.cm/?device=p1. This is experimental stuff right now, and it has been behaving as such. It seems that I usually have lock up when I am using GPS and downloading at the same time. Had a heck of time when I first tried using the Navigation this weekend.

Update 3: The first official build I used in Update 2 was marked experimental. The very next day I noticed that the ROM for the Galaxy Tab was now officially in the nightly builds. So, I gave it another try. I have been running 10-20120907-NIGHTLY-p1 for five days now. I cannot say how impressed I am with the stability of the build. I have not have to reboot once, or had one lock up. It has been great. The only thing I have noticed is that the Amazon AppStore is slow, but everything else has been decent.

Adding a new disk, volume group and volume in CentOS6 from the command line.

I needed to add more storage to my CentOS6 machine for my remote system backups. I decided to allocate a completely new volume group and volume to facilitate this need. Here are the steps I used to create the volume:

The new disk was added via vSphere, since this a VM. I determined the correct device file by looking to the dmesg output.

Initialize the whole disk using pvcreate.
# pvcreate /dev/sde

For partitions, use pvcreate /dev/sde[x].

Create a volume group
# vgcreate vg_vmlinux01_backup /dev/sde

To add multiple disks or partions, use vgcreate volume_group_name /dev/sdx /dev/sdy …

Activate the volume group:
# vgchange -a y vg_vmlinux01_backup

Create logical volume
This will allocate all remaining available space to the volume. You can use -L to specify a particular size. Not needed in my case.
# lvcreate -l 100%FREE -n lv_rmbackup vg_vmlinux01_backup

Write the filesystem with the desired label.
# mkfs -t ext4 -j -L /rmbackup /dev/vg_vmlinux01_backup/lv_rmbackup

If you need to create the filesystem with more than the default number of inodes:
# mkfs -t ext4 -j -N 20000000 -L /rmbackup /dev/vg_vmlinux01_backup/lv_rmbackup

Modify the /etc/fstab:
# vi /etc/fstab

LABEL=/rmbackup /rmbackup ext4 defaults 1 0

Mount it:
# mount /rmbackup

Change a MacOS icon.

Annoyed by a link to an application that has the wrong icon? This is one of those things that seems so obvious once you do it, but you just don’t think to try it. Note: when I say “select”, I mean just click on it once. Also, when I say “menu”, I mean the one at the very top of your screen (Apple menu?). Get Info is usually under the File option.

Find something with the icon you want and select it.

From the menu, click on Get Info.

Select the icon in the top left corner, and hit Command+C.

Select the link you want to change.

From the menu, click on Get Info.

Select the icon in the top left corner, and hit Command+V.

Remove dead Favorites in Finder (MacOS)

Picked up a nefty little trick to remove those pesky Favorites in Finder that are dead. The ones you click on and nothing happens. Well, to get them back, you need to restablish the connection to the share/folder and drag them to your Favorites. However, sometimes this does not fix the dead ones. To remove those, hold down option+command and drag the dead Favorite to the Trash.

Disabling Gatekeeper in MacOS Mountain Lion

Well, it didn’t take long. I needed to install opensource software that is not in App Store. Goodbye Gatekeeper. I definitely don’t this direction Apple is taking with MacOS.

Go to System Preferences and select Security & Privacy.

If locked, unlock to make changes and enter your password.

Under “Allow applications downloaded from:”, select Anywhere.

Click “Allow From Anywhere” to acknowledge that you could be making your computer less secure.

Lock Security & Privacy.

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

Return top

INFORMATION