如何从 Get-WmiObject 更新 SystemName 或更新数据表
我需要从 Get-WmiObject 覆盖 SystemName:
Function Get-VolumeSpace ([string]$ServerName="localhost") {
$wql="Select SystemName, Name, Capacity, FreeSpace From Win32_Volume Where (DriveType=2 or DriveType=3) and name like '[a-z]%'"
$volSpace=Get-WmiObject -ComputerName $ServerName -Query $wql
$volSpace | Select SystemName, Name, Capacity, FreeSpace}
在 SQL 群集上,SystemName 包含物理节点名称,而不是我传递到 Get-VolumeSpace 的虚拟名称。我需要它是我传入的名称,而不是实际的物理节点名称。
如果我可以从 Get-VolumeSpace 函数中覆盖 SystemName,那就太好了。或者,我可以只更新数据表。因此,我使用在网上找到的 Out-DataTable 函数将输出放入数据表中:
$dataTable = Get-VolumeSpace $ServerName | Out-DataTable
有人可以帮助我在 Get-VolumeSpace 中使用 $ServerName 覆盖 SystemName 或帮助我将每行中的第一列更新为 $ServerName in $数据表?
I need to override SystemName from Get-WmiObject:
Function Get-VolumeSpace ([string]$ServerName="localhost") {
$wql="Select SystemName, Name, Capacity, FreeSpace From Win32_Volume Where (DriveType=2 or DriveType=3) and name like '[a-z]%'"
$volSpace=Get-WmiObject -ComputerName $ServerName -Query $wql
$volSpace | Select SystemName, Name, Capacity, FreeSpace}
On a SQL cluster, SystemName contains the physical node name and not the virtual name that I passed into Get-VolumeSpace. I need it to be the name that I passed in and not the actual physical node name.
If I can override SystemName from within my Get-VolumeSpace function, that would be good. Alternatively, I can just update the data table. So I have put the output into a data table using Out-DataTable function that I found on the web:
$dataTable = Get-VolumeSpace $ServerName | Out-DataTable
Can someone either help me override SystemName with $ServerName in Get-VolumeSpace OR help me update the first column in every row to $ServerName in $dataTable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我明白你在问什么,以下应该有效:
If I understood what you are asking, the following should work: