Sunday, February 16, 2020

sample script for Access

<# This tool has been desgined by Swagat Rout
For More pls Contact: Swagatkumar.rout@outlook.com
.NAME
Untitled
#>

Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()

$Delegation = New-Object system.Windows.Forms.Form
$Delegation.ClientSize = '523,348'
$Delegation.text = "ACCESS Management"
$Delegation.BackColor = "#f8d41c"
$Delegation.TopMost = $false

$URL = New-Object system.Windows.Forms.Label
$URL.text = "URL"
$URL.AutoSize = $true
$URL.width = 25
$URL.height = 10
$URL.location = New-Object System.Drawing.Point(27,21)
$URL.Font = 'Microsoft Sans Serif,14,style=Bold'

$NetworkPath = New-Object system.Windows.Forms.TextBox
$NetworkPath.multiline = $false
$NetworkPath.width = 329
$NetworkPath.height = 20
$NetworkPath.location = New-Object System.Drawing.Point(108,15)
$NetworkPath.Font = 'Microsoft Sans Serif,10'

$ACL = New-Object system.Windows.Forms.Button
$ACL.BackColor = "#7ed321"
$ACL.text = "ACL"
$ACL.width = 60
$ACL.height = 30
$ACL.Anchor = 'top,bottom,left'
$ACL.location = New-Object System.Drawing.Point(25,69)
$ACL.Font = 'Microsoft Sans Serif,11,style=Bold'

$result = New-Object system.Windows.Forms.TextBox
$result.multiline = $true
$result.width = 294
$result.height = 159
$result.location = New-Object System.Drawing.Point(136,70)
$result.Font = 'Microsoft Sans Serif,10'

#$result = New-Object system.Windows.Forms.ListBox
#$result.text = "listbox"
#$result.width = 294
#$result.height = 159
#$result.location = New-Object System.Drawing.Point(136,70)

$CloseButton = New-Object system.Windows.Forms.Button
$CloseButton.BackColor = "#21d371"
$CloseButton.text = "close"
$CloseButton.width = 56
$CloseButton.height = 21.20001220703125
$CloseButton.Anchor = 'bottom,left'
$CloseButton.location = New-Object System.Drawing.Point(356,270)
$CloseButton.Font = 'Microsoft Sans Serif,10,style=Bold'
$CloseButton.ForeColor = "#000000"

$Delegation.controls.AddRange(@($URL,$NetworkPath,$ACL,$result,$CloseButton))

$ACL.Add_Click({ Acl })
$closeButton.Add_Click({ closeForm })

Function Acl()
{
$result.Text += "`r`n" + "fetching information for" +$NetworkPath.Text
$val=Get-Acl $NetworkPath.Text #| select Access -ExpandProperty Access | select IdentityReference,FileSystemRights |ogv
#Validation and result part
if($val -ne $null)
{
Get-Acl $NetworkPath.Text | select Access -ExpandProperty Access | select IdentityReference,FileSystemRights |ogv
}
else
{
$result.Text += "`r`n" + "path does not exist, Try again with correct path"
}
# $result.Text = $rights.filesystemrights,$rights.identityreference
}


function closeForm(){$Delegation.close()}

#Write your logic code here

[void]$Delegation.ShowDialog()

No comments:

Test Script

############################################################################## #####################################################...