Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Creating Event Logs Exception

Reply
 
Old 02-08-2008   #1 (permalink)
David


 
 

Creating Event Logs Exception

I have created a custom eventlog using powershell using the following script
$eventSourceCreationData = new-object
System.Diagnostics.EventSourceCreationData($source, $logName);
[System.Diagnostics.EventLog]::CreateEventSource($eventSourceCreationData);
Problem arrises when I browse to the registry key for the eventlog and
select permissions. I get the following error "Permissions on "LogName" are
incorrectly ordered, which may cause some entries to be ineffective.

Also if I try to set the permissions from script usng the following script
$location =
'REGISTRY::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\{0}'
-f $logName;
$registryRights =
[System.Security.AccessControl.RegistryRights]::QueryValues -bor
[System.Security.AccessControl.RegistryRights]::EnumerateSubKeys -bor
[System.Security.AccessControl.RegistryRights]::Notify -bor
[System.Security.AccessControl.RegistryRights]::ReadKey;
$inheritanceFlags =
[System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor
[System.Security.AccessControl.InheritanceFlags]::ObjectInherit;
$propagationFlags = [System.Security.AccessControl.PropagationFlags]::None;
$accessControlType = [System.Security.AccessControl.AccessControlType]::Allow;
$registryAccessRule = New-Object
System.Security.AccessControl.RegistryAccessRule(
$identityReference,
$registryRights,
$inheritanceFlags,
$propagationFlags,
$accessControlType);

# Get acl for event log registry key location
$acl = Get-Acl $location

# Create access rule and set in acl
$acl.SetAccessRule($registryAccessRule);

# Apply new acl settings to location
$acl | Set-Acl $location


I get the following exception

Exception calling "SetAccessRule" with "1" argument(s): "This access control
list is not in canonical form and therefore cannot be modified."

Any help or suggestions would be much appreciated.

David


My System SpecsSystem Spec
Old 02-11-2008   #2 (permalink)
Shay Levi


 
 

Re: Creating Event Logs Exception



You can get the exisiting ACL from another log and apply it to yours:

$acl = get-acl HKLM:\SYSTEM\CurrentControlSet\Services\Eventlog\Application
set-acl HKLM:\SYSTEM\CurrentControlSet\Services\Eventlog\LogName -aclobject
$acl


-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> I have created a custom eventlog using powershell using the following
> script $eventSourceCreationData = new-object
> System.Diagnostics.EventSourceCreationData($source, $logName);
> [System.Diagnostics.EventLog]::CreateEventSource($eventSourceCreationD
> ata); Problem arrises when I browse to the registry key for the
> eventlog and select permissions. I get the following error
> "Permissions on "LogName" are incorrectly ordered, which may cause
> some entries to be ineffective.
>
> Also if I try to set the permissions from script usng the following
> script
> $location =
> 'REGISTRY::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventl
> og\{0}'
> -f $logName;
> $registryRights =
> [System.Security.AccessControl.RegistryRights]::QueryValues -bor
> [System.Security.AccessControl.RegistryRights]::EnumerateSubKeys -bor
> [System.Security.AccessControl.RegistryRights]::Notify -bor
> [System.Security.AccessControl.RegistryRights]::ReadKey;
> $inheritanceFlags =
> [System.Security.AccessControl.InheritanceFlags]::ContainerInherit
> -bor
> [System.Security.AccessControl.InheritanceFlags]::ObjectInherit;
> $propagationFlags =
> [System.Security.AccessControl.PropagationFlags]::None;
> $accessControlType =
> [System.Security.AccessControl.AccessControlType]::Allow;
> $registryAccessRule = New-Object
> System.Security.AccessControl.RegistryAccessRule(
> $identityReference,
> $registryRights,
> $inheritanceFlags,
> $propagationFlags,
> $accessControlType);
> # Get acl for event log registry key location
> $acl = Get-Acl $location
> # Create access rule and set in acl
> $acl.SetAccessRule($registryAccessRule);
> # Apply new acl settings to location
> $acl | Set-Acl $location
> I get the following exception
>
> Exception calling "SetAccessRule" with "1" argument(s): "This access
> control list is not in canonical form and therefore cannot be
> modified."
>
> Any help or suggestions would be much appreciated.
>
> David
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
archiving event logs VB Script
Managing Event Logs Software
subject windows Vista Event Logs access through WMI ( Applications and Services Logs) Vista networking & sharing
windows Vista Event Logs access through WMI ( Applications and Services Logs) Vista General
Event logs Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46