Script works fine in Powershell/ISE but not in PrimalForms.

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
daviesg6
Posts: 49
Joined: Thu Nov 21, 2013 12:36 pm

Re: Script works fine in Powershell/ISE but not in PrimalFor

Post by daviesg6 »

I copied and pasted the code from a previous entry in this thread so it is the same code.
Debugger shows nothing
the script DOES work as a standalone in ISE, irrespective of what the variable name is the script executes on an OU, as long as an OU name is entered by the user.

t's ok, I'll find another way to do this.

jvierra
Posts: 14578
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Re: Script works fine in Powershell/ISE but not in PrimalFor

Post by jvierra »

There is no OU involved in this code you posted:
PowerShell Code
Double-click the code block to select all.
$resultsbox.Text=Get-QADObject domain.com/$UserEntryTextBox.Text -SecurityMask Dacl | Get-QADPermission -UseExtendedMatch -Inherited -SchemaDefault -Property ('name') | Out-String
     $ResultsBox.Focus()
You cannot use "$UserEntryTextBox.Text " in the ISE. It will not work. It is only valid in a form.

THe format of that identity is just wrong. I haveQuest and have tested it. It is a bad syntax.

I keep asking for the PFF file and I can test it completely. If you cannot see or understand the issue I ma posting about then I cannot be of much help.

Sorry.

User avatar
daviesg6
Posts: 49
Joined: Thu Nov 21, 2013 12:36 pm

Re: Script works fine in Powershell/ISE but not in PrimalFor

Post by daviesg6 »

The OU is what the user enters in the text box, that's why the code uses the variable $userentrybox. The path is domainname/variable. As long as the OU is entered there it is supposed to look at the permissions set on that OU.
Again, this works when not in a form, as soon as it is included in the primalforms code it stops working and that is my problem.

To break it down, the user enters the name of an OU, this is prefixed in the code by the domain name and the script looks up the permissions set on the OU the user entered the name of. It then, when not in the form, displays the permissions set on the OU, all users, all groups with inherited or explicit permissions set on the OU are listed, the permissions they have are listed and whether it is inherited or not is displayed.
The code works fine until it is put into the form, when I try to run this in the form it does nothing. If it was looking for a user ID and an OU was entered it would say there was a problem, it couldn't find the object listed. It does not do this.

I have posted 2 versions of the same script, the only differences are one is a standalone, no variables needed, this works perfectly, the second version includes variables because that's the idea of using a form, allow users to pick which OU they want details of. the actual script itself is the same, just where it gets it's search criteria from and where to display it are different.

User avatar
Alexander Riedel
Posts: 7498
Joined: Tue May 29, 2007 4:43 pm

Re: Script works fine in Powershell/ISE but not in PrimalFor

Post by Alexander Riedel »

Run your script in powershell -noprofile first
Usually in these cases you have a dependency on a profile.

Please note that this particular forum is for scripting questions and NOT product support questions.
Alexander Riedel
SAPIEN Technologies, Inc.

jvierra
Posts: 14578
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Re: Script works fine in Powershell/ISE but not in PrimalFor

Post by jvierra »

For an OU with Get-ADObject this will work

$oupath="domain.com/$($textbox.Text)"

Note that you must use the subexpression evaluation operator. This will not work for userids and the supplied canonical path must be the complete path to the object.

jvierra
Posts: 14578
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Re: Script works fine in Powershell/ISE but not in PrimalFor

Post by jvierra »

it works fine for me with Quest using the last method I posted which guarantees proper evaluation of the textbox properties.


I will build a very simple demo in a few minutes if I have time.

jvierra
Posts: 14578
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Re: Script works fine in Powershell/ISE but not in PrimalFor

Post by jvierra »

Here is what I used and it works as expected:
PowerShell Code
Double-click the code block to select all.
$button1_Click={
	#TODO: Place custom script here
	
	$textbox2.text=Get-QADObject "test.local/$($textbox1.Text)" |fl | Out-String
}

User avatar
daviesg6
Posts: 49
Joined: Thu Nov 21, 2013 12:36 pm

Re: Script works fine in Powershell/ISE but not in PrimalFor

Post by daviesg6 »

thank you, that works, I was missing the (see bold characters) "domain/$(variable)"

Sorry to have caused confusion.

jvierra
Posts: 14578
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Re: Script works fine in Powershell/ISE but not in PrimalFor

Post by jvierra »

Yeah! That is one of the things I was trying to get you to address. To bad we kept having issues with the web site and with which code was at issue.

This is a basic PowerShell issue. Whenever we "stringify" a variable the variable needs to be evaluated as a value type and not an object property.

The issue has nothing to do with FOrms or ISE or Sapien. It is a basic issue of PowerShell.

Example:
PowerShell Code
Double-click the code block to select all.
PS C:\scripts> $item=get-service browser
PS C:\scripts> $item.name
browser
PS C:\scripts> "$item.name"
System.ServiceProcess.ServiceController.name
PS C:\scripts> "$($item.name)"
browser
PS C:\scripts>
Note what happens if we do not use "subexpression evaluation"

Here is a useful post: http://mcpmag.com/articles/2012/10/02/p ... ables.aspx

Locked