Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Problem specifying -Property items in script

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 07-03-2008   #1 (permalink)
Smoshea
Guest


 

Problem specifying -Property items in script

Hi,

I'm trying to convert the details of an array of AD objects to a HTML file
using the following command:

$Members | ConvertTo-Html -Property Type,Name | Set-Content
"C:\temp\members.htm"

If I run this on the command line it works perfectly but when I run it as a
script I get this error:

ConvertTo-Html : A parameter cannot be found that matches parameter name ','.

It seems to be trying to use the separator as a property, but only when run
as a script! If I don't specify any -Property options it works OK.

I'm using the Quest Cmdlets to get the AD objects so I'm using the
"ActiveRoles Management Shell for Active Directory"

Any Ideas?

Thanks

Smoshea



My System SpecsSystem Spec
Old 07-03-2008   #2 (permalink)
sapienscripter's Avatar
Scripting Guru


Join Date: Jun 2008
Vista Ultimate 32bit
Syracuse, NY
 
Rep Power: 8
sapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura about
  sapienscripter is offline

Re: Problem specifying -Property items in script

Can you post more of the script? I haven't been able to duplicate your problem, at least not with other cmdlets. I'm going to test the Quest cmdlet but I don't see why that would make a difference.
My System SpecsSystem Spec
Old 07-03-2008   #3 (permalink)
sapienscripter's Avatar
Scripting Guru


Join Date: Jun 2008
Vista Ultimate 32bit
Syracuse, NY
 
Rep Power: 8
sapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura about
  sapienscripter is offline

Re: Problem specifying -Property items in script

Oh...just in case, are you using PowerShell v1.0 or the CTP?
My System SpecsSystem Spec
Old 07-03-2008   #4 (permalink)
Smoshea
Guest


 

Re: Problem specifying -Property items in script

OK, here's the whole script:

[void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

$Form = new-object Windows.Forms.Form
$Form.Text = "Group Membership Form"
$Form.Size = New-Object System.Drawing.Size(300,200)
$Form.StartPosition = "CenterScreen"

$SelectLabel = New-Object System.Windows.Forms.Label
$SelectLabel.Location = New-Object System.Drawing.Size(10,20)
$SelectLabel.Size = New-Object System.Drawing.Size(280,20)
$SelectLabel.Text = "Select a Group"
$Form.Controls.Add($SelectLabel)

$GroupComboBox = New-Object System.Windows.Forms.ComboBox
$GroupComboBox.Location = New-Object System.Drawing.Size(10,40)
$GroupComboBox.Size = New-Object System.Drawing.Size(260,20)
$GroupComboBox.Sorted = $True

$GroupHashTable = @{}

# Populate the Groups list
$Groups = Get-QADObject -Service 'Test.Domain.com:389' -Type 'Group'
-SearchRoot 'OU=TestOU,DC=TEST,DC=DOMAIN,DC=COM' -SizeLimit '0'
foreach ($Group in $Groups) {
$GroupHashTable[$Group.GroupName] = $Group.DN
$GroupComboBox.Items.Add($Group.GroupName)}
# End Populate Groups list
$Form.Controls.Add($GroupComboBox)

$ListButton = New-Object System.Windows.Forms.Button
$ListButton.Location = New-Object System.Drawing.Size(90,70)
$ListButton.Size = New-Object System.Drawing.Size(100,23)
$ListButton.Text = "List Members"
$ListButton.Add_Click({


$Selected = $GroupComboBox.SelectedItem
$Members = Get-QADGroupMember -Identity $GroupHashTable[$Selected]
$Members | ConvertTo-Html -Property Type,Name | Set-Content
"C:\temp\members.htm"
C:\"Program Files"\"Internet Explorer"\iexplore.exe "C:\temp\members.htm"

})
$Form.Controls.Add($ListButton)


$Form.Add_Shown({$Form.Activate()})
$Form.ShowDialog()



"sapienscripter" wrote:
Quote:

>
> Can you post more of the script? I haven't been able to duplicate your
> problem, at least not with other cmdlets. I'm going to test the Quest
> cmdlet but I don't see why that would make a difference.
>
>
> --
> sapienscripter
>
> Coming Soon: 'Managing Active Directory with Windows PowerShell: TFM'
> (http://www.sapienpress.com/ad.asp)
>
> Windows PowerShell MVP
>
> 'My Blog' (http://blog.sapien.com/)
> 'FollowMe on Twitter' (http://www.twitter.com/JeffHicks)
>
My System SpecsSystem Spec
Old 07-03-2008   #5 (permalink)
sapienscripter's Avatar
Scripting Guru


Join Date: Jun 2008
Vista Ultimate 32bit
Syracuse, NY
 
Rep Power: 8
sapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura about
  sapienscripter is offline

Re: Problem specifying -Property items in script

I think the issue is that you are using a WinForm. In PowerShell v1.0, when you use a form, it blocks PowerShell until you close the form. What is happening is that $members is never getting populated, or at least you can't use it until the form closes. Modify the form to close after the user selects a group and move your click code to after ShowDialog.
My System SpecsSystem Spec
Old 07-03-2008   #6 (permalink)
Smoshea
Guest


 

Re: Problem specifying -Property items in script

$Members is populated and can be used, if I specify only a single or no
Properties it all works as it should. The problem with that is 1 property is
not enough information and all of them is far too many.

Stu

"sapienscripter" wrote:
Quote:

>
> I think the issue is that you are using a WinForm. In PowerShell v1.0,
> when you use a form, it blocks PowerShell until you close the form.
> What is happening is that $members is never getting populated, or at
> least you can't use it until the form closes. Modify the form to close
> after the user selects a group and move your click code to after
> ShowDialog.
>
>
> --
> sapienscripter
>
> Coming Soon: 'Managing Active Directory with Windows PowerShell: TFM'
> (http://www.sapienpress.com/ad.asp)
>
> Windows PowerShell MVP
>
> 'My Blog' (http://blog.sapien.com/)
> 'FollowMe on Twitter' (http://www.twitter.com/JeffHicks)
>
My System SpecsSystem Spec
Old 07-03-2008   #7 (permalink)
sapienscripter's Avatar
Scripting Guru


Join Date: Jun 2008
Vista Ultimate 32bit
Syracuse, NY
 
Rep Power: 8
sapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura about
  sapienscripter is offline

Re: Problem specifying -Property items in script

I still think this is related to the interaction of Windows forms with PowerShell v1.0. Yes $members is created and you have some access to it. I know that if you move these lines

$Members | ConvertTo-Html -Property Type,Name | Set-Content
"C:\temp\members.htm"
C:\"Program Files"\"Internet Explorer"\iexplore.exe "C:\temp\members.htm"

to after ShowDialog everything works for you.
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Add -credential property to script ? voodooking PowerShell 3 08-31-2008 11:42 AM
Thread-safety: Change property of items in arraylist versus removingitems from the arraylist Curious .NET General 2 08-06-2008 06:36 AM
Word 2007 table cell property problem in Vista Dick De Vries Vista General 1 05-09-2008 10:34 PM
Use my custom TypeDescriptor to obtains default Value on property inXAML Property Editor of Visual Studio 2008 azerty Avalon 0 04-14-2008 06:14 AM
Taskbar property problem crawjoel Vista General 2 01-08-2008 06:55 PM


Vistax64.com 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 2005-2008

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 47 48 49 50 51