Script to remove invalid shortcuts from start menu


Last week I was asked to write a script that could be executed on desktops in the user context as part of a pre-migration script.
The goal of the script was to check for, and remove, invalid shortcuts from the Start Menu / Start Screen.
Luckily I did this once or twice before, so I dove in my repository and shared it.
So, here is the script… Hope you find it useful :-)

Function Remove-InvalidStartMenuItem {
    $WshShell = New-Object -comObject WScript.Shell
    $Files = Get-ChildItem -Path "C:Users$env:USERNAMEAppDataRoamingMicrosoftWindowsStart MenuPrograms" -Filter *.lnk
    foreach ($File in $Files) {
        $FilePath = $File.FullName
        $Shortcut = $WshShell.CreateShortcut($FilePath)
        $Target = $Shortcut.TargetPath
        if (Test-Path -Path $Target) {
            Write-Output "Valid: $($File.BaseName)"
        } else {
            Write-Output "Invalid: $($File.BaseName) removed."
            try {
              Remove-Item -Path $LnkFilePath
              Write-Output "Removed: $($File.BaseName) removed."
            } catch {
              Write-Output "ERROR: $($File.BaseName) not removed."

Sixth DuPSUG meeting, an overview


Today I attended the Dutch PowerShell User Group meeting, colloquially known as DuPSUG. It was the first meeting of 2015 and it was a day filled with exciting sessions focusing on Desired State Configuration, OMI, AST and Azure Pack. Inovativ was kind enough to host the day at their headquarters in Amstelveen.

Blog of the Presenters
Jeffrey Snover
Bartek Bielawski
Ben Gelens
Jeff Wouters
Stefan Stranger
Interesting Links
Dutch PowerShell User Group Site
Monad Manifesto

TwitterLinkedInFacebookGoogle+RedditWordPressEmailTumblrPinterestHacker NewsShare

6th DuPSUG meeting sold out… it is!

It only took 7 days for 70 tickets to be sold.
To all that didn’t get a ticket: Sorry, better luck next time!
I remember when we had our first meeting, with Ed Wilson (MSFT Scripting Guys) as our ‘main attraction’ and it took almost 3 months to sell 35 tickets.

Only 3 years later, the PowerShell community has grown considerably in The Netherlands.
We even have a ticket registered to an American (Texas) lady that lives in Germany.
We have some Belgians coming over…
Not even to mention all the expats that live in The Netherlands that have registered.

To see this adoption and of PowerShell and the community around is makes me happy.
This is what I started the user group for!
So I want to thank all past, current and future attendees / speakers / sponsors for making all of this possible… Thank you!

See you at the meeting! :-)

On behalf of DuPSUG,

Jeff Wouters.

  • ISESteroids

  • Pluralsight

  • Sapien

Go to Top