Simple form help

Testing out Poweshell Universal latest version and created a simple form. I want to take a UNC path (\servername\myshare) input from user and get back the access rights with the NTFSSecurity module. I am able to get the input from the form into $value but can’t get the command Get-NtfsAccess $value to display. My code below. Thanks for any help, I know I must be missing something simple.

New-UDForm -Content {
New-UDTextbox -Id ‘txtPath’ -Label ‘Path’
} -OnSubmit {
$Value = (Get-UDElement -Id ‘txtPath’).value
Get-NTFSAccess $Value
Show-UDToast -Message $value
}

Hey @phunky1!

Welcome to the forums.

You can do this:

    New-UDForm -Content {
        New-UDTextbox -Id ‘txtPath’ -Label ‘Path’
    } -OnSubmit {
        Show-UDToast -Message $EventData.txtPath
    }

If you want to return the result of the Get-NTFSAccess command, do something like:

    New-UDForm -Content {
        New-UDTextbox -Id ‘txtPath’ -Label ‘Path’
    } -OnSubmit {
        Show-UDToast -Message (Get-NTFSAccess $EventData.txtPath)
    }

Thanks, cool stuff! So I tried that and it didn’t display anything. I found this for a v2 on the forums that worked, using Get-ACL, but wanted to use v3 code if possible.

New-UDHtml -Markup "
Security Permission Check
"

New-UDInput -Title “Please Enter Server and Folder Name” -Endpoint {

    param(

    [Parameter(Mandatory=$true)]

    [string]$folder 

    )  

New-UDInputAction -Content {

New-UDElement -Tag 'div'  -Content {

New-UDTable -Title 'Results'  -Headers  @('Path', 'Owner' , 'Access') -Endpoint {

        Invoke-Command -ScriptBlock { Get-acl -Path $folder| Select-Object `

        @{name = 'Path'; expression = {Convert-Path $_.Path }},

        @{name = 'Owner'; expression = { $_.Owner }},

        @{name = 'Access'; expression = { $_.AccessToString } }   | Out-UDTableData -Property @('Path' , 'Owner', 'Access')

        }

        }

        

        New-UDHtml -Markup '<button class="btn ud-button" type="button" onClick="window.location.reload();">Reset Page</button>'

}#close ud-element 

}#close input action

}#close input

Here’s a v3 version.

    New-UDForm -Content {
        New-UDTextbox -Id 'txtFolder' -Placeholder Folder
    } -OnSubmit {
        $Data = Get-acl -Path $EventData.txtFolder | Select-Object `
                @{name = 'Path'; expression = {Convert-Path $_.Path }},
                @{name = 'Owner'; expression = { $_.Owner }},
                @{name = 'Access'; expression = { $_.AccessToString }}

        New-UDTable -Data $Data
    }

Thanks again, that worked! Appreciate the fast responses.

Now I am trying to get this working with the NTFSSecurity module. Almost have it but for some reason the $_.accessrights display numbers instead of the access rights.

New-UDForm -Content {
    New-UDTextbox -Id 'txtFolder' -Placeholder Folder

} -OnSubmit {

    $Data = Get-NTFSAccess -Path $EventData.txtFolder | Select-Object `

            @{name = 'Account'; expression = { $_.Account.accountname }},

            @{name = 'Access Rights'; expression = { $_.Accessrights }}

    New-UDTable -Data $Data

}
|Account|Access Rights| | --- | --- | |Everyone|1179817| |CREATOR OWNER|2032127| |CREATOR GROUP|2032127| ||2032127| ||2032127|

It looks like access rights is an enum. Trying casting it to a string. It’s probably serializing to an integer currently.

New-UDForm -Content {
    New-UDTextbox -Id 'txtFolder' -Placeholder Folder

} -OnSubmit {

    $Data = Get-NTFSAccess -Path $EventData.txtFolder | Select-Object `

            @{name = 'Account'; expression = { $_.Account.accountname }},

            @{name = 'Access Rights'; expression = { $_.Accessrights.ToString() }}

    New-UDTable -Data $Data

}

Perfect! Thanks once again.

One more question, can you extend the input box so that it can display the full path or at least as wide as the screen will accept? The code from v2 above did this. Now it only displays about 40 characters.

Thanks!