我正在尝试编写一个脚本来审核一些对HIPAA敏感的服务器上的共享文件夹.我正在使用gwmi Win32_Share获得一份股票列表,但是当我使用gwmi Win32_LogicalShareSecuritySetting获取每个共享的权限时,隐藏的管理共享未列出.
我意识到这是因为显而易见的原因,它不像权限更改,但我想要某种迹象表明这实际上是一个管理共享.目前我正在使用try-catch块来处理错误并踢出“无法找到权限”消息.
有什么办法可以使用PowerShell列出隐藏的管理共享吗?
尝试(将“.”更改为您的远程计算机名称):
原文链接:https://www.f2er.com/windows/368197.html[String] $Local:strComputerName = "."; [System.Management.ManagementBaSEObject[]] $Local:arrShares = @(); [System.Management.ManagementBaSEObject] $Local:objShare = $null; $arrShares = Get-WMIObject -class "Win32_Share" -namespace "root\CIMV2" -computername $strComputerName -ErrorAction SilentlyContinue | Where-Object { $_.Type -eq 2147483648 }; if ( $? ) { foreach ( $objShare in $arrShares ) { # List attributes (other attributes include AccessMask,AllowMaximum,Description,# InstallDate,MaximumAllowed,Status and Type). Write-Host -Object ( "Name : {0}" -f $objShare.Name ); Write-Host -Object ( "Path : {0}" -f $objShare.Path ); Write-Host -Object ( "Caption : {0}" -f $objShare.Caption ); Write-Host -Object ""; } #foreach } else { Write-Host -Object "ERROR."; } #else-if