-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDBScan.ps1
More file actions
29 lines (26 loc) · 2.22 KB
/
Copy pathDBScan.ps1
File metadata and controls
29 lines (26 loc) · 2.22 KB
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
$svr = new-object ('Microsoft.SqlServer.Management.Smo.Server') 'MOW04DEV014'
$dbfl = @()
$relocateData = @()
foreach ($db in $svr.Databases | Where-Object {$_.Name -eq 'AXTest'})
{
$dbname = $db.Name
foreach ($fg in $db.FileGroups)
{
foreach ($fl in $fg.Files)
{
$dirnm = $fl.FileName | Split-Path -Parent
$filnm = $fl.FileName | Split-Path -Leaf
$dfl = $fl | select @{Name="DBName"; Expression={$dbname}}, Name, @{Name="Directory"; Expression={$dirnm}}, @{Name="FileName"; Expression={$filnm}}, Size, UsedSpace
$dbfl += $dfl
$relocateData += New-Object Microsoft.SqlServer.Management.Smo.RelocateFile($fl.Name, $fl.FileName)
}
}
foreach ($fl in $db.LogFiles)
{
$dirnm = $fl.FileName | Split-Path -Parent
$filnm = $fl.FileName | Split-Path -Leaf
$dfl = $fl | select @{Name="DBName"; Expression={$dbname}}, Name, @{Name="Directory"; Expression={$dirnm}}, @{Name="FileName"; Expression={$filnm}}, Size, UsedSpace
$dbfl += $dfl
}
}
$dbfl | Format-Table -AutoSize