Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista Tutorial - deleting files that meet specific criteria

Reply
 
Old 02-25-2008   #1 (permalink)
Boomer
Guest


 
 

deleting files that meet specific criteria

Hi all,

My intent is use PS to search through my digital music library and remove
all DRM files for which I no longer have rights.

I used to subscribe to the URGE music store, and have a bunch of files
tagged with "protected content" under the License Property Set. This
"license" tab can be viewed as a tab along side the general, the security,
and the summary tabs, if one clicks on the file's property.

For the life of me, I cannot find anything that describes how to show/list
the presence of the "license" tab. TypeName: System.IO.FileInfo ... I can
retreive info about the file with the memberType Property ... Nothing out of
the ordinary is listed for memberType when I enter the following command on a
file in question:
Quote:

> gci | gm

I figured it would the easiest to do it in PS, but it didn't turn out to be
such a good assumption.

Your assistance is greatly appreciated.


My System SpecsSystem Spec
Old 02-25-2008   #2 (permalink)
Jeff
Guest


 
 

Re: deleting files that meet specific criteria

On Feb 25, 1:00 pm, Boomer <Boo...@xxxxxx> wrote:
Quote:

> Hi all,
>
> My intent is use PS to search through my digital music library and remove
> all DRM files for which I no longer have rights.
>
> I used to subscribe to the URGE music store, and have a bunch of files
> tagged with "protected content" under the License Property Set. This
> "license" tab can be viewed as a tab along side the general, the security,
> and the summary tabs, if one clicks on the file's property.
>
> For the life of me, I cannot find anything that describes how to show/list
> the presence of the "license" tab. TypeName: System.IO.FileInfo ... I can
> retreive info about the file with the memberType Property ... Nothing out of
> the ordinary is listed for memberType when I enter the following command on a
> file in question:
>
Quote:

> > gci | gm
>
> I figured it would the easiest to do it in PS, but it didn't turn out to be
> such a good assumption.
>
> Your assistance is greatly appreciated.
Boomer,

I looked around at what was available through Windows Media player,
and the best I could come up with is this little script that tells you
if a file has DRM protection or not:

# Get-Protected.ps1
param( [string] $wmaFile )

if ( Test-Path $wmaFile )
{
$wmplayer = New-Object -ComObject "WMPlayer.OCX"

$media = $wmplayer.newMedia( $wmaFile )

[bool]::Parse( $media.getItemInfo( "Is_Protected" ) )
}
# Get-Protected.ps1

If you want much more information that that, it looks like you might
need to get a license from Microsoft for a DRM SDK of some kind:
http://msdn2.microsoft.com/en-us/win.../bb190309.aspx

These licenses are necessary if you are creating an application to
manage licenses or something like that, so it seems like they
shouldn't be necessary if all you want to do is query the
information. If you do find anything, please post back here; I would
certainly be interested.

Jeff

My System SpecsSystem Spec
Old 02-25-2008   #3 (permalink)
Jeff
Guest


 
 

Re: deleting files that meet specific criteria

Boomer,

I found an SDK that might help you with what you want to do:

Windows Media Format 11 SDK
http://msdn2.microsoft.com/en-us/lib...10(VS.85).aspx

This SDK lets you query all kinds of DRM information for a file, and
the SDK comes with a whole bunch of useful sample code. It doesn't
look like any of it is easily accessible from .NET (no TLBs or COM
servers), so you may have to write a small Win32 console application
to query what you want, and then call it from your PowerShell script.

I hope this helps.

Jeff

Jeff wrote:
Quote:

> On Feb 25, 1:00 pm, Boomer <Boo...@xxxxxx> wrote:
Quote:

> > Hi all,
> >
> > My intent is use PS to search through my digital music library and remove
> > all DRM files for which I no longer have rights.
> >
> > I used to subscribe to the URGE music store, and have a bunch of files
> > tagged with "protected content" under the License Property Set. This
> > "license" tab can be viewed as a tab along side the general, the security,
> > and the summary tabs, if one clicks on the file's property.
> >
> > For the life of me, I cannot find anything that describes how to show/list
> > the presence of the "license" tab. TypeName: System.IO.FileInfo ... I can
> > retreive info about the file with the memberType Property ... Nothing out of
> > the ordinary is listed for memberType when I enter the following command on a
> > file in question:
> >
Quote:

