PowerShell's not always able to "hook" into every COM object... between its
adaptation layer and .NET's interop, some COM objects just don't work the
right way all the time.
Is there a strong reason to port this into PowerShell if it's working in C#?
Windows PowerShell MVP
Co-Author: "Windows PowerShell: TFM"
"Mycroft" <Mycroft.firstname.lastname@example.org> wrote in message
> First of all I know next to nothing about COM, fiddling in Powershell is
> my first experience with it. Apologies if this is obvious but I can't
> for the life of me find the answers. I've created the following C#
> program based on the iTunes SDK examples, which works fine
> using System;
> using System.Collections.Generic;
> using System.Text;
> using iTunesLib;
> using System.Diagnostics;
> namespace ConsoleApplication1
> class Program
> static void Main(string args)
> iTunesApp app = new iTunesAppClass();
> IITTrackCollection tracks = app.LibraryPlaylist.Tracks;
> int numTracks = tracks.Count;
> int count = 0;
> while (numTracks != 0)
> IITTrack track = tracks[numTracks];
> IITFileOrCDTrack t = (IITFileOrCDTrack) track;
> if (t.Location == null)
> It simply finds all the dead links within iTunes and deletes them. How
> would I go about porting this to Powershell? It's creating new COM
> objects and casting that I'm stuck with. $track = $tracks[numTracks]
> won't work, "Unable to index into an object..." How do I make Powershell
> aware of the types such as IITTrackCollection?