[英]How do I get the initial database size in PowerShell SQLPS?
I have been searching for a few days now on how to get the initial size of a database and its logs files via PowerShell SQLPS module.我已经搜索了几天关于如何通过 PowerShell SQLPS 模块获取数据库及其日志文件的初始大小。 For some unknown reason this information is not included in the properties of the returned object from the
Get-SqlDatabase
command.由于某些未知原因,此信息未包含在从
Get-SqlDatabase
命令返回的对象的属性中。
Thanks for the help.谢谢您的帮助。
First of all, the label 'initial size' is a bit unfortunate as it is rather the actual size - see this blog article about it首先,标签“初始大小”有点不幸,因为它是实际大小 - 请参阅有关它的博客文章
That being said, you could try something like this话虽如此,你可以尝试这样的事情
$db = Get-SqlDatabase YourDBName
# Size of files of primary group
$db.FileGroups['Primary'].Files |
Select-Object -Property Name, @{N = 'Size'; E = { $_.Size / 1KB }}
# Size of log files
$db.LogFiles |
Select-Object -Property Name, @{N = 'Size'; E = { $_.Size / 1KB }}
For a test database on my home lab this looked like this对于我家庭实验室的测试数据库,它看起来像这样
PS> $db.FileGroups['Primary'].Files |
Select-Object -Property Name, @{N = 'Size'; E = { $_.Size / 1KB }}
Name Size
---- ----
AXDB 12408
AXDB_2 50
PS> $db.LogFiles |
Select-Object -Property Name, @{N = 'Size'; E = { $_.Size / 1KB }}
Name Size
---- ----
AXDB_log 5448
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.