Hello,
What is wrong with my code?
In the first textbox, the command work
![]()
but in the second textbox, the command not work.
![]()
but if I put the group name instead of a variable, the command works
![]()
Below is the complete code:
function Show-mainform2_psf {
Add-Type -AssemblyName System.Windows.Forms
import-module activedirectory
#region Generated Form Objects
[System.Windows.Forms.Application]::EnableVisualStyles()
$form1 = New-Object 'System.Windows.Forms.Form'
$textboxResultado = New-Object 'System.Windows.Forms.TextBox'
$textboxCheckPath = New-Object 'System.Windows.Forms.TextBox'
$textboxCheckGroup = New-Object 'System.Windows.Forms.TextBox'
$buttonCheckOwnerGroup = New-Object 'System.Windows.Forms.Button'
$buttonClickMe = New-Object 'System.Windows.Forms.Button'
$buttonOK = New-Object 'System.Windows.Forms.Button'
$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
#endregion Generated Form Objects
$form1_Load={
}
$buttonClickMe_Click={
$textboxResultado.Lines = (Get-Acl $textboxCheckPath.Lines).Access | ft IdentityReference,FileSystemRights -auto | Out-String
}
$buttonCheckOwnerGroup_Click={
$textboxResultado.Lines = Get-ADGroup -Identity $textboxCheckGroup.Lines -Properties Name,Description,info | select Name,Description,Info | Out-String
}
#region Generated Events
$Form_StateCorrection_Load=
{
#Correct the initial state of the form to prevent the .Net maximized form issue
$form1.WindowState = $InitialFormWindowState
}
$Form_Cleanup_FormClosed=
{
#Remove all event handlers from the controls
try
{
$buttonClickMe.remove_Click($buttonClickMe_Click)
$form1.remove_Load($form1_Load)
$form1.remove_Load($Form_StateCorrection_Load)
$form1.remove_FormClosed($Form_Cleanup_FormClosed)
}
catch { Out-Null <# Prevent PSScriptAnalyzer warning #> }
}
#endregion Generated Events
#region Generated Form Code
# form1
#
$form1.Controls.Add($textboxResultado)
$form1.Controls.Add($textboxCheckPath)
$form1.Controls.Add($textboxCheckGroup)
$form1.Controls.Add($buttonClickMe)
$form1.Controls.Add($buttonCheckOwnerGroup)
$form1.Controls.Add($buttonOK)
$form1.AcceptButton = $buttonOK
$form1.AutoScaleDimensions = '6, 13'
$form1.AutoScaleMode = 'Font'
$form1.ClientSize = '711, 483'
$form1.FormBorderStyle = 'FixedDialog'
$form1.MaximizeBox = $False
$form1.MinimizeBox = $False
$form1.Name = 'Check Folder'
$form1.StartPosition = 'CenterScreen'
$form1.Text = 'Check Folder'
$form1.add_Load($form1_Load)
#
# textboxCheckGroup
#
$textboxCheckGroup.Location = '23, 45'
$textboxCheckGroup.Multiline = $True
$textboxCheckGroup.Name = 'textboxCheckGroup'
$textboxCheckGroup.Size = '300, 20'
$textboxCheckGroup.TabIndex = 4
#
# textboxCheckPath
#
$textboxCheckPath.Location = '23, 15'
$textboxCheckPath.Multiline = $True
$textboxCheckPath.Name = 'textboxCheckPath'
$textboxCheckPath.Size = '300, 20'
$textboxCheckPath.TabIndex = 3
#
# textboxResultado
#
$textboxResultado.Location = '23, 150'
$textboxResultado.Multiline = $True
$textboxResultado.Name = 'textboxResultado'
$textboxResultado.Size = '476, 178'
$textboxResultado.TabIndex = 2
#
# buttonCheckOwnerGroup
#
$buttonCheckOwnerGroup.Location = '330, 44'
$buttonCheckOwnerGroup.Name = 'CheckOwnerGroup'
$buttonCheckOwnerGroup.Size = '120, 23'
$buttonCheckOwnerGroup.TabIndex = 5
$buttonCheckOwnerGroup.Text = 'Check Owner Group'
$buttonCheckOwnerGroup.UseCompatibleTextRendering = $True
$buttonCheckOwnerGroup.UseVisualStyleBackColor = $True
$buttonCheckOwnerGroup.add_Click($buttonCheckOwnerGroup_Click)
#
# buttonClickMe
#
$buttonClickMe.Location = '330, 13'
$buttonClickMe.Name = 'buttonClickMe'
$buttonClickMe.Size = '75, 23'
$buttonClickMe.TabIndex = 1
$buttonClickMe.Text = 'Check Path'
$buttonClickMe.UseCompatibleTextRendering = $True
$buttonClickMe.UseVisualStyleBackColor = $True
$buttonClickMe.add_Click($buttonClickMe_Click)
#
# buttonOK
#
$buttonOK.Anchor = 'Bottom, Right'
$buttonOK.DialogResult = 'OK'
$buttonOK.Location = '624, 448'
$buttonOK.Name = 'buttonOK'
$buttonOK.Size = '75, 23'
$buttonOK.TabIndex = 0
$buttonOK.Text = '&OK'
$buttonOK.UseCompatibleTextRendering = $True
$buttonOK.UseVisualStyleBackColor = $True
$form1.ResumeLayout()
#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($Form_StateCorrection_Load)
#Clean up the control events
$form1.add_FormClosed($Form_Cleanup_FormClosed)
#Show the Form
return $form1.ShowDialog()
}
Show-mainform2_psf