> > > gci | gm
> >
> > I figured it would the easiest to do it in PS, but it didn't turn out to be
> > such a good assumption.
> >
> > Your assistance is greatly appreciated.
>
> Boomer,
>
> I looked around at what was available through Windows Media player,
> and the best I could come up with is this little script that tells you
> if a file has DRM protection or not:
>
> # Get-Protected.ps1
> param( [string] $wmaFile )
>
> if ( Test-Path $wmaFile )
> {
> $wmplayer = New-Object -ComObject "WMPlayer.OCX"
>
> $media = $wmplayer.newMedia( $wmaFile )
>
> [bool]::Parse( $media.getItemInfo( "Is_Protected" ) )
> }
> # Get-Protected.ps1
>
> If you want much more information that that, it looks like you might
> need to get a license from Microsoft for a DRM SDK of some kind:
> http://msdn2.microsoft.com/en-us/win.../bb190309.aspx
>
> These licenses are necessary if you are creating an application to
> manage licenses or something like that, so it seems like they
> shouldn't be necessary if all you want to do is query the
> information. If you do find anything, please post back here; I would
> certainly be interested.
>
> Jeff
My System SpecsSystem Spec
Old 02-25-2008   #4 (permalink)
Keith Hill [MVP]
Guest


 
 

Re: deleting files that meet specific criteria

"Boomer" <Boomer@xxxxxx> wrote in message
news:A254A497-F985-417D-954D-856E5B918048@xxxxxx
Quote:

> Hi all,
>
> My intent is use PS to search through my digital music library and remove
> all DRM files for which I no longer have rights.
>
> I used to subscribe to the URGE music store, and have a bunch of files
> tagged with "protected content" under the License Property Set. This
> "license" tab can be viewed as a tab along side the general, the security,
> and the summary tabs, if one clicks on the file's property.
>
> For the life of me, I cannot find anything that describes how to show/list
> the presence of the "license" tab. TypeName: System.IO.FileInfo ... I can
> retreive info about the file with the memberType Property ... Nothing out
> of
> the ordinary is listed for memberType when I enter the following command
> on a
> file in question:
>
Quote:

>> gci | gm
>
>
> I figured it would the easiest to do it in PS, but it didn't turn out to
> be
> such a good assumption.
>
> Your assistance is greatly appreciated.
If you look at the details on these DRM protected files in Windows Explorer
do you see any metatags that identify the file as DRM protected? If so you
can use the presence and/or value of those flags to conditionally delete
those files.

--
Keith

My System SpecsSystem Spec
Old 02-25-2008   #5 (permalink)
Jeff
Guest


 
 

Re: deleting files that meet specific criteria

On Feb 25, 5:46 pm, Jeff <jeff.hill...@xxxxxx> wrote:
Quote:

> Boomer,
>
> I found an SDK that might help you with what you want to do:
>
> Windows Media Format 11 SDKhttp://msdn2.microsoft.com/en-us/library/aa387410(VS.85).aspx
>
> This SDK lets you query all kinds of DRM information for a file, and
> the SDK comes with a whole bunch of useful sample code. It doesn't
> look like any of it is easily accessible from .NET (no TLBs or COM
> servers), so you may have to write a small Win32 console application
> to query what you want, and then call it from your PowerShell script.
>
> I hope this helps.
>
> Jeff
>
> Jeff wrote:
Quote:

> > On Feb 25, 1:00 pm, Boomer <Boo...@xxxxxx> wrote:
Quote:

> > > Hi all,
>
Quote:
Quote:

> > > My intent is use PS to search through my digital music library and remove
> > > all DRM files for which I no longer have rights.
>
Quote:
Quote:

> > > I used to subscribe to the URGE music store, and have a bunch of files
> > > tagged with "protected content" under the License Property Set. This
> > > "license" tab can be viewed as a tab along side the general, the security,
> > > and the summary tabs, if one clicks on the file's property.
>
Quote:
Quote:

> > > For the life of me, I cannot find anything that describes how to show/list
> > > the presence of the "license" tab. TypeName: System.IO.FileInfo ... I can
> > > retreive info about the file with the memberType Property ... Nothing out of
> > > the ordinary is listed for memberType when I enter the following command on a
> > > file in question:
>
Quote:
Quote:

> > > > gci | gm
>
Quote:
Quote:

> > > I figured it would the easiest to do it in PS, but it didn't turn out to be
> > > such a good assumption.
>
Quote:
Quote:

> > > Your assistance is greatly appreciated.
>
Quote:

> > Boomer,
>
Quote:

> > I looked around at what was available through Windows Media player,
> > and the best I could come up with is this little script that tells you
> > if a file has DRM protection or not:
>
Quote:

> > # Get-Protected.ps1
> > param( [string] $wmaFile )
>
Quote:

> > if ( Test-Path $wmaFile )
> > {
> > $wmplayer = New-Object -ComObject "WMPlayer.OCX"
>
Quote:

> > $media = $wmplayer.newMedia( $wmaFile )
>
Quote:

> > [bool]::Parse( $media.getItemInfo( "Is_Protected" ) )
> > }
> > # Get-Protected.ps1
>
Quote:

> > If you want much more information that that, it looks like you might
> > need to get a license from Microsoft for a DRM SDK of some kind:
> >http://msdn2.microsoft.com/en-us/win.../bb190309.aspx
>
Quote:

> > These licenses are necessary if you are creating an application to
> > manage licenses or something like that, so it seems like they
> > shouldn't be necessary if all you want to do is query the
> > information. If you do find anything, please post back here; I would
> > certainly be interested.
>
Quote:

> > Jeff
Boomer,

In case this is the route you decide to go, here is a little console
application that checks the "Playback Allowed" property on a DRM
protected file:

#include <atlbase.h>
#include <TCHAR.H>
#include "wmsdk.h"

int _tmain( int argc, wchar_t *argv[] )
{
if ( SUCCEEDED( CoInitialize( NULL ) ) )
{
int nCount = MultiByteToWideChar(
CP_ACP, 0, (LPCSTR)argv[ 1 ], -1, NULL, 0 );

wchar_t *pwszFileName = new wchar_t[ nCount ];

MultiByteToWideChar(
CP_ACP, 0, (LPCSTR)argv[ 1 ], -1, pwszFileName, nCount );

// check to see if the file is protected with DRM
BOOL bProtected;

HRESULT hr = WMIsContentProtected( pwszFileName,
&bProtected );

if ( SUCCEEDED( hr ) )
{
// if the file isn't protected with DRM, we don't need to
continue
if ( !bProtected )
{
wprintf( L"Playback Allowed: True\n" );
}
else
{
// create a meta data editor
CComPtr<IWMMetadataEditor> spEditor;
hr = WMCreateEditor( &spEditor );

// open the media file
if ( SUCCEEDED( hr ) )
{
hr = spEditor->Open( pwszFileName );
}

// QI for the DRM editor
CComQIPtr<IWMDRMEditor> spDRMEditor( spEditor );
WMT_ATTR_DATATYPE wmtAttribute;
BYTE playbackAllowed[ 4 ];
WORD wLength;

if ( SUCCEEDED( hr ) && spDRMEditor )
{
// get the 'playback allowed' property value
hr = spDRMEditor->GetDRMProperty(
g_wszWMDRM_ActionAllowed_Playback,
&wmtAttribute, playbackAllowed,
&wLength );

if ( SUCCEEDED( hr ) )
{
wprintf( L"Playback Allowed: %s\n",
( (BOOL)*playbackAllowed ? L"True" :
L"False" ) );
}
}
}
}

CoUninitialize();
}

return 0;
}

This should be enough to determine if you want to keep a file or not.

Good luck.

Jeff
My System SpecsSystem Spec
Old 02-25-2008   #6 (permalink)
Jeff
Guest


 
 

Re: deleting files that meet specific criteria

On Feb 25, 5:46 pm, Jeff <jeff.hill...@xxxxxx> wrote:
Quote:

> Boomer,
>
> I found an SDK that might help you with what you want to do:
>
> Windows Media Format 11 SDKhttp://msdn2.microsoft.com/en-us/library/aa387410(VS.85).aspx
>
> This SDK lets you query all kinds of DRM information for a file, and
> the SDK comes with a whole bunch of useful sample code. It doesn't
> look like any of it is easily accessible from .NET (no TLBs or COM
> servers), so you may have to write a small Win32 console application
> to query what you want, and then call it from your PowerShell script.
>
> I hope this helps.
>
> Jeff
>
> Jeff wrote:
Quote:

> > On Feb 25, 1:00 pm, Boomer <Boo...@xxxxxx> wrote:
Quote:

> > > Hi all,
>
Quote:
Quote:

> > > My intent is use PS to search through my digital music library and remove
> > > all DRM files for which I no longer have rights.
>
Quote:
Quote:

> > > I used to subscribe to the URGE music store, and have a bunch of files
> > > tagged with "protected content" under the License Property Set. This
> > > "license" tab can be viewed as a tab along side the general, the security,
> > > and the summary tabs, if one clicks on the file's property.
>
Quote:
Quote:

> > > For the life of me, I cannot find anything that describes how to show/list
> > > the presence of the "license" tab. TypeName: System.IO.FileInfo ... I can
> > > retreive info about the file with the memberType Property ... Nothing out of
> > > the ordinary is listed for memberType when I enter the following command on a
> > > file in question:
>
Quote:
Quote:

> > > > gci | gm
>
Quote:
Quote:

> > > I figured it would the easiest to do it in PS, but it didn't turn out to be
> > > such a good assumption.
>
Quote:
Quote:

> > > Your assistance is greatly appreciated.
>
Quote:

> > Boomer,
>
Quote:

> > I looked around at what was available through Windows Media player,
> > and the best I could come up with is this little script that tells you
> > if a file has DRM protection or not:
>
Quote:

> > # Get-Protected.ps1
> > param( [string] $wmaFile )
>
Quote:

> > if ( Test-Path $wmaFile )
> > {
> > $wmplayer = New-Object -ComObject "WMPlayer.OCX"
>
Quote:

> > $media = $wmplayer.newMedia( $wmaFile )
>
Quote:

> > [bool]::Parse( $media.getItemInfo( "Is_Protected" ) )
> > }
> > # Get-Protected.ps1
>
Quote:

> > If you want much more information that that, it looks like you might
> > need to get a license from Microsoft for a DRM SDK of some kind:
> >http://msdn2.microsoft.com/en-us/win.../bb190309.aspx
>
Quote:

> > These licenses are necessary if you are creating an application to
> > manage licenses or something like that, so it seems like they
> > shouldn't be necessary if all you want to do is query the
> > information. If you do find anything, please post back here; I would
> > certainly be interested.
>
Quote:

> > Jeff
Boomer,

In case this is the route you decide to take, here is a small console
application that determines if playback is allowed for a DRM-protected
file:

#include <atlbase.h>
#include <TCHAR.H>
#include "wmsdk.h"

int _tmain( int argc, wchar_t *argv[] )
{
if ( SUCCEEDED( CoInitialize( NULL ) ) )
{
int nCount = MultiByteToWideChar(
CP_ACP, 0, (LPCSTR)argv[ 1 ], -1, NULL, 0 );

wchar_t *pwszFileName = new wchar_t[ nCount ];

MultiByteToWideChar(
CP_ACP, 0, (LPCSTR)argv[ 1 ], -1, pwszFileName, nCount );

// check to see if the file is protected with DRM
BOOL bProtected;

HRESULT hr = WMIsContentProtected(
pwszFileName, &bProtected );

if ( SUCCEEDED( hr ) )
{
// if the file isn't protected with DRM,
// we don't need to continue
if ( !bProtected )
{
wprintf( L"Playback Allowed: True\n" );
}
else
{
// create a meta data editor
CComPtr<IWMMetadataEditor> spEditor;
hr = WMCreateEditor( &spEditor );

// open the media file
if ( SUCCEEDED( hr ) )
{
hr = spEditor->Open( pwszFileName );
}

// QI for the DRM editor
CComQIPtr<IWMDRMEditor> spDRMEditor( spEditor );
WMT_ATTR_DATATYPE wmtAttribute;
BYTE playbackAllowed[ 4 ];
WORD wLength;

if ( SUCCEEDED( hr ) && spDRMEditor )
{
// get the 'playback allowed' property value
hr = spDRMEditor->GetDRMProperty(
g_wszWMDRM_ActionAllowed_Playback,
&wmtAttribute, playbackAllowed,
&wLength );

if ( SUCCEEDED( hr ) )
{
wprintf( L"Playback Allowed: %s\n",
( (BOOL)*playbackAllowed ? L"True"
: L"False" ) );
}
}
}
}

CoUninitialize();
}

return 0;
}

This should be enough to determine if you want to keep a file or not.

Good luck.

Jeff
My System SpecsSystem Spec
Old 02-29-2008   #7 (permalink)
Boomer
Guest


 
 

Re: deleting files that meet specific criteria

On Feb 25, 9:21*pm, Jeff <jeff.hill...@xxxxxx> wrote:
Quote:

> On Feb 25, 5:46 pm, Jeff <jeff.hill...@xxxxxx> wrote:
>
>
>
>
>
Quote:

> >Boomer,
>
Quote:

> > I found an SDK that might help you with what you want to do:
>
Quote:

> > Windows Media Format 11 SDKhttp://msdn2.microsoft.com/en-us/library/aa387410(VS.85).aspx
>
Quote:

> > This SDK lets you query all kinds of DRM information for a file, and
> > the SDK comes with a whole bunch of useful sample code. *It doesn't
> > look like any of it is easily accessible from .NET (no TLBs or COM
> > servers), so you may have to write a small Win32 console application
> > to query what you want, and then call it from your PowerShell script.
>
Quote:

> > I hope this helps.
>
Quote:

> > Jeff
>
Quote:

> > Jeff wrote:
Quote:

> > > On Feb 25, 1:00 pm,Boomer<Boo...@xxxxxx> wrote:
> > > > Hi all,
>
Quote:
Quote:

> > > > My intent is use PS to search through my digital music library and remove
> > > > all DRM files for which I no longer have rights.
>
Quote:
Quote:

> > > > I used to subscribe to the URGE music store, and have a bunch of files
> > > > tagged with "protected content" under the License Property Set. *This
> > > > "license" tab can be viewed as a tab along side the general, the security,
> > > > and the summary tabs, *if one clicks on the file's property.
>
Quote:
Quote:

> > > > For the life of me, I cannot find anything that describes how to show/list
> > > > the presence of the "license" tab. *TypeName: System.IO.FileInfo .... I can
> > > > retreive info about the file with the memberType Property ... *Nothing out of
> > > > the ordinary is listed for memberType when I enter the following command on a
> > > > file in question:
>
Quote:
Quote:

> > > > > gci | gm
>
Quote:
Quote:

> > > > I figured it would the easiest to do it in PS, but it didn't turn out to be
> > > > such a good *assumption.
>
Quote:
Quote:

> > > > Your assistance is greatly appreciated.
>
Quote:
Quote:

> > >Boomer,
>
Quote:
Quote:

> > > I looked around at what was available through Windows Media player,
> > > and the best I could come up with is this little script that tells you
> > > if a file has DRM protection or not:
>
Quote:
Quote:

> > > # Get-Protected.ps1
> > > param( [string] $wmaFile )
>
Quote:
Quote:

> > > if ( Test-Path $wmaFile )
> > > {
> > > * * $wmplayer = New-Object -ComObject "WMPlayer.OCX"
>
Quote:
Quote:

> > > * * $media = $wmplayer.newMedia( $wmaFile )
>
Quote:
Quote:

> > > * * [bool]::Parse( $media.getItemInfo( "Is_Protected" ) )
> > > }
> > > # Get-Protected.ps1
>
Quote:
Quote:

> > > If you want much more information that that, it looks like you might
> > > need to get a license from Microsoft for a DRM SDK of some kind:
> > >http://msdn2.microsoft.com/en-us/win.../bb190309.aspx
>
Quote:
Quote:

> > > These licenses are necessary if you are creating an application to
> > > manage licenses or something like that, so it seems like they
> > > shouldn't be necessary if all you want to do is query the
> > > information. *If you do find anything, please post back here; I would
> > > certainly be interested.
>
Quote:
Quote:

> > > Jeff
>
> Boomer,
>
> In case this is the route you decide to take, here is a small console
> application that determines if playback is allowed for a DRM-protected
> file:
>
> #include <atlbase.h>
> #include <TCHAR.H>
> #include "wmsdk.h"
>
> int _tmain( int argc, wchar_t *argv[] )
> {
> * * if ( SUCCEEDED( CoInitialize( NULL ) ) )
> * * {
> * * * * int nCount = MultiByteToWideChar(
> * * * * * * CP_ACP, 0, (LPCSTR)argv[ 1 ], -1, NULL, 0 );
>
> * * * * wchar_t *pwszFileName = new wchar_t[ nCount ];
>
> * * * * MultiByteToWideChar(
> * * * * * * CP_ACP, 0, (LPCSTR)argv[ 1 ], -1, pwszFileName, nCount );
>
> * * * * // check to see if the file is protected with DRM
> * * * * BOOL bProtected;
>
> * * * * HRESULT hr = WMIsContentProtected(
> * * * * * * pwszFileName, &bProtected );
>
> * * * * if ( SUCCEEDED( hr ) )
> * * * * {
> * * * * * * // if the file isn't protected with DRM,
> * * * * * * // we don't need to continue
> * * * * * * if ( !bProtected )
> * * * * * * {
> * * * * * * * * wprintf( L"Playback Allowed: True\n" );
> * * * * * * }
> * * * * * * else
> * * * * * * {
> * * * * * * * * // create a meta data editor
> * * * * * * * * CComPtr<IWMMetadataEditor> spEditor;
> * * * * * * * * hr = WMCreateEditor( &spEditor );
>
> * * * * * * * * // open the media file
> * * * * * * * * if ( SUCCEEDED( hr ) )
> * * * * * * * * {
> * * * * * * * * * * hr = spEditor->Open( pwszFileName );
> * * * * * * * * }
>
> * * * * * * * * // QI for the DRM editor
> * * * * * * * * CComQIPtr<IWMDRMEditor> spDRMEditor( spEditor );
> * * * * * * * * WMT_ATTR_DATATYPE wmtAttribute;
> * * * * * * * * BYTE playbackAllowed[ 4 ];
> * * * * * * * * WORD wLength;
>
> * * * * * * * * if ( SUCCEEDED( hr ) && spDRMEditor )
> * * * * * * * * {
> * * * * * * * * * * // get the 'playback allowed' property value
> * * * * * * * * * * hr = spDRMEditor->GetDRMProperty(
> * * * * * * * * * * * * g_wszWMDRM_ActionAllowed_Playback,
> * * * * * * * * * * * * &wmtAttribute, playbackAllowed,
> * * * * * * * * * * * * &wLength );
>
> * * * * * * * * * * if ( SUCCEEDED( hr ) )
> * * * * * * * * * * {
> * * * * * * * * * * * * wprintf( L"Playback Allowed: %s\n",
> * * * * * * * * * * * * * * ( (BOOL)*playbackAllowed ? L"True"
> * * * * * * * * * * * * * * * * * * * * * * * * * * *: L"False" ) );
> * * * * * * * * * * }
> * * * * * * * * }
> * * * * * * }
> * * * * }
>
> * * * * CoUninitialize();
> * * }
>
> * * return 0;
>
> }
>
> This should be enough to determine if you want to keep a file or not.
>
> Good luck.
>
> Jeff- Hide quoted text -
>
> - Show quoted text -
Thanks a bunch all ... I have a coulle of options here with your
help. I'll give all of them a try and let you all know how it turns
out.
My System SpecsSystem Spec
Old 03-03-2008   #8 (permalink)
Boomer
Guest


 
 

Re: deleting files that meet specific criteria

On Feb 29, 8:57*am, Boomer <marion...@xxxxxx> wrote:
Quote:

> On Feb 25, 9:21*pm, Jeff <jeff.hill...@xxxxxx> wrote:
>
>
>
>
>
Quote:

> > On Feb 25, 5:46 pm, Jeff <jeff.hill...@xxxxxx> wrote:
>
Quote:
Quote:

> > >Boomer,
>
Quote:
Quote:

> > > I found an SDK that might help you with what you want to do:
>
Quote:
Quote:

> > > Windows Media Format 11 SDKhttp://msdn2.microsoft.com/en-us/library/aa387410(VS.85).aspx
>
Quote:
Quote:

> > > This SDK lets you query all kinds of DRM information for a file, and
> > > the SDK comes with a whole bunch of useful sample code. *It doesn't
> > > look like any of it is easily accessible from .NET (no TLBs or COM
> > > servers), so you may have to write a small Win32 console application
> > > to query what you want, and then call it from your PowerShell script.
>
Quote:
Quote:

> > > I hope this helps.
>
Quote:
Quote:

> > > Jeff
>
Quote:
Quote:

> > > Jeff wrote:
> > > > On Feb 25, 1:00 pm,Boomer<Boo...@xxxxxx> wrote:
> > > > > Hi all,
>
Quote:
Quote:

> > > > > My intent is use PS to search through my digital music library andremove
> > > > > all DRM files for which I no longer have rights.
>
Quote:
Quote:

> > > > > I used to subscribe to the URGE music store, and have a bunch of files
> > > > > tagged with "protected content" under the License Property Set. *This
> > > > > "license" tab can be viewed as a tab along side the general, the security,
> > > > > and the summary tabs, *if one clicks on the file's property.
>
Quote:
Quote:

> > > > > For the life of me, I cannot find anything that describes how to show/list
> > > > > the presence of the "license" tab. *TypeName: System.IO.FileInfo... I can
> > > > > retreive info about the file with the memberType Property ... *Nothing out of
> > > > > the ordinary is listed for memberType when I enter the following command on a
> > > > > file in question:
>
Quote:
Quote:

> > > > > > gci | gm
>
Quote:
Quote:

> > > > > I figured it would the easiest to do it in PS, but it didn't turn out to be
> > > > > such a good *assumption.
>
Quote:
Quote:

> > > > > Your assistance is greatly appreciated.
>
Quote:
Quote:

> > > >Boomer,
>
Quote:
Quote:

> > > > I looked around at what was available through Windows Media player,
> > > > and the best I could come up with is this little script that tells you
> > > > if a file has DRM protection or not:
>
Quote:
Quote:

> > > > # Get-Protected.ps1
> > > > param( [string] $wmaFile )
>
Quote:
Quote:

> > > > if ( Test-Path $wmaFile )
> > > > {
> > > > * * $wmplayer = New-Object -ComObject "WMPlayer.OCX"
>
Quote:
Quote:

> > > > * * $media = $wmplayer.newMedia( $wmaFile )
>
Quote:
Quote:

> > > > * * [bool]::Parse( $media.getItemInfo( "Is_Protected" ) )
> > > > }
> > > > # Get-Protected.ps1
>
Quote:
Quote:

> > > > If you want much more information that that, it looks like you might
> > > > need to get a license from Microsoft for a DRM SDK of some kind:
> > > >http://msdn2.microsoft.com/en-us/win.../bb190309.aspx
>
Quote:
Quote:

> > > > These licenses are necessary if you are creating an application to
> > > > manage licenses or something like that, so it seems like they
> > > > shouldn't be necessary if all you want to do is query the
> > > > information. *If you do find anything, please post back here; I would
> > > > certainly be interested.
>
Quote:
Quote:

> > > > Jeff
>
Quote:

> >Boomer,
>
Quote:

> > In case this is the route you decide to take, here is a small console
> > application that determines if playback is allowed for a DRM-protected
> > file:
>
Quote:

> > #include <atlbase.h>
> > #include <TCHAR.H>
> > #include "wmsdk.h"
>
Quote:

> > int _tmain( int argc, wchar_t *argv[] )
> > {
> > * * if ( SUCCEEDED( CoInitialize( NULL ) ) )
> > * * {
> > * * * * int nCount = MultiByteToWideChar(
> > * * * * * * CP_ACP, 0, (LPCSTR)argv[ 1 ], -1, NULL, 0 );
>
Quote:

> > * * * * wchar_t *pwszFileName = new wchar_t[ nCount ];
>
Quote:

> > * * * * MultiByteToWideChar(
> > * * * * * * CP_ACP, 0, (LPCSTR)argv[ 1 ], -1, pwszFileName, nCount );
>
Quote:

> > * * * * // check to see if the file is protected with DRM
> > * * * * BOOL bProtected;
>
Quote:

> > * * * * HRESULT hr = WMIsContentProtected(
> > * * * * * * pwszFileName, &bProtected );
>
Quote:

> > * * * * if ( SUCCEEDED( hr ) )
> > * * * * {
> > * * * * * * // if the file isn't protected with DRM,
> > * * * * * * // we don't need to continue
> > * * * * * * if ( !bProtected )
> > * * * * * * {
> > * * * * * * * * wprintf( L"Playback Allowed: True\n" );
> > * * * * * * }
> > * * * * * * else
> > * * * * * * {
> > * * * * * * * * // create a meta data editor
> > * * * * * * * * CComPtr<IWMMetadataEditor> spEditor;
> > * * * * * * * * hr = WMCreateEditor( &spEditor );
>
Quote:

> > * * * * * * * * // open the media file
> > * * * * * * * * if ( SUCCEEDED( hr ) )
> > * * * * * * * * {
> > * * * * * * * * * * hr = spEditor->Open( pwszFileName );
> > * * * * * * * * }
>
Quote:

> > * * * * * * * * // QI for the DRM editor
> > * * * * * * * * CComQIPtr<IWMDRMEditor> spDRMEditor( spEditor );
> > * * * * * * * * WMT_ATTR_DATATYPE wmtAttribute;
> > * * * * * * * * BYTE playbackAllowed[ 4 ];
> > * * * * * * * * WORD wLength;
>
Quote:

> > * * * * * * * * if ( SUCCEEDED( hr ) && spDRMEditor )
> > * * * * * * * * {
> > * * * * * * * * * * // get the 'playback allowed' property value
> > * * * * * * * * * * hr = spDRMEditor->GetDRMProperty(
> > * * * * * * * * * * * * g_wszWMDRM_ActionAllowed_Playback,
> > * * * * * * * * * * * * &wmtAttribute, playbackAllowed,
> > * * * * * * * * * * * * &wLength );
>
Quote:

> > * * * * * * * * * * if ( SUCCEEDED( hr ) )
> > * * * * * * * * * * {
> > * * * * * * * * * * * * wprintf( L"Playback Allowed: %s\n",
> > * * * * * * * * * * * * * * ( (BOOL)*playbackAllowed ? L"True"
> > * * * * * * * * * * * * * * * * * * * * * * * * * * *: L"False" ) );
> > * * * * * * * * * * }
> > * * * * * * * * }
> > * * * * * * }
> > * * * * }
>
Quote:

> > * * * * CoUninitialize();
> > * * }
>
Quote:

> > * * return 0;
>
Quote:

> > }
>
Quote:

> > This should be enough to determine if you want to keep a file or not.
>
Quote:

> > Good luck.
>
Quote:

> > Jeff- Hide quoted text -
>
Quote:

> > - Show quoted text -
>
> Thanks a bunch all ... I have a coulle of options here with your
> help. *I'll give all of them a try and let you all know how it turns
> out.- Hide quoted text -
>
> - Show quoted text -
I found a way to remove those DRM files without programming (no fun,
but faster) ... Click on Library Tab > Music > In the navigation pane
right-click library and check/choose Show More Views > Online Stores

Obviously at this point it is querying and providing exactly what I
needed.

Thanks for all of your help.

-Boomer
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Deleting specific columns in an Excel spreadsheet... VB Script
Where specific files are kept? Vista file management
deleting files using a date criteria PowerShell
Get size of folders and subfolders that meet a certain criteria PowerShell
RC1 install problem: Disk does not meet the criteria to install vi Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46