Add a favourite to Internet Explorer

Way back in this post

I mentioned about adding a new favourite. 

Favourites are special folders and one way to work with them is through the old COM objects

function add-favourite{             
$so = New-Object -ComObject Shell.Application            
$ff = $so.Namespace(0x6)            
$path = Join-Path -Path $($ff.Self.Path) -ChildPath "$name.url"             
$shell = New-Object -ComObject WScript.Shell            
$sc = $shell.CreateShortCut($path)            
$sc.TargetPath = $url            
Add a new favourite

Add a new favourite

add-favourite -name mytest -url ""


The name for the favourite and the URL are parameters. Create a object for the Favourites folder and then a path for the favourite. Use CreateShorcut on the WScript.Shell object add the URL and save

This entry was posted in Powershell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s