Conor Lillis <> wrote:
> Hi all,
> I am hoping for some assistance in trying to enumerate Exchange 2003
> public folder replication partners using Perl and WMI. I can
> enumerate all information I am trying to retrieve except the
> ReplicaList property, and can see that the query returns data, but
> when I try to enumerate it I get no usable output.
> I have included my snippet below, and the output below that.
>
> foreach my $host(sort @hosts)
> {
> chomp($host);
> print "\n".gmtime()."\tRetrieving Public folder sizes on
$host\n";
> my $OLECon =
>
Win32::OLE->GetObject("winmgmts:\\\\$host\\root\\MicrosoftExchangeV2")||
> die "Cannot access WMI on remote machine: $host",Win32::OLE-LastError;
> my $PublicFolders = $OLECon->ExecQuery("Select * From
> Exchange_PublicFolder") or die "WMI Query Failed!\n";
> foreach my $PublicFolder(in $PublicFolders)
> {
> $PF1=$PublicFolder->AddressBookName;
> $PF2=$PublicFolder->TotalMessageSize/1024;
> $PF3=$PublicFolder->MessageCount;
> $PF4=$PublicFolder->Path;
> my $ReplicaList = $PublicFolder->ReplicaList;
> my $ReplicaList = $PublicFolder->ReplicaList;
> print "Replica Array = $ReplicaList\n"; # Treat as
> text
> foreach my $replica(@ReplicaList ) {print "Replica
> $replica\n";} # Treat as array
> foreach my $key(sort keys %ReplicaList) {print "Key is
> $key\tValue is $ReplicaList{$key}\n";} # Treat as hash
> }
> }
> exit;
>
>
> Thu Jul 22 12:53:01 2010 Retrieving Public folder sizes on
> [Exchange server]
> Thu Jul 22 12:59:07 2010 Working on pub folder [public folder]
> Replica Array = ARRAY(0x9ead7d4)
That is telling you that you have a reference to an array, so you need
to dereference it. Try the following:
foreach my $replica(@$ReplicaList ) {
# ^
print "Replica $replica\n";
}
See 'perldoc -f perlreftut' and 'perldoc perlref'.
Also, your code suggests that you may not have 'use strict;' at the
start of your script, at least the code you supply would not compile if
it was there. It's a good idea to always to have that, and 'use
warnings;' at the start of every script.
HTH
--
Brian Raven
Please consider the environment before printing this e-mail.
This e-mail may contain confidential and/or privileged information. If you are
not the intended recipient or have received this e-mail in error, please advise
the sender immediately by reply e-mail and delete this message and any
attachments without retaining a copy.
Any unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs