≡ Menu

Use powershell to find zero size/byte files

Below scripts helps you to find files with zero file size. Run this piece of code from root of your system from powershell window.

Get-Childitem -Recurse | foreach-object {
    if(!$_.PSIsContainer -and $_.length -eq 0) {
        write-host (“{0} -> {1}” -f $_.FullName, $_.Length)
        }
}

You can also refer to below article on how to find files older than certain size.

https://techibee.com/powershell/list-the-files-greater-than-given-size-using-powershell/163

{ 0 comments }

OS keyboard in Windows 7

OS keyboard(On Screen Keyboard) helps you to type in letters when your physical keyboard is not functioning. This is not a new feature in windows 7, XP also has it but in Windows 7 it enhanced a bit.

To launch OS keyboard in windows 7 just type “osk.exe” in Start->Run. You should see keyboard like below.

 

{ 0 comments }

How to disable Aero Snap in Windows 7

The Aero Snap feature allows you to arrange open windows, including maximizing and resizing, just by dragging and dropping a window to different edges of the screen. When a window is dragged to the correct position, a ripple effect will emanate from the cursor and you’ll see an animated outline of the window instantly appear in its new position. As soon as you release the mouse button, the window will snap to that position. You can read more about this Aero Snap feature at http://www.microsoft.com/windows/windows-7/features/snap.aspx

Though this feature provides lot of flexibility, some people are not liking for various reasons. And they are feeling in convenience. To help such people I came with steps to disable Aero Snap Feature alone in Windows 7 desktops. After this, other Aero features(peak, shake) will continue to work normally like before.

Procedure

  1. Go to Start -> in search box type “snap”
  2. Click on “Turn off automation windows arrangement” option. When you select that result, you’ll see the Make the Mouse Easier to Use panel in the Ease of Access tool .
  3. Select the “Prevent Windows from Being Automatically Arranged when Moved to the Edge of the Screen” check box
  4. Click on OK. This will disable Aero snap.
{ 0 comments }

Remoting is one of the wonderful features offered by powershell V2.This article will explain how to setup remoting and run commands on remote system using remoting feature.

Introduction:

First of all, what is remoting? Executing a command against a remote system is what called remoting? No, this is not a full fledged remoting. PowerShell remoting enables you to run a command *in* remote computer and bring the output to your console. For example, if you type some command like “hostname” or “ipconfig” in remoting, it will get executed in target computer and brings the output to your computer console. You might want to ask, why this remoting is needed when cmdlets offering -computername parameter(for example Get-WMIObject). The answer is simple, not every cmdlet support remoting and authentication happens per cmdlet basis. To overcome these limitations powershell remoting was introduced where you will get authenticated with target computer once and from there on you can execute the command/script/powershell cmdlet/batch file locally to the remote computer.

Configuration:

You need at least Windows powershell V2 to make remoting work. Use Get-Host cmdlet to know your current powershell version.

Enable remoting:

Remoting feature is not enabled by default. But it’s not that difficult to enable it. Launch a powershell window with elevated rights and run below command.

[PS]C:>Enable-Remoting

This enabling has to be done on all computers in your domain to trigger commands/script executing remotely. If you see any errors while enabling remoting use -force option.
This completes the configuration of remoting in computers.

Now it’s time to perform actions in target system by sitting at your desktop. First let’s go through the list of cmdlets available as part of remoting.

Above cmdlets are self explanatory. Executing a command against a target computer is a 3 step process.

  1. Establish a session
  2. Execute any command/script/cmdlet using the session
  3. Delete the session

1. Establishing a session:

A new session needs to be established with target computer to execute commands against it. The below examples helps you in creating a session with computer name called myremotepc.

[PS]C:>New-PsSession -ComputerName  myremotepc

This command will succeed if your current login has administrator rights on target computer. If not, then you have an option to provide credentials at the time of establishing new connection like shown below

[PS]C:>New-PsSession -ComputerName myremotepc -credential $prompt

This completes the session establishment:

2. Executing commands:

Now it’s the time for us to execute some commands. Let’s start with a simple example. Have you ever used Get-Date cmdlet to get the time of remote computer? I bet you never. This cmdlet don’t have option to do this. But with remoting we can make it possible.

[PS]C:>$mysession = New-PSSession -ComputerName myremotepc
[PS]C:>Invoke-Command { Get-Date } -Session $mysession

In the above example, first we established a new session with remote computer and saved the session details to a new variable called $mysession. Using invoke-Command cmdlet we executed Get-Date cmdlet against remote computer using the session that we created before. This way you can execute any command/script/cmdlet using Invoke-command cmdlet by passing the command inside the curly brackets.

3. Deleting the session:

It is always recommended to delete the session once you are done with using it. This is a good security practice. This way we can ensure that no other who uses your computer later can execute commands on your name. Remove-PsSession is the cmdlet which helps us here.

[PS]C:>Remove-PsSession -session $mysession

An alternate method for executing commands is directly entering the remote computer powershell window. Enter-Pssession cmdlet does it for you.

Conclusion:

Windows PowerShell remoting really make the life of system administrators so easy in Windows 7/windows 2008 environment. The level of automations that sysadmins can do will be increased to greater extents with powershell.

{ 6 comments }

Apple MAC OS X keyboard shortcuts

Visit below link for complete list of MAC OS X shortcuts.

Click Here

Hope this helps.

{ 0 comments }

Sometimes while writing powershell scripts, you might get a need to verify if the given path is absolute(c:tempmyfolders) or relative(..myfolders). You can easily run this test by using one of the dotnet provided method, IsPathRooted(). This method returns TRUE if the given path is absolute and will return FALSE if the given path is relative.

 Below is one classic example…

c:>[System.IO.Path]::IsPathRooted("c:tempmyfolders")
True

c:>[System.IO.Path]::IsPathRooted("..myfolders")
False

 Note that this won’t check whether the path you provided exists or not. You can read more about this method at 

http://msdn.microsoft.com/en-us/library/system.io.path.ispathrooted.aspx

{ 0 comments }

Today I came across a requirement to gather information about the process running in remote computer. Basically I want to know when the process is started. In this case you can’t use process explorer as it doesn’t have option to connect to remote computer. So, I quickly wrote a small script to get this information.

$myproc = gwmi -Class Win32_Process -ComputerName moose -Filter "caption = 'outlook.exe'"

([wmi]'').ConvertToDatetime($myproc.creationdate)
{ 0 comments }

count files by extension using powershell

Just a tip. This will help you to list files count by extension.

Get-Childitem c:\local -Recurse | where { -not $_.PSIsContainer } | group Extension -NoElement | sort count -desc
{ 17 comments }

Windows 2008 R2 supports Exchange 2007 now

With recent service pack(SP3), exchange started supporting installation on Windows 2008 R2. More details at http://msexchangeteam.com/archive/2010/06/21/455145.aspx

{ 0 comments }

Most often, users of windows XP will get below signing prompt while installing some devices in their computers. Basically XP computer is looking for drivers which are signed by Microsoft for the device you are installing. But not all the drivers are signed by Microsoft and that doesn’t mean that you can not install them in XP. This is a kind of security measure from Microsoft to help XP users. If you are confidant that this drive won’t cause any problems, then you can go ahead and install.

Follow the below steps to disable the Device Driver Signing Check in XP:

  1.  Logon to XP computer with Administrator rights
  2. Go to “My Computer” properties, “Hardware” tab, and select “Driver Signing” button
  3. In Drive signing options window, select block option and click on OK.
  4. This disables the driver signing and it won’t prompt you again.

Hope this information helps you.

{ 2 comments }