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. 【HDU 5233】Tree chain problem (树形DP+树剖+线段树|树状数组)最大权不相交树链集

    [题目] Tree chain problem Problem Description Coco has a tree, whose vertices are conveniently labeled ...

  2. 【网络流24题】No. 20 深海机器人问题 (费用流)

    [题意] 深海资源考察探险队的潜艇将到达深海的海底进行科学考察.潜艇内有多个深海机器人. 潜艇到达深海海底后, 深海机器人将离开潜艇向预定目标移动. 深海机器人在移动中还必须沿途采集海底生物标本. 沿 ...

  3. 运行所选代码生成器时出错:无效指针(异常来自HRESULT:0x80004003(E_POINTER))

    这个是在使用了VS2015 update1学MVC的时候,在controllers的方法添加view时报的一个错误,中文基本搜不到解决方法,然后无奈转到成英文,还好G家的搜索提示补全能力拯救了我的渣英 ...

  4. Drainage Ditches(Dinic最大流)

    http://poj.org/problem?id=1273 用Dinic求最大流的模板题,注意会有重边. 邻接矩阵建图 #include<stdio.h> #include<str ...

  5. 【转】eclipse android 设置及修改生成apk的签名文件 -- custom debug keystore

    原文网址:http://hold-on.iteye.com/blog/2064642 android eclipse 设置及修改生成apk的签名文件 1. 问题: 平时在使用eclipse进行andr ...

  6. Java程序员从笨鸟到菜鸟全部博客目录

    本文来自:曹胜欢博客专栏.转载请注明出处:http://blog.csdn.net/csh624366188 大学上了一年半,接触java也一年半了,虽然中间也有其他东西的学习,但是还是以java为主 ...

  7. Bootstrap框架中的字形图标的理解

    最近项目中准备使用 Bootstrap 框架,看中了Ace Admin 这套皮肤,看其代码的时候,发现使用了字形图标.下面内容来源于网络,根据自己对新知识的学习曲线重新整合了一下: 一,字形图标的定义 ...

  8. 在CentOS上为DiscuzX3安装ImageMagick支持。

    找了几篇外文的,写的很好,按照参考安装成功! http://www.tecmint.com/install-imagemagick-in-linux/ ImageMagick is an free o ...

  9. JavaScript高级程序设计39.pdf

    第13章 事件 JavaScript与HTML之间的交互式通过事件来实现的. 事件流 事件流描述的是从页面中接收事件的顺序,IE和Netscape提出了完全相反的事件流概念,IE是事件冒泡流,Nets ...

  10. C随便练练手的题

    判断101-200之间有多少个素数,并输出所有素数 #include <stdio.h> int main(){ ; ; ; ){ while(may<cur){ ){ break; ...