Grant-Permission.ps1
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的更多相关文章
- Security3: Schema 和 Permission
Schema是Object的容器,授予对Schema访问的权限,就是授予对Schema下所有object的访问权限. 一,Schema 是object的container The new schema ...
- 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 ...
- Granting and Managing Item Level Permission using SharePoint2013 Designer Workflow
https://gnanasivamgunasekaran.wordpress.com/2015/12/29/granting-and-managing-item-level-permission-u ...
- Share and NTFS Permission
NTFS Permissions Share Permissions Share and NTFS Permission Similarities 共享权限和NTFS权限的相似性 Modifying ...
- - Permission 运行时权限 总结 翻译 MD
目录 目录 对运行时权限的一些理解 运行时权限使用案例 开源库:PermissionsDispatcher 注解 使用案例 使用步骤 测试代码 自动生成的类 官方文档:请求权限 Add permiss ...
- [转]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 ...
- java安全管理器SecurityManager入门
table { margin-left: 30px; width: 95%; border: 1px; border-collapse: collapse } img { border: 1px so ...
- Hadoop 全分布模式 平台搭建
现将博客搬家至CSDN,博主改去CSDN玩玩~ 传送门:http://blog.csdn.net/sinat_28177969/article/details/54138163 Ps:主要答疑区在本帖 ...
- Security10:授予访问Object的权限
1,将访问Object的权限授予Database Role 或 User 的语法如下 GRANT <permission> [ ,...n ] ON [ OBJECT :: ][ sche ...
- 使用 fixed role 授予权限
今天下午,Leader 发mail给我,要求授予某个User对数据库只读的权限. Step1,在SQL Server中为该用户创建一个Login和User,在创建User时,建立Login 和 Use ...
随机推荐
- 【HDU 3483】 A Very Simple Problem (二项式展开+矩阵加速)
A Very Simple Problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- iOS开发UI篇—UITableviewcell的性能问题
iOS开发UI篇—UITableviewcell的性能问题 一.UITableviewcell的一些介绍 UITableView的每一行都是一个UITableViewCell,通过dataSource ...
- TF卡的Class4/Class6/Class10
TF卡全称TransFlash卡,即T-Flash又称MicroSD,随设备微型化的需要,TF卡用途越来越广,速度也越来越快,从最初的Class2早已发展到目前主流的Class10,TF卡体积为15m ...
- 猜测:信号槽的本质是使用Windows的自定义消息来实现的
在不断执行: void MyTool::DeleteAllFiles(){ for (i = 0; i <= n - 1; i++) { // do something }}在for循环没有执行 ...
- Linux 下报错:A Java RunTime Environment (JRE) or Java Development Kit (JDK) must解决方案
一.报错环境:在Linux mint下,前几天还用得很好的的eclipse,今天开机不知为什么这样. Linux 下报错:A Java RunTime Environment (JRE) or Jav ...
- 动态规划(计数DP):HDU 5136 Yue Fei's Battle
Yue Fei's Battle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Other ...
- AppFabric 版本区分
目前CSDN上可以下载到的 AppFabric有两个版本: 1, WindowsServerAppFabricSetup_x64_6.1.exe, 2010/12/3 发布的, 不推荐使用,Wi ...
- selenium webdriver 环境搭建--java
selenium java环境的安装可以分为三个部分:jdk.eclipse和selenium. jdk jdk(java development kit)是sun公司针对java开发人员的产品,是整 ...
- NodeAsp——像开发NodeJS应用一样玩转ASP
NodeAsp是一套Classic ASP框架,借鉴了NodeJS的模块化思想,让您可以使用全新的理念愉快地书写ASP程序. NodeAsp使用遵循CommonJS规范的require,完全兼容Nod ...
- apache的FileUtils方法大全
FileUtils 获取系统的临时目录路径:getTempDirectoryPath() [java] view plaincopyprint? public static String getTem ...