rtf*_*rtf 5 security windows powershell network-share
我正在尝试编写一个脚本来审核几个 HIPAA 敏感服务器上的共享文件夹。我使用 获得了一个很好的共享列表gwmi Win32_Share,但是当我使用获取每个共享的权限时gwmi Win32_LogicalShareSecuritySetting,隐藏的管理共享没有列出。
我意识到这是出于显而易见的原因,这不像权限更改,但我想要某种迹象表明这实际上是管理共享。目前我正在使用 try-catch 块来处理错误并踢出“找不到权限”消息。
有什么方法可以使用 PowerShell 仅列出隐藏的管理共享?
尝试(将“.”更改为您的远程计算机名称):
[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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4166 次 |
| 最近记录: |