Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell将列值存储到字符串中_Powershell_Split_Exchange Server - Fatal编程技术网

Powershell将列值存储到字符串中

Powershell将列值存储到字符串中,powershell,split,exchange-server,Powershell,Split,Exchange Server,我想将列值放入数组中。由于“Microsoft.PowerShell.Commands.Internal.Format.FormatteryData”的格式表管道,当前无法执行此操作 $mailboxnames = get-mailboxdatabase | ft Name $splits=@() foreach($names in $mailboxnames){ $splits += $names.split('-') } $splits 您不必使用格式表 $mailboxDBs =

我想将列值放入数组中。由于“Microsoft.PowerShell.Commands.Internal.Format.FormatteryData”的格式表管道,当前无法执行此操作

$mailboxnames = get-mailboxdatabase | ft Name

$splits=@()
foreach($names in $mailboxnames){
  $splits += $names.split('-')
}
$splits

您不必使用格式表

$mailboxDBs = get-mailboxdatabase
foreach ($mailboxDB in $mailboxDBs)
{
 $mailboxDB.name
}

Mailbox Database 1558034411
archiveMail
别忘了你在.NET平台上玩的Powershell中的一切都是对象

所以你有两个freinds: 1.gettype()方法,该方法提供对象的类型 2.Get-Member CmdLet可帮助您了解对象的属性和方法

Get成员有许多参数可以提供帮助,但请尝试:

$mailboxDBs | Get-Member
或使用管道:

$db = Get-MailboxDatabase | Foreach-Object {$_.Name}

我一直认为它就像其他语言一样,只需要获取列表并放入数组。非常感谢。