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. PYTHON--CLASS

    class Robot: population = 0 def __init__(self, name): self.name = name print("(Initializing {0} ...

  2. [转贴]xcode帮助文档

    突然间得到了一台MAC ,这时候不学OC 更待何时学呀?马上找了IOS开发的书和网上的帖子看,最近在开源力量那里看了TINYFOOL的入门讲座,讲的都很虚,可能时间不够吧,也没看到什么例子呀,什么的, ...

  3. C++静态变量对象的建立和删除,兼论MFC开始运行的起点(全局对象)

    看了不少C++书,当讲到静态变量的时候,总是以int成员来举例,是啊,这样很好理解.但是如果这个静态变量是一个对象行不行呢?不仅行,有时候还非常必要,而且别有洞天. 比如: // .h 文件 clas ...

  4. leetcode面试准备: Substring with Concatenation of All Words

    leetcode面试准备: Substring with Concatenation of All Words 1 题目 You are given a string, s, and a list o ...

  5. PAIP.提升效率----论项目知识库的建设。。

    PAIP.提升效率----论项目知识库的建设.. 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn.net ...

  6. 【HDOJ】4553 约会安排

    线段树.线段树的细节很重要,小数据遍历可以发现问题. /* 4553 */ #include <iostream> #include <string> #include < ...

  7. 微软开放技术发布针对 Mac 和 Linux 的更新版 Azure Node.JS SDK 和命令行工具

    发布于 2013-12-04 作者 Eduard Koller 这次为我们使用Linux 的朋友带来了更多关于部署云上虚拟机的消息.今天,微软开放技术有限公司 (MS Open Tech),想与大家分 ...

  8. Unity3D常见技术点(持续更新)

    一:获取对象, 添加对象等 1:使用prefab生成对象 GameObject ballObj = GameObject.Instantiate(Resources.Load(, Quaternion ...

  9. WPF开源UI框架推荐 Modern UI

    稍后追加,详细教程 http://mui.codeplex.com/

  10. [LeetCode] 74. Search a 2D Matrix 解题思路

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...