.NET Framework - get-eventlog on Remote computer with PS v2

Asked By Littl
20-Feb-09 04:58 PM
I get an error when using the -computername parameter?

PS H:\> get-eventlog -computername ap-tstdba-t01 -logname System
Get-EventLog : A parameter cannot be found that matches parameter name
'computername'.
At line:1 char:27
+ get-eventlog -computername <<<<  ap-tstdba-t01 -logname System

Any ideas what I am doing wrong?
ErrorVariable
(1)
OutVariable
(1)
OutBuffer
(1)
ErrorVar
(1)
RichS
(1)
SelectParametersets
(1)
Siddaway
(1)
Windows
(1)
  Vadims Podans replied...
20-Feb-09 05:16 PM
are you sure that you are running command in PowerShell V2? Looks like
your're running PowerShell 1.0
--
WBR, Vadims Podans
PowerShell blog - www.sysadmins.lv
  RichSMV replied...
21-Feb-09 06:31 AM
check that a computername parameter exists in your version

get-command get-eventlog |  select parametersets | fl

should show you the parameters

can also try using $psversiontable  - if you don't get anything then ist not
version 2

--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk
  Marco Shaw [MVP] replied...
21-Feb-09 08:13 AM
As Richard indicates, you can check the parameter sets, which is a more
exact way to get the listing of supported parameters.

This is appears to be a documentation error, and -computerName is
actually not supported.

Marco
  RichSMV replied...
21-Feb-09 11:36 AM
The computername parameter is definitely present in CTP3

Get-EventLog -ComputerName home05 -LogName system

works for me
--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk
  Josh Einstein replied...
21-Feb-09 06:48 PM
Also, make sure that you haven't installed a Snapin or module that has
overridden the Get-EventLog command.

C:\Users\Josh Einstein> Get-Command Get-EventLog | Select DLL

DLL
---
C:\Windows\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Management\1.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Management.dll
  Littl replied...
23-Feb-09 03:49 PM
Pretty sure as when it starts it has:
Windows PowerShell V2 (Community Technology Preview - Features Subject to
Change)
Copyright (C) 2007 Microsoft Corporation. All rights reserved.

I uninstalled V1 to install this latest version V2.
  Littl replied...
23-Feb-09 03:52 PM
No it does not show up from that command:

PS C:\MyScripts> get-command get-eventlog | select parametersets | fl


ParameterSets : {[-LogName] <String> [-Newest <Int32>] [-Verbose] [-Debug]
[-ErrorAction <ActionPreference>] [-ErrorVar
iable <String>] [-OutVariable <String>] [-OutBuffer
-ErrorAction <ActionPreference>] [-ErrorVariable <String>]
[-OutVariable <String>] [-OutBuffer <Int32>]
}


but it does show up on: PS C:\MyScripts> get-help get-eventlog

NAME
Get-EventLog

SYNOPSIS
Gets the events in a specified event log or gets a list of the event
logs on the local or remote computers.


SYNTAX
Get-EventLog [-logName] <string> [-newest <int>] [-computerName

Get-EventLog [-list] [-asString] [-computerName <string[]>]
[<CommonParameters>]

Is the selectParametersets more accurate and the get-help just documentation
as suggested below?
  Littl replied...
23-Feb-09 03:57 PM
Dont think I have do.  It also works locally.
  Littl replied...
23-Feb-09 03:59 PM
Not sure if I am using that version but am guessing not.

Thank you all for quick response. I am guessing it is b/c it is just in the
documentation as being available for when it becomes available in CPT3 but
not available in the v2 version I am using.

Thanks to all, Leon
Create New Account
help
C:> 'New-TimeSpan' | Name Aliases - -- - - -- -- -- Start {LastWriteTime} Verbose {vb} Debug {db} ErrorAction {ea} WarningAction {wa} ErrorVariable {ev} WarningVariable {wv} OutVariable {ov} OutBuffer {ob} I guess this is the "better" way to code it: Get-ChildItem xo | % {New
HID device. I started with the following code found on the Internet: if (WriteFile(WriteHandleToUSBDevice, OUTBuffer, 65, ref BytesWritten, IntPtr.Zero)) / / Blocking function, unless an "overlapped" structure is used { INBuffer[0 a TextBox } } This code works, but only when we ask for a message through the OUTBuffer. Otherwise the ReadFileManagedBuffer function is blocking. Does somebody know how avoid this blocking ? Is it
retPing = Ping $computer if($retPing -eq $true) { $errorActionPreference = "SilentlyContinue" $testAccss = get-wmiobject Win32_OperatingSystem -computername $computer -ErrorVariable ERR If($ERR) {$Access = $false} else{$Access = $true} } else{$Access = $false} if($Access -eq $false