我尝试在Get-Service
输出中添加新列。我发现到目前为止的解决方案,添加列,但不可能添加多个值。我将输出保存在数组中,例如:
$b = @()
$b += Get-Service wuauserv
您知道吗,我如何更改正常的输出:
Status Name DisplayName
- - - - - - - -- - - - -- - - - -
Running wuauserv Windows Update
Running sysmain Superfetch
这样的事情:
Status Name DisplayName ComputerName
- - - - - - - - - - - - - - - - - - - - - -- - - - - - -
Running wuauserv Windows Update Server1
Running sysmain Superfetch Server5
希望,任何人都可以帮助我:)
答案 0 :(得分:0)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CQViewer.Hierarchy;
namespace CQViewer.ViewModels
{
class HierarchyViewModel : ViewModelBase
{
#region Fields
#endregion
#region Construction/Deconstruction/Initialisation
/// <summary>
/// Constructor
/// </summary>
public HierarchyViewModel ()
{
Nodes = new HierarchyNode ("Test1");
HierarchyNode Node2 = new HierarchyNode ("TestX");
Node2.ChildNodes.Add (new HierarchyNode ("TestY"));
Nodes.ChildNodes.Add (Node2);
Nodes.ChildNodes.Add (new HierarchyNode ("Test3"));
}
#endregion
#region Properties
public HierarchyNode Nodes { get; set; }
#endregion
#region Public Access Interface
/// <summary>
/// Creates/Recreates the hierarchy
/// </summary>
public void InitializeHierarchy ()
{
// TODO Clear the tree view
}
/// <summary>
/// Gets the folder currently selected in the tree view hierarchy
/// </summary>
public string GetCurrentlySelected ()
{
return "$/";
}
#endregion
#region Private Functions
#endregion
}
}
不属于Get-Service cmdlet返回的ComputerName
对象的一部分。因此,您必须在select语句中使用表达式并获取计算机名称(例如,使用System.ServiceProcess.ServiceController
):
$env:computername
修改强>
啊,你可以使用Get-Service wuauserv | select Status, Name, DisplayName, @{l="ComputerName";e={$env:COMPUTERNAME}}
属性(感谢Darklite1)。因此,如果要重命名列,可以使用:
MachineName
答案 1 :(得分:0)
也许这可以帮到你:
$("body").on("click","#fluid-overlay",function() {
//code goes here
});
如果您运行以下命令:
$b = @()
$b += Get-Service -ComputerName SERVER1-Name wuauserv
$b += Get-Service -ComputerName SERVER2 -Name sysmain
$b | Select-Object Status, Name, DisplayName, MachineName
它会告诉您$b | Get-Member
名为Property
。您可以使用MachineName
CmdLet查看输出中的Select-Object
。