Powershell将列值存储到字符串中
我想将列值放入数组中。由于“Microsoft.PowerShell.Commands.Internal.Format.FormatteryData”的格式表管道,当前无法执行此操作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 =
$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}
我一直认为它就像其他语言一样,只需要获取列表并放入数组。非常感谢。