In deze blog http://mow001.blogspot.co...-shares-and-security.html
staat een script om met PowerShell een export te maken van Windows share informatie via WMI.
Ik kom er maar niet achter waarom het script niet werkt (getest op Vista en Server 2003)
foutmelding:
Method invocation failed because [System.Management.ManagementObject#root\cimv2\Win32_LogicalShareSecuritySetting] doesn't contain a method named 'invokeMethod'.
At C:\Install\ExportShares.ps1:20 char:33
+ $sd = $shareSec.invokeMethod( <<<< 'GetSecurityDescriptor',$null,$null)
staat een script om met PowerShell een export te maken van Windows share informatie via WMI.
Ik kom er maar niet achter waarom het script niet werkt (getest op Vista en Server 2003)
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| # ExportShares.ps1 # This script will export the existing Shares # complete with securityInfo # # /\/\o\/\/ 2006 # http://mow001.blogspot.com $filename = 'ShareInfo.csv' # get Shares (Type o is "Normal" shares) $shares = gwmi Win32_Share -filter 'type=0' # combine Shares with Security info $Shareinfo = @() foreach ($share in $shares) { $shareSec = gwmi Win32_LogicalShareSecuritySetting -filter "name='$($share.name)'" if($shareSec) { $sd = $shareSec.invokeMethod('GetSecurityDescriptor',$null,$null) $ShareInfo += $sd.Descriptor.DACL |% { $_ | select @{e={$share.name};n='Name'}, @{e={$share.Path};n='Path'}, @{e={$share.Description};n='Description'}, AccessMask, AceFlags, AceType, @{e={$_.trustee.Name};n='User'}, @{e={$_.trustee.Domain};n='Domain'}, @{e={$_.trustee.SIDString};n='SID'} } }Else{ $ShareInfo += $share | select Name,Path,Description } } # Export them to CSV $ShareInfo | select Name,Path,Description,User,Domain,SID, AccessMask,AceFlags,AceType | export-csv -noType $filename |
foutmelding:
Method invocation failed because [System.Management.ManagementObject#root\cimv2\Win32_LogicalShareSecuritySetting] doesn't contain a method named 'invokeMethod'.
At C:\Install\ExportShares.ps1:20 char:33
+ $sd = $shareSec.invokeMethod( <<<< 'GetSecurityDescriptor',$null,$null)
|=|=|=||=|=|=||=|=|=| http://www.vanwijck.com |=|=|=||=|=|=||=|=|=||=|=|=||=|=|=||=|=|=||=|=|=|