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.
This topic is 9 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
daviesg6
Posts: 49
Last visit: Tue Nov 25, 2014 1:23 pm

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

Post by daviesg6 »

So, I have a script I created to make a repetitive task easier for my manager. He needs to run reports on who has permissions on specific OUs, so I created a neat little menu based ps1 that let him do this. He has asked if this can be made into a GUI after seeing the forms I created for other tasks.

The code I'm using is:
PowerShell Code
Double-click the code block to select all.
#Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.10.0
# Generated On: 4/22/2014 2:37 PM
# Generated By: gdavies
########################################################################

#region Import the Assemblies
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
#endregion

#region Generated Form Objects
$form1 = New-Object System.Windows.Forms.Form
$textBox3 = New-Object System.Windows.Forms.TextBox
$GroupNameLabel = New-Object System.Windows.Forms.Label
$TextLabel = New-Object System.Windows.Forms.Label
$ResultLabel = New-Object System.Windows.Forms.Label
$ResultsBox = New-Object System.Windows.Forms.TextBox
$ExitButton = New-Object System.Windows.Forms.Button
$RemoveUserFromGroupButton = New-Object System.Windows.Forms.Button
$AddUserToGroupButton = New-Object System.Windows.Forms.Button
$DisplayGroupMembersButton = New-Object System.Windows.Forms.Button
$SearchOUPermissionsButton = New-Object System.Windows.Forms.Button
$UserEntryTextBox = New-Object System.Windows.Forms.TextBox
$WarningLabel = New-Object System.Windows.Forms.Label
$InstructionLabel = New-Object System.Windows.Forms.Label
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects

#----------------------------------------------
#Generated Event Script Blocks
#----------------------------------------------
#Provide Custom Code for events specified in PrimalForms.
$AddUserToGroupButton_OnClick= 
{
$resultsbox.Text=Add-ADGroupMember -Identity $textBox3.Text -Members $UserEntryTextBox.Text | Out-String
     $ResultsBox.Focus()
}

$ExitButton_OnClick= 
{
$form1.Close()
}

$DisplayGroupMembersButton_OnClick= 
{
$resultsbox.Text=Get-ADGroupMember $UserEntryTextBox.Text -recursive | Select-Object Name | Out-String
     $ResultsBox.Focus()
}

$RemoveUserFromGroupButton_OnClick= 
{
$resultsbox.Text=Remove-ADGroupMember -Identity $textBox3.Text -Members $UserEntryTextBox.Text -confirm:$false | Out-String
     $ResultsBox.Focus()
}

$SearchPermButton_OnClick= 
{
$resultsbox.Text=Get-QADObject bellevue.edu/$UserEntryTextBox -SecurityMask Dacl | Get-QADPermission -UseExtendedMatch -Inherited -SchemaDefault -Property ('name') | Out-String
     $ResultsBox.Focus()
}

$ImportModules= 
{
Add-PSSnapin Quest.ActiveRoles.ADManagement
import-module activedirectory
}

$OnLoadForm_StateCorrection=
{#Correct the initial state of the form to prevent the .Net maximized form issue
	$form1.WindowState = $InitialFormWindowState
}

#----------------------------------------------
#region Generated Form Code
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 611
$System_Drawing_Size.Width = 684
$form1.ClientSize = $System_Drawing_Size
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$form1.Name = "form1"
$form1.Text = "Search and modify AD permissions"
$form1.add_Load($ImportModules)

$textBox3.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 430
$System_Drawing_Point.Y = 140
$textBox3.Location = $System_Drawing_Point
$textBox3.Name = "textBox3"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 240
$textBox3.Size = $System_Drawing_Size
$textBox3.TabIndex = 15

$form1.Controls.Add($textBox3)

$GroupNameLabel.DataBindings.DefaultDataSourceUpdateMode = 0
$GroupNameLabel.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",8.25,1,3,0)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 340
$System_Drawing_Point.Y = 140
$GroupNameLabel.Location = $System_Drawing_Point
$GroupNameLabel.Name = "GroupNameLabel"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 80
$GroupNameLabel.Size = $System_Drawing_Size
$GroupNameLabel.TabIndex = 14
$GroupNameLabel.Text = "Name 2"
$GroupNameLabel.TextAlign = 32

$form1.Controls.Add($GroupNameLabel)

$TextLabel.DataBindings.DefaultDataSourceUpdateMode = 0
$TextLabel.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",8.25,1,3,0)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 10
$System_Drawing_Point.Y = 140
$TextLabel.Location = $System_Drawing_Point
$TextLabel.Name = "TextLabel"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 80
$TextLabel.Size = $System_Drawing_Size
$TextLabel.TabIndex = 13
$TextLabel.Text = "Name 1"
$TextLabel.TextAlign = 32

$form1.Controls.Add($TextLabel)

$ResultLabel.DataBindings.DefaultDataSourceUpdateMode = 0
$ResultLabel.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",8.25,1,3,0)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 10
$System_Drawing_Point.Y = 180
$ResultLabel.Location = $System_Drawing_Point
$ResultLabel.Name = "ResultLabel"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 660
$ResultLabel.Size = $System_Drawing_Size
$ResultLabel.TabIndex = 12
$ResultLabel.Text = "Results"
$ResultLabel.TextAlign = 32

$form1.Controls.Add($ResultLabel)

$ResultsBox.BackColor = [System.Drawing.Color]::FromArgb(255,0,0,0)
$ResultsBox.DataBindings.DefaultDataSourceUpdateMode = 0
$ResultsBox.ForeColor = [System.Drawing.Color]::FromArgb(255,124,252,0)
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 10
$System_Drawing_Point.Y = 210
$ResultsBox.Location = $System_Drawing_Point
$ResultsBox.Multiline = $True
$ResultsBox.Name = "ResultsBox"
$ResultsBox.ReadOnly = $True
$ResultsBox.ScrollBars = 2
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 330
$System_Drawing_Size.Width = 660
$ResultsBox.Size = $System_Drawing_Size
$ResultsBox.TabIndex = 11

$form1.Controls.Add($ResultsBox)

$ExitButton.BackColor = [System.Drawing.Color]::FromArgb(255,0,0,0)

$ExitButton.DataBindings.DefaultDataSourceUpdateMode = 0
$ExitButton.FlatStyle = 1
$ExitButton.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",8.25,1,3,0)
$ExitButton.ForeColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
$ExitButton.Image = [System.Drawing.Image]::FromFile('C:\Users\gdavies\Pictures\exit1.jpg')
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 590
$System_Drawing_Point.Y = 550
$ExitButton.Location = $System_Drawing_Point
$ExitButton.Name = "ExitButton"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 40
$System_Drawing_Size.Width = 75
$ExitButton.Size = $System_Drawing_Size
$ExitButton.TabIndex = 10
$ExitButton.UseVisualStyleBackColor = $False
$ExitButton.add_Click($ExitButton_OnClick)

$form1.Controls.Add($ExitButton)

$RemoveUserFromGroupButton.BackColor = [System.Drawing.Color]::FromArgb(255,255,69,0)

$RemoveUserFromGroupButton.DataBindings.DefaultDataSourceUpdateMode = 0
$RemoveUserFromGroupButton.FlatStyle = 1
$RemoveUserFromGroupButton.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",6.75,1,3,0)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 460
$System_Drawing_Point.Y = 550
$RemoveUserFromGroupButton.Location = $System_Drawing_Point
$RemoveUserFromGroupButton.Name = "RemoveUserFromGroupButton"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 40
$System_Drawing_Size.Width = 120
$RemoveUserFromGroupButton.Size = $System_Drawing_Size
$RemoveUserFromGroupButton.TabIndex = 9
$RemoveUserFromGroupButton.Text = "Remove user from security group"
$RemoveUserFromGroupButton.UseVisualStyleBackColor = $False
$RemoveUserFromGroupButton.add_Click($RemoveUserFromGroupButton_OnClick)

$form1.Controls.Add($RemoveUserFromGroupButton)

$AddUserToGroupButton.BackColor = [System.Drawing.Color]::FromArgb(255,255,69,0)

$AddUserToGroupButton.DataBindings.DefaultDataSourceUpdateMode = 0
$AddUserToGroupButton.FlatStyle = 1
$AddUserToGroupButton.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",6.75,1,3,0)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 310
$System_Drawing_Point.Y = 550
$AddUserToGroupButton.Location = $System_Drawing_Point
$AddUserToGroupButton.Name = "AddUserToGroupButton"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 40
$System_Drawing_Size.Width = 120
$AddUserToGroupButton.Size = $System_Drawing_Size
$AddUserToGroupButton.TabIndex = 8
$AddUserToGroupButton.Text = "Add user to security group"
$AddUserToGroupButton.UseVisualStyleBackColor = $False
$AddUserToGroupButton.add_Click($AddUserToGroupButton_OnClick)

$form1.Controls.Add($AddUserToGroupButton)

$DisplayGroupMembersButton.BackColor = [System.Drawing.Color]::FromArgb(255,173,255,47)

$DisplayGroupMembersButton.DataBindings.DefaultDataSourceUpdateMode = 0
$DisplayGroupMembersButton.FlatStyle = 1
$DisplayGroupMembersButton.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",6.75,1,3,0)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 160
$System_Drawing_Point.Y = 550
$DisplayGroupMembersButton.Location = $System_Drawing_Point
$DisplayGroupMembersButton.Name = "DisplayGroupMembersButton"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 40
$System_Drawing_Size.Width = 120
$DisplayGroupMembersButton.Size = $System_Drawing_Size
$DisplayGroupMembersButton.TabIndex = 7
$DisplayGroupMembersButton.Text = "Display members of security group"
$DisplayGroupMembersButton.UseVisualStyleBackColor = $False
$DisplayGroupMembersButton.add_Click($DisplayGroupMembersButton_OnClick)

$form1.Controls.Add($DisplayGroupMembersButton)

$SearchOUPermissionsButton.BackColor = [System.Drawing.Color]::FromArgb(255,173,255,47)

$SearchOUPermissionsButton.DataBindings.DefaultDataSourceUpdateMode = 0
$SearchOUPermissionsButton.FlatStyle = 1
$SearchOUPermissionsButton.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",6.75,1,3,0)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 10
$System_Drawing_Point.Y = 550
$SearchOUPermissionsButton.Location = $System_Drawing_Point
$SearchOUPermissionsButton.Name = "SearchOUPermissionsButton"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 40
$System_Drawing_Size.Width = 120
$SearchOUPermissionsButton.Size = $System_Drawing_Size
$SearchOUPermissionsButton.TabIndex = 6
$SearchOUPermissionsButton.Text = " Search assigned permissions for OU"
$SearchOUPermissionsButton.UseVisualStyleBackColor = $False
$SearchOUPermissionsButton.add_Click($SearchOUPermissionsButton_OnClick)

$form1.Controls.Add($SearchOUPermissionsButton)

$UserEntryTextBox.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 100
$System_Drawing_Point.Y = 140
$UserEntryTextBox.Location = $System_Drawing_Point
$UserEntryTextBox.Name = "UserEntryTextBox"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 240
$UserEntryTextBox.Size = $System_Drawing_Size
$UserEntryTextBox.TabIndex = 5

$form1.Controls.Add($UserEntryTextBox)

$WarningLabel.BackColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
$WarningLabel.DataBindings.DefaultDataSourceUpdateMode = 0
$WarningLabel.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",8.25,1,3,0)
$WarningLabel.ForeColor = [System.Drawing.Color]::FromArgb(255,178,34,34)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 10
$System_Drawing_Point.Y = 70
$WarningLabel.Location = $System_Drawing_Point
$WarningLabel.Name = "WarningLabel"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 60
$System_Drawing_Size.Width = 660
$WarningLabel.Size = $System_Drawing_Size
$WarningLabel.TabIndex = 1
$WarningLabel.Text = "Ensure the OU, Security Group or User ID are entered exactly as they appear in AD. Any incorrect spelling will result in either a failure or the search/change being run on the wrong object
For Add/Remove user from group, please enter the user ID in the first text box, the Group name in the second"
$WarningLabel.TextAlign = 32

$form1.Controls.Add($WarningLabel)

$InstructionLabel.DataBindings.DefaultDataSourceUpdateMode = 0
$InstructionLabel.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",8.25,1,3,0)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 10
$System_Drawing_Point.Y = 10
$InstructionLabel.Location = $System_Drawing_Point
$InstructionLabel.Name = "InstructionLabel"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 40
$System_Drawing_Size.Width = 660
$InstructionLabel.Size = $System_Drawing_Size
$InstructionLabel.TabIndex = 0
$InstructionLabel.Text = "Enter the OU, Security Group or User you wish to search or modify then hit the relevant button.            IMPORTANT NOTE: No confirmation will be requested so please ensure you are making the correct change and you are authorized to make the change."
$InstructionLabel.TextAlign = 32

$form1.Controls.Add($InstructionLabel)

#endregion Generated Form Code

#Save the initial state of the form
$InitialFormWindowState = $form1.WindowState
#Init the OnLoad event to correct the initial state of the form
$form1.add_Load($OnLoadForm_StateCorrection)
#Show the Form
$form1.ShowDialog()| Out-Null

} #End Function

#Call the Function
GenerateForm
Everything works, apart from the main one he needs (lines 38+39). If I try to run this it gives no output, I tried pushing it out to a file, it creates the file but there is no data. Running the same script this way:
PowerShell Code
Double-click the code block to select all.
Add-PSSnapin Quest.ActiveRoles.ADManagement
import-module activedirectory
$prompt = @"
 ______________________________________________________________________________
|                                                                              |
|                     Please select from the options below                     |
|                                                                              |
|                     s = Search assigned permissions for OU                   |
|                     g = Display members of Security Group                    |
|                     a = Add user to Security Group                           |
|                     r = Remove user from Security Group                      |
|                     x = exit                                                 |
|                                                                              |
|______________________________________________________________________________|


"@
Clear-host
Do{
	$originalcolor = $host.UI.RawUI.ForegroundColor
	$host.UI.RawUI.ForegroundColor = "green"
	$choice = Read-Host -Prompt $prompt
	$host.UI.RawUI.ForegroundColor = "green"
	Switch($choice){
        s {$user = Read-Host 'Enter the OU you wish to see assigned permissions for. you do not need to enter bellevue.edu/ just the path from there (i.e. employees, employees/disabled accounts etc.)' ; Get-QADObject bellevue.edu/$user -SecurityMask Dacl | Get-QADPermission -UseExtendedMatch -Inherited -SchemaDefault -Property ('sAMAccountName','name')}
        g {$user = Read-Host 'Enter the Security Group name you wish to list the members of' ; Get-ADGroupMember $user -recursive | Select-Object Name}
        a {$user = Read-Host 'Enter the Account name (sAMAccountName) you wish to add'; $group = Read-Host 'Enter the Security Group you wish to add the user to' ; Add-ADGroupMember -Identity $group -Members $user}
        r {$user = Read-Host 'Enter the Account name (sAMAccountName) you wish to remove'; $group = Read-Host 'Enter the Security Group you wish to remove the user from' ; Remove-ADGroupMember  -Identity $group -Members $user -confirm:$false}


        x {break}

		default {write-host "Invalid selection, please try again." -ForegroundColor Red}
	}
}Until($choice -eq "x")
works fine, the only difference is the variable names and the way it looks.

Is this a problem with PrimalForms and the Quest pssnapin not playing together maybe?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

When posting code from PS2012 can you please post the PFF as an attachment. It is very hard to pick through all of that.

You could also just post the event that is at issue.
User avatar
daviesg6
Posts: 49
Last visit: Tue Nov 25, 2014 1:23 pm

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

Post by daviesg6 »

My apologies, the one script that is not working is actually lines 61 and 62, the code is
PowerShell Code
Double-click the code block to select all.
{$resultsbox.Text=Get-QADObject bellevue.edu/$UserEntryTextBox.Text -SecurityMask Dacl | Get-QADPermission -UseExtendedMatch -Inherited -SchemaDefault -Property ('name') | Out-String     $ResultsBox.Focus()}
When run as a standalone, replacing the
PowerShell Code
Double-click the code block to select all.
$UserEntryTextBox.Text
with an OU gives all the permissions on the OU, in the PrimalForms form it gives nothing, no errors, no results.

Removing .Text after the variable name makes no difference, I removed it to test and saw no change.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

It is nearly impossible to understand what you are asking.

I have no idea what lines 61 and 62 are. There are no line numbers on your code.

What is it that you are adding and removing. Those objects do not exist out side of the form.

I am sorry but you are pasting a lot of unrelated code and making statements that do not relate to anything that I can get a handle. on.
User avatar
daviesg6
Posts: 49
Last visit: Tue Nov 25, 2014 1:23 pm

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

Post by daviesg6 »

I'm confused by your comment. When I look at my post I clearly see line numbers in the code blocks so I don't understand why you are saying you don't see this.

All I am trying to do is get the single script, previously entered as a separate code block following your request for this to be posted separately, which provides a list of users and groups with ANY permissions assigned on an OU. Powershell does not have this function enabled by default but Quest have provided a PSSnappin that does. When this is used standalone it works, when included in the PrimalForms code it gives no output, it gives no errors. The line of code, when used standalone is:
PowerShell Code
Double-click the code block to select all.
Get-QADObject domain.com/OU -SecurityMask Dacl | Get-QADPermission -UseExtendedMatch -Inherited -SchemaDefault -Property ('sAMAccountName','name')
This gives a list of the groups and users who have the permission to do anything to the OU listed in the script

When this is adapted to be used as part of the form, the line changes to"
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()

$resultsbox.Text is the text box results are displayed in
$UserEntryTextBox.Text is the text box the user enters the OU they want to find results for.

As for posting unrelated code, what I have posted is related, I posted the full script that works as a standard powershell script and the full PrimalForms script. Without the full script the variable names mean nothing and raise more questions.

All I need to know is does PrimalForms have an issue using Quest PSSnappins? If not, why do I not get any results when I run the query to give the permissions set on the specified OU?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

Sorry but the site is not working correctly. Yesterday the formatting and line numbers were missing.

The following will not send output anywhere inside of a form. You need to assign the output to a variable or a control.
PowerShell Code
Double-click the code block to select all.
#
Get-QADObject domain.com/OU -SecurityMask Dacl | 
     Get-QADPermission -UseExtendedMatch -Inherited -SchemaDefault -Property sAMAccountName,name
#
Spend sometime reading the blog discussion on how to design and use Admin forms in PowerShell. I think it will answer many of your questions.

http://www.sapien.com/blog/topics/user- ... istrators/
User avatar
daviesg6
Posts: 49
Last visit: Tue Nov 25, 2014 1:23 pm

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

Post by daviesg6 »

No worries, site issues can be a pain.

I already have it set to output results, the line of code I posted that is giving no results is
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()
So the results are being piped to $ResultsBox using Out-string. The same command is used on other scripts in this same form, and other forms I have created, and it works just fine. This particular script gives no output. I tried outputting to a text file, the file was created but had no content.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

It is hard to understand what you are asking. This code is not what you posted before.

You are not executing code that absolutely works in ISe because you are using form variables.

This is not likely to work:

domain.com/$UserEntryTextBox.Text

It will`not work in ISE as you stated. QAD takes a user identity. That is not an identity.

<domain>\<userid> is an identity.

Run in the debugger and you will see what I mean. Try using a hardcoded ID. Insert a messagebox and output the value. Check the error code.

Have you tried any of these things yet?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

Try it like this:
PowerShell Code
Double-click the code block to select all.
$userid="domain\$($UserEntryTextBox.Text)"
msgbox $userid
$txt=Get-QADObject $userid -SecurityMask Dacl |
     Get-QADPermission -UseExtendedMatch -Inherited -SchemaDefault -Property name |
     Out-String

msgbox $txt
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

One other option:
$userid="$($UserEntryTextBox.Text)@domain.com"

FOr the current domain none of this is needed. Just use the users accounted (samaccountname)
This topic is 9 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked