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#?
--
Don Jones
Windows PowerShell MVP
Founder:
www.ScriptingAnswers.com
Co-Author: "Windows PowerShell: TFM"
"Mycroft" <Mycroft.2r2jhb@no-mx.forums.net> wrote in message
news:Mycroft.2r2jhb@no-mx.forums.net...
>
> 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
>
>
> Code:
> --------------------
> 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)
> {
> Debug.WriteLine(t.Name);
> t.Delete();
> count++;
> }
> numTracks--;
> }
> Debug.WriteLine(count);
> }
> }
> }
> --------------------
> 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?
>
>
> --
> Mycroft