Список общих ресурсов

Get-WmiObject -Class win32_share -ComputerName localhost | 
Sort-Object name | 
Format-Table name, path, description -AutoSize

Детализированнй список

вариант 1

$class = "WIN32_Share"
$computer = "localhost"
$aryProperty ="type", "name", "allowMaximum", "caption", `
  "description", "maximumAllowed", "Path"
$objWMI = Get-WmiObject -Class $class -computername $computer

foreach($share in $objWMI)
{ 
 Write-Host `
 "
 `nProperty values of Share: $($share.name) 
-------------------------
 "
                
  foreach($property in $aryProperty)
   {
    if($share.$property -notlike "")
     {
      Write-Host $property : $share.$property
	 }
   }
}


вариант 2

Function funLookUp ($intIN) 
{
 switch ($intIN) 
 { 
   0  { $global:strRTN="Disk Drive" }
   1  { $global:strRTN="Print Queue" }
   2  { $global:strRTN="Device" }
   3  { $global:strRTN="IPC " }
   2147483648 { $global:strRTN="Disk Drive Admin" }
   2147483649 { $global:strRTN="Print Queue Admin"}
   2147483650 { $global:strRTN="Device Admin" }
   2147483651 { $global:strRTN="IPC Admin" }
 }
}


$global:strRTN = $null
$class = "WIN32_Share"
$computer = "localhost"
$aryProperty ="type", "name", "allowMaximum", "caption", `
  "description", "maximumAllowed", "Path"
$objWMI = Get-WmiObject -Class $class -computername $computer

foreach($share in $objWMI)
{ 
 Write-Host `
 "
 `nProperty values of Share: $($share.name) 
-------------------------
 "
                
  foreach($property in $aryProperty)
   {
    if($share.$property -notlike "")
     {
      Write-Host $property : $share.$property
	 }
	if($property -eq "type")
	  { 
	   funLookup($share.$property)
	   Write-Host $property "name:" $strRTN
	  }
   }
$Global:strRTN=$null
}

0
Голосов пока нет

Оставить комментарий