環境: 服務器:啓用了遠程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