Grant-Permission.ps1

Download the EXE version of SetACL 3.0.6 for 32-bit and 64-bit Windows. Put setacl.exe at the same location with the script.

function Grant-Permission
{
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[Parameter()]
[string]$ComputerName = $env:computername, [Parameter(Mandatory=$true)]
[string]$Path, [Parameter(Mandatory=$true)]
[ValidateSet('file','reg','srv','prn','shr','wmi')]
[string]$Type, [Parameter(Mandatory=$true)]
[string]$Name, [Parameter(Mandatory=$true)]
[string]$Permission, [Parameter()]
[switch]$PassThru
) Write-Verbose "Granting '$Name' $Permission permission on '$ComputerName'..." if(!(Test-Connection $ComputerName -Count -Quiet))
{
Write-Error "Unable to connect '$ComputerName'. The network path not found."
return
}
try
{
if(!$PSScriptRoot) { $PSScriptRoot = Split-Path (Get-Variable MyInvocation -Scope ).Value.MyCommand.Path }
Set-Alias setacl "$PSScriptRoot\setacl.exe"
if($ComputerName -ne $env:computername) { $fullPath = "\\$ComputerName\$Path" } else { $fullPath = $Path }
$result = Invoke-Expression "setacl -on `"$fullPath`" -ot $Type -actn ace -ace `"n:$Name;p:$Permission`""
if($result -match "error") {
Write-Error ($result -join "`n")
return
}
Write-Verbose ($result -join "`n")
Write-Verbose "'$Name' has been granted $Permission permission on '$ComputerName'." if($Passthru)
{
$pso = New-Object PSObject -Property @{
ComputerName = $ComputerName.ToUpper()
Path = $Path
Type = $Type
Name = $Name
Permission = $Permission
}
$pso.PSTypeNames.Clear()
$pso.PSTypeNames.Add('MKServerBuilder.ACL')
$pso
}
}
catch
{
$_
}
}

Grant-Permission.ps1的更多相关文章

  1. Security3: Schema 和 Permission

    Schema是Object的容器,授予对Schema访问的权限,就是授予对Schema下所有object的访问权限. 一,Schema 是object的container The new schema ...

  2. Using Java SecurityManager to grant/deny access to system functions

    In Java it is possible to restrict access to specific functions like reading/writing files and syste ...

  3. Granting and Managing Item Level Permission using SharePoint2013 Designer Workflow

    https://gnanasivamgunasekaran.wordpress.com/2015/12/29/granting-and-managing-item-level-permission-u ...

  4. Share and NTFS Permission

    NTFS Permissions Share Permissions Share and NTFS Permission Similarities 共享权限和NTFS权限的相似性 Modifying ...

  5. - Permission 运行时权限 总结 翻译 MD

    目录 目录 对运行时权限的一些理解 运行时权限使用案例 开源库:PermissionsDispatcher 注解 使用案例 使用步骤 测试代码 自动生成的类 官方文档:请求权限 Add permiss ...

  6. [转]Code! MVC 5 App with Facebook, Twitter, LinkedIn and Google OAuth2 Sign-on (C#)

    本文转自:https://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-o ...

  7. java安全管理器SecurityManager入门

    table { margin-left: 30px; width: 95%; border: 1px; border-collapse: collapse } img { border: 1px so ...

  8. Hadoop 全分布模式 平台搭建

    现将博客搬家至CSDN,博主改去CSDN玩玩~ 传送门:http://blog.csdn.net/sinat_28177969/article/details/54138163 Ps:主要答疑区在本帖 ...

  9. Security10:授予访问Object的权限

    1,将访问Object的权限授予Database Role 或 User 的语法如下 GRANT <permission> [ ,...n ] ON [ OBJECT :: ][ sche ...

  10. 使用 fixed role 授予权限

    今天下午,Leader 发mail给我,要求授予某个User对数据库只读的权限. Step1,在SQL Server中为该用户创建一个Login和User,在创建User时,建立Login 和 Use ...

随机推荐

  1. Qt浅谈之三十九圆形进度条(已经有50篇了)

    http://blog.csdn.net/taiyang1987912/article/category/2314763

  2. C++小知识之Vector用法

    tyle="margin:20px 0px 0px; font-size:14px; line-height:26px; font-family:Arial; color:rgb(51,51 ...

  3. 开始hadoop

    hadoop介绍 分布式存储系统HDFS(Hadoop Distributed File System),提供了高可靠性.高扩展性和高吞吐率的数据存储服务: 资源管理系统YARN(Yet Anothe ...

  4. SQL Server 2008 R2 制作数据库结构和数据脚本

    数据库中包含众多表和数据,有时候需要创建脚本将表结构和数据一起导出 具体方法如下: 1.右键选择数据库,选择“任务”--->“生成脚本” 2.根据需求,选择制作脚本的对象,一般情况选择“表” 3 ...

  5. ecshop模板修改后还原的原因

    转:http://www.ecmoban.com/article-1693.html 有些刚接触 ecshop的朋友会遇到这样的问题:今天刚修改好的一个地方,等过一段时间后台操作了一会之后发现修改过的 ...

  6. [C#]网络编程系列专题二:HTTP协议详解

    转自:http://www.cnblogs.com/zhili/archive/2012/08/18/2634475.html 我们在用Asp.net技术开发Web应用程序后,当用户在浏览器输入一个网 ...

  7. HDU 5965 扫雷 【模拟】 (2016年中国大学生程序设计竞赛(合肥))

    扫雷 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submissi ...

  8. android学习—— LayoutInflater的使用

    在实际开发种LayoutInflater这个类还是非常有用的,它的作用类似于findViewById(),不同点是LayoutInflater是 用来找layout下xml布局文件,并且实例化!而fi ...

  9. Linux系统下使用crontab添加计划任务的方法

     在服务器中添加定期执行的任务,在很多情况下是非常必要的.比如,每天清理一次/tmp目录下的文件;没几分钟检查某一守护进程是否正常等等.这样计划任务就显得尤为方便.下面将介绍如何在Linux系统中 ...

  10. JavaScript---网络编程(7)-Dom模型(节点间的层次关系,节点的增、删、改)

    利用节点间的层次关系获取节点: 上一节讲了3中获取的方式: * ※※一.绝对获取,获取元素的3种方式:-Element * 1.getElementById(): 通过标签中的id属性值获来取该标签对 ...