use strict; use Win32::OLE; use Win32::OLE::Enum; use Carp; eval { my $newip = "13.11.11.11,255.255.255.0"; Win32::OLE->Option(Warn => 3); my $secobj = Win32::OLE->GetObject("IIS://ogre/W3svc/1/Root") or croak "Couldn't get object: $!\n"; my $MyIPSec = $secobj->{IPSecurity}; my $ref_IPList = $MyIPSec->{IPGrant}; my @IPList = @{$ref_IPList}; foreach my $i (@IPList) { print "Granted IP: $i\n"; } push(@IPList,$newip); my $ref_newIPList = \@IPList; $MyIPSec->IPGrant = \@IPList or croak "ERROR: Couldn't set variable: $!\n"; # $MyIPSec->SetProperty("IPDeny",$ref_newIPList) or croak "ERROR: Couldn't SetProperty: $!\n"; # $MyIPSec->{IPGrant}->create($newip) or croak "ERROR: Couldn't create new grant: $!\n"; # $obj_grant->($newip) or croak "ERROR: Couldn't create new grant: $!\n"; # $MyIPSec->IPGrant(@IPList) or carp "Couldn't do SetInfo: $!\n"; $MyIPSec->SetProperty("IPGrant",$ref_IPList) or carp "WARNING: Couldn't SetInfo(): ".Win32::OLE->LastError().".\n"; my $secobjnew = Win32::OLE->GetObject("IIS://ogre/W3svc/1/Root") or croak "Couldn't get object: $!\n"; my $MyIPSecnew = $secobjnew->{IPSecurity}; foreach my $newip (@{$MyIPSecnew->{IPGrant}}) { print "IP Granted (new): $newip\n"; } }; print Win32::OLE->LastError()."\n" if (Win32::OLE->LastError());