![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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 Specs![]() |
| | #2 (permalink) |
| Scripting Guru ![]() Rep Power: 8 ![]() ![]() ![]() | 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 Specs![]() |
| | #3 (permalink) |
| Scripting Guru ![]() Rep Power: 8 ![]() ![]() ![]() | Re: Problem specifying -Property items in script Oh...just in case, are you using PowerShell v1.0 or the CTP? |
My System Specs![]() |
| | #4 (permalink) | ||||||||||||
| 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:
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #5 (permalink) |
| Scripting Guru ![]() Rep Power: 8 ![]() ![]() ![]() | 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 Specs![]() |
| | #6 (permalink) | ||||||||||||
| 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:
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #7 (permalink) |
| Scripting Guru ![]() Rep Power: 8 ![]() ![]() ![]() | 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 Specs![]() |
![]() |
| 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 |