Posts

Showing posts from 2011

Mercurial Support for Visual Studio

I just created an account at bitbucket.org because they provide unlimited repositories and 300MB of disk space but I had to use Mercurial. After a Google search I found two plugins,
HgSccPackage which uses mercurial command line client as backend, andVisualHG which uses TortoiseHg as backend.I had no Mercurial clients install so I randomly chose HgSccPackage. I installed the mercurial command line client for windows from http://mercurial.selenic.com/wiki/Download and then the plugin.

I have to admit that I didn't want to switch to Mercurial, even though bitbucket supports SVN ( but still in beta ), but it seems to be very nice.

Poweshell File and Folder Size Function

Have you ever wanted to know the size of a folder using Powershell? Of course! Sure, you can get the size of a file using the length property but what about folders?

This is a function that uses .NET objects to calculate the size of a folder. You can use it for files too.


function Get-Size{
param( $path )
if( test-path $path -pathtype container )
{
$size = _get-dirsize $path
}
else
{
$size = get-item $path
$size = $size.length
}

get-item $path | select-object Name, @{name="Size (MB)";expression={[Math]::Round( ($size / 1MB), 2 )}}, fullname, @{name="Size";expression={$size}} | format-table

}

function _Get-DirSize{
param( $folder )
$folder = resolve-path $folder
$d = New-Object system.IO.DirectoryInfo $folder
[long] $Size = 0;

# Add file sizes.
$fis = $d.GetFiles();
foreach ($fi in $fis){
$size += $fi.Length;
}

# Add subdirectory sizes recursively.
$dis = $d.GetDirec…

WSUS 3 Update Removal

In case your update server takes too much space on your hard disk, you can follow these steps to remove "old" updates.

You might also like to try "Server CleanUp" first...

So,
Unapprove all updates from the Update Console.Stop "World Wide Web Publishing Service" service and all of it's dependentsStop "Update Service" and "Windows Update" servicesDelete all contents from the "WSUS Content" folderStart the above servicesStart a command line window and change to "c:\program files\update services\tools"Run wsusutil.exe reset The 'reset' command tells wsus to check all of it downloads and redownload any missing or corrupt files. Since you deleted them all it will download only the updates that have been approved.

Call a function from file in Windows Powershell

In order to call a function from a powershell file we have to use a method called dot-sourcing.

Let's say we have file called a.ps1 and it's contents are:

function f
{
    echo "Hi!!!"
}
And now we want to call that function from powershell. We have to load that file (think of a library):
. .\a.ps1 (that's dot, space, path-to-file) and then we can call the function itself.

This can be very usefull if you have many functions in your profile file and you don't want it to get very big.

Previewing ‘Windows 8’

The first preview of Microsoft's new Operating System, internaly codenamed "Windows 8" by Julie Larson-Green, Corporate Vice President, Windows Experience.