こんにちは。
Windows Server 2012 R2であれば共有フォルダの列挙はGet-SmbShare
コマンドレットで可能です。
例)
powershell
1# -Special:$falseで管理共有(C$など)を除外
2Get-SmbShare -Special:$false
ただ、このコマンドレットでフォルダサイズは取得できず、PowerShell全般の問題としてフォルダのサイズ取得は一筋縄ではいきません...
基本的にはこちらのブログにある様に関数を自作してやる必要があります。
とりあえずの解として、上記の点を組み合わせて以下の様な感じで処理を実行することは可能です。
(フォルダサイズが大きいと時間がかかります)
powershell
1# この関数は
2# http://tech.guitarrapc.com/entry/2013/09/26/071905
3# より引用しています
4function Get-DirectoryVolume
5{
6
7 [CmdletBinding()]
8 param
9 (
10 [parameter(
11 position = 0,
12 mandatory = 1,
13 valuefrompipeline = 1,
14 valuefrompipelinebypropertyname = 1)]
15 [string[]]
16 $Path = $null,
17
18 [parameter(
19 position = 1,
20 mandatory = 0,
21 valuefrompipelinebypropertyname = 1)]
22 [validateSet("KB", "MB", "GB")]
23 [string]
24 $Scale = "KB",
25
26 [parameter(
27 position = 2,
28 mandatory = 0,
29 valuefrompipelinebypropertyname = 1)]
30 [switch]
31 $Recurse = $false,
32
33 [parameter(
34 position = 3,
35 mandatory = 0,
36 valuefrompipelinebypropertyname = 1)]
37 [switch]
38 $Ascending = $false,
39
40 [parameter(
41 position = 4,
42 mandatory = 0,
43 valuefrompipelinebypropertyname = 1)]
44 [switch]
45 $OmitZero
46 )
47
48 process
49 {
50 $path `
51 | %{
52 Write-Verbose ("Checking path : {0}. Scale : {1}. Recurse switch : {2}. Decending : {3}" -f $_, $Scale, $Recurse, !$Ascending)
53 if (Test-Path $_)
54 {
55 $result = Get-ChildItem -Path $_ -Recurse:$Recurse `
56 | where PSIsContainer `
57 | %{
58 $subFolderItems = (Get-ChildItem $_.FullName | where Length | measure Length -sum)
59 [PSCustomObject]@{
60 Fullname = $_.FullName
61 $scale = [decimal]("{0:N4}" -f ($subFolderItems.sum / "1{0}" -f $scale))
62 }} `
63 | sort $scale -Descending:(!$Ascending)
64
65 if ($OmitZero)
66 {
67 return $result | where $Scale -ne ([decimal]("{0:N4}" -f "0.0000"))
68 }
69 else
70 {
71 return $result
72 }
73 }
74 }
75 }
76}
77
78# 管理共有を除いた共有フォルダの列挙
79Get-SmbShare -Special:$false | ForEach-Object {
80 # フォルダサイズの取得は気合いで頑張るしかない
81 $folderSize = Get-DirectoryVolume -Path $_.Path -Recurse -Scale MB | Measure-Object -Sum MB | Select-Object -ExpandProperty Sum
82 # 結果を出力
83 Write-Output ("{0}({1}) : {2}MB" -f $_.Name, $_.Path, $folderSize)
84}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/22 04:56 編集
2018/02/22 05:40
2018/02/23 02:49
2018/02/23 03:50
2018/02/26 01:49
2018/02/26 02:25
2018/02/26 02:30
2018/02/26 02:34