Add a favourite to Internet Explorer
Way back in this post
http://msmvps.com/blogs/richardsiddaway/archive/2011/06/27/modifying-favourites.aspx
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{
[CmdletBinding()]
param(
[parameter(Mandatory=$true)]
[string]$name,
[ValidateNotNullOrEmpty()]
[string]$url
)
BEGIN{}#begin
PROCESS{
$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
$sc.Save()
}#process
END{}#end
<#
.SYNOPSIS
Add a new favourite
.DESCRIPTION
Add a new favourite
.EXAMPLE
add-favourite -name mytest -url "http://www.bing.com"
#>
}
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