环境: 服务器:启用了远程PowerShell的Windows Server 2012 R2。 工作站:Windows 8.1中通过远程PowerShell在函数中写入事件日志
所以我创建了一个PowerShell模块调用MyModule.psm1具有以下功能:
Function CreateEvent() {
Write-EventLog –LogName ToolLog –Source “Schedule” –EntryType Information –EventID 13 –Message “There were users written to the database.”
}
我创建了一个PSSessionConfigurationFile,然后用EVENTLOGGING的配置名称注册它,这样我可以通过以下远程PowerShell:
$Creds = Get-Credential
$SessionOpts = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$Session = New-PSSession -ComputerName Server.Domain.Com -ConfigurationName EventLogging -Credential $Creds -UseSSL -SessionOption $SessionOpts
Import-PSSession $Session
现在,当我输入本地管理员凭据到获取-凭据,我可以运行功能CreateEvent,一切工作就好了。但是,如果我输入Standard Local Users凭据,则会出现以下错误:无法打开源“Schedule”的日志“ToolLog”的注册表项。
我更换了写事件日志的功能的:
$EventLog = new-object System.Diagnostics.EventLog("ToolLog");
$EventLog.MachineName = ".";
$EventLog.Source = "Schedule";
$EventLog.WriteEntry("There were users written to the database.", "Information", 15);
我收到的错误:异常调用“WriteEntry”和“3”的说法(S):“无法打开日志源'附表',你可能没有写权限。“
如果我在本地登录服务器并导入模块并尝试运行该函数,我会得到相同的确切错误。我也不能自己运行Write-EventLog的cmdlet。
从我在互联网上找到的所有信息中,我已给我的本地非管理员用户写入事件日志的权限。通过RegEdit和通过实际的事件日志文件上的NTFS。
任何想法?
感谢, 布赖恩
嗨,布赖恩,你有没有得到任何与此? – 2015-04-23 20:46:24