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 - Accessing array properties from WMI

Reply
 
Old 11-28-2008   #1 (permalink)
Martin Bayly


 
 

Accessing array properties from WMI

Hi
I'm trying to use wmi to modify the script maps for an IIS6 web site.
Specifically, I want to script the adding of PUT and DELETE verbs to the aspx
handler.

I can see that script maps exist for a particular website's IIsWebVirtualDir
in the IIS metabase.
But I can't figure out how to even read it from Powershell/WMI. It always
comes back blank

e.g.

get-wmiobject IIsWebVirtualDirSetting -namespace "root\MicrosoftIISv2" |
where {$_.Name -eq "W3SVC/357108404/root"} | select-object ScriptMaps

if i pipe the result into get-member the scriptmaps property is defined as:
ScriptMaps Property
System.Management.ManagementObject#ScriptMap[] ScriptMaps {get;set;}

So maybe it's something to do with the way the property is defined? Maybe I
have to access it in some other way?

Thanks
Martin


My System SpecsSystem Spec
Old 11-28-2008   #2 (permalink)
tojo2000


 
 

Re: Accessing array properties from WMI

On Nov 28, 12:09*am, Martin Bayly <Martin
Ba...@xxxxxx> wrote:
Quote:

> Hi
> I'm trying to use wmi to modify the script maps for an IIS6 web site. *
> Specifically, I want to script the adding of PUT and DELETE verbs to the aspx
> handler.
>
> I can see that script maps exist for a particular website's IIsWebVirtualDir
> in the IIS metabase.
> But I can't figure out how to even read it from Powershell/WMI. *It always
> comes back blank
>
> e.g.
>
> get-wmiobject IIsWebVirtualDirSetting -namespace "root\MicrosoftIISv2" |
> where {$_.Name -eq "W3SVC/357108404/root"} | select-object ScriptMaps
>
> if i pipe the result into get-member the scriptmaps property is defined as:
> ScriptMaps * * * * * * * * * *Property * *
> System.Management.ManagementObject#ScriptMap[] ScriptMaps {get;set;}
>
> So maybe it's something to do with the way the property is defined? *Maybe I
> have to access it in some other way?
>
> Thanks
> Martin
I don't have access to an IIS server where I am right now, but I've
come across this before when the property you want to get is a lazy
property. Lazy properties aren't populated when you pull up the
object, instead you have to call the Get() method on the object and
then access the property.
My System SpecsSystem Spec
Old 11-28-2008   #3 (permalink)
Martin Bayly


 
 

Re: Accessing array properties from WMI

Thanks for the reply. Yep, I've seen references to lazy properties too and
wondered if it could be related to that.

Which object do you think I should call Get() on.
I tried just calling Get() as follows but didn't seem to make any
difference. ScriptMaps is still empty.

$vdir = get-wmiobject IIsWebVirtualDirSetting -namespace
"root\MicrosoftIISv2" | where {$_.Name -eq "W3SVC/357108404/root"}

$vdir.Get()

The annoying thing is, I also tried doing this in VBScript and it seems to
return the ScriptMaps ok. Didn't know either VBScript or Powershell until
about 3 days ago, and beginning to think I made the wrong choice in opting
for Powershell.

Thanks
Martin

"tojo2000" wrote:
Quote:

> On Nov 28, 12:09 am, Martin Bayly <Martin
> Ba...@xxxxxx> wrote:
Quote:

> > Hi
> > I'm trying to use wmi to modify the script maps for an IIS6 web site.
> > Specifically, I want to script the adding of PUT and DELETE verbs to the aspx
> > handler.
> >
> > I can see that script maps exist for a particular website's IIsWebVirtualDir
> > in the IIS metabase.
> > But I can't figure out how to even read it from Powershell/WMI. It always
> > comes back blank
> >
> > e.g.
> >
> > get-wmiobject IIsWebVirtualDirSetting -namespace "root\MicrosoftIISv2" |
> > where {$_.Name -eq "W3SVC/357108404/root"} | select-object ScriptMaps
> >
> > if i pipe the result into get-member the scriptmaps property is defined as:
> > ScriptMaps Property
> > System.Management.ManagementObject#ScriptMap[] ScriptMaps {get;set;}
> >
> > So maybe it's something to do with the way the property is defined? Maybe I
> > have to access it in some other way?
> >
> > Thanks
> > Martin
>
> I don't have access to an IIS server where I am right now, but I've
> come across this before when the property you want to get is a lazy
> property. Lazy properties aren't populated when you pull up the
> object, instead you have to call the Get() method on the object and
> then access the property.
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
VB script - for accessing a array returned from stored procedure VB Script
accessing control properties .NET General
Accessing File Properties PowerShell
Accessing Word document properties PowerShell
wmi accessing indexed properties PowerShell


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