powershell共享服务器写文件,PowerShell脚本或者CMD命令导出共享权限

您好,

乱码的话可以改文件编码,不需要的属性可以直接去掉,但权限的显示是没有办法改变顺序的。

二级目录

$path = "\\192.168.135.130\test\"

$result = "C:\temp\level2result.csv"

[console]::InputEncoding = [System.Text.Encoding]::UTF8

[console]::OutputEncoding = [System.Text.Encoding]::UTF8

if(Test-Path -Path $result){ Remove-Item -Path $result}

$dirs = Get-ChildItem $path -Directory

foreach($dir in $dirs){

(Get-Acl -Path $dir.fullname).Access | ForEach-Object{

$_ | Select-Object @{n="Folder";e={$dir.fullname}},IdentityReference,FileSystemRights,IsInherited

} | Export-Csv -Path $result -NoTypeInformation -Append -Encoding UTF8

}

Import-Csv -Path $result -Encoding UTF8 | Format-Table

三级目录

$path = "\\192.168.135.130\test\"

$result = "C:\temp\level3result.csv"

[console]::InputEncoding = [System.Text.Encoding]::UTF8

[console]::OutputEncoding = [System.Text.Encoding]::UTF8

if(Test-Path -Path $result){ Remove-Item -Path $result}

$dirs = Get-ChildItem $path -Directory | Get-ChildItem -Directory

foreach($dir in $dirs){

(Get-Acl -Path $dir.fullname).Access | ForEach-Object{

$_ | Select-Object @{n="Folder";e={$dir.fullname}},IdentityReference,FileSystemRights,IsInherited

} | Export-Csv -Path $result -NoTypeInformation -Append -Encoding UTF8

}

Import-Csv -Path $result -Encoding UTF8 | Format-Table

二级和三级目录

$path = "\\192.168.135.130\test\"

$result = "C:\temp\level23result.csv"

[console]::InputEncoding = [System.Text.Encoding]::UTF8

[console]::OutputEncoding = [System.Text.Encoding]::UTF8

if(Test-Path -Path $result){ Remove-Item -Path $result}

$dirs = Get-ChildItem $path -Directory -Depth 1

foreach($dir in $dirs){

(Get-Acl -Path $dir.fullname).Access | ForEach-Object{

$_ | Select-Object @{n="Folder";e={$dir.fullname}},IdentityReference,FileSystemRights,IsInherited

} | Export-Csv -Path $result -NoTypeInformation -Append -Encoding UTF8

}

Import-Csv -Path $result -Encoding UTF8 | Format-Table

如您还有其他疑问,请随时与我们联系。如果回答是有帮助的,请将其标记为答案,可以帮助其他有相同问题的社区成员快速找到有用的答复

祝好

Ian Xue

Please remember to mark the replies as answers if they help.

If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值