Powershell: How to do implicit processing?

Created on 14 May 2020  ·  2Comments  ·  Source: PowerShell/PowerShell

Steps to reproduce

What do i need to do next?

Export-PSSession -session $session -OutputModule s -Force -CommandName ‘Get-winEvent’ -AllowClobber -CommandType all
Remove-PSSession -Session $session
import-module s -vb
get-winevent  -FilterHashtable @{ LogName='Security'; StartTime=$Date;  Id='4625' }

Expected behavior


Actual behavior

error

Environment data

**********************
PowerShell transcript start
Start time: 20200514100345
Username: localhost\root
RunAs User: localhost\root
Configuration Name: 
Machine: localhost (Unix 4.9.112.0)
Host Application: /root/.powershell-daily/pwsh.dll
Process ID: 30283
PSVersion: 7.1.0-daily.20200501
PSEdition: Core
GitCommitId: 7.1.0-daily.20200501
OS: Linux 4.9.112-perf #1 SMP PREEMPT Mon Jan 7 10:46:47 KST 2019
Platform: Unix
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.10032.0, 6.0.0, 6.1.0, 6.2.0, 7.0.0, 7.1.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
WSManStackVersion: 3.0
**********************
Transcript started, output file is /root/PowerShell_transcript.localhost.dgpP9ud7.20200514100345.txt
PS sh> CommandInvocation(Write-Verbose): "Write-Verbose"
>> ParameterBinding(Write-Verbose): name="Message"; value="Command is not a simple pipeline and cannot be batched."
PS sh> $session=new-PSSession -HostName 167.179.zxx  -Port xxx -UserName administrator
PS sh> Export-PSSession -session $session -OutputModule s -Force -CommandName ‘get-process’ -AllowClobber -CommandType all


        Directory: /root/.local/share/powershell/Modules/s


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-----       2020/5/14   上午10:04             93 s.format.ps1xml
-----       2020/5/14   上午10:04            619 s.psd1
-----       2020/5/14   上午10:04          11890 s.psm1

PS sh> Remove-PSSession -Session $session
PS sh> import-module s -vb
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/s/s.psd1'.
VERBOSE: Importing function 'Get-Process'.
PS sh> get-process
Creating a new session for implicit remoting of "Get-Process" command...
PS sh> TerminatingError(New-PSSessionOption): "A parameter cannot be found that matches parameter name 'Culture'."
>> TerminatingError(New-PSSessionOption): "A parameter cannot be found that matches parameter name 'Culture'."
>> TerminatingError(Get-PSImplicitRemotingSession): "A parameter cannot be found that matches parameter name 'Culture'."
>> TerminatingError(): "Exception calling "GetSteppablePipeline" with "1" argument(s): "A parameter cannot be found that matches parameter name 'Culture'.""
>> TerminatingError(): "Exception calling "GetSteppablePipeline" with "1" argument(s): "A parameter cannot be found that matches parameter name 'Culture'.""
Exception calling "GetSteppablePipeline" with "1" argument(s): "A parameter cannot be found that matches parameter name 'Culture'."

ParentContainsErrorRecordException: /root/.local/share/powershell/Modules/s/s.psm1:309
Line |
 309 |              $steppablePipeline = $scriptCmd.GetSteppablePipeline($myI …
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "GetSteppablePipeline" with "1"
     | argument(s): "A parameter cannot be found that
     | matches parameter name 'Culture'."

PS sh> Stop-Transcript
**********************
PowerShell transcript end
End time: 20200514100452
**********************
PS sh> invoke-command -Session $session {[cultureinfo]::currentculture|fl}

Parent                         : zh-Hans
LCID                           : 2052
KeyboardLayoutId               : 2052
Name                           : zh-CN
IetfLanguageTag                : zh-CN
DisplayName                    : 中文(简体,中国)
NativeName                     : 中文(中国)
EnglishName                    : Chinese (Simplified, China)
TwoLetterISOLanguageName       : zh
ThreeLetterISOLanguageName     : zho
ThreeLetterWindowsLanguageName : CHS
CompareInfo                    : CompareInfo - zh-CN
TextInfo                       : TextInfo - zh-CN
IsNeutralCulture               : False
CultureTypes                   : SpecificCultures, InstalledWin32Cult
                                 ures
NumberFormat                   : System.Globalization.NumberFormatInf
                                 o
DateTimeFormat                 : System.Globalization.DateTimeFormatI
                                 nfo
Calendar                       : System.Globalization.GregorianCalend
                                 ar
OptionalCalendars              : {System.Globalization.GregorianCalen
                                 dar}
UseUserOverride                : True
IsReadOnly                     : True


PS sh> [cultureinfo]::currentculture|fl

Parent                         : zh
LCID                           : 2052
KeyboardLayoutId               : 2052
Name                           : zh-CN
IetfLanguageTag                : zh-CN
DisplayName                    : 中文(中国)
NativeName                     : 中文(中国)
EnglishName                    : Chinese (China)
TwoLetterISOLanguageName       : zh
ThreeLetterISOLanguageName     : zho
ThreeLetterWindowsLanguageName : CHS
CompareInfo                    : CompareInfo - zh-CN
TextInfo                       : TextInfo - zh-CN
IsNeutralCulture               : False
CultureTypes                   : SpecificCultures
NumberFormat                   : System.Globalization.NumberFormatInf
                                 o
DateTimeFormat                 : System.Globalization.DateTimeFormatI
                                 nfo
Calendar                       : System.Globalization.GregorianCalend
                                 ar
OptionalCalendars              : {System.Globalization.GregorianCalen
                                 dar}
UseUserOverride                : True
IsReadOnly                     : True
Issue-Question OS-Linux

Most helpful comment

PowerShell implicit remoting is currently incompatible with SSH remoting because it contains WinRM specific code that doesn't apply to SSH. It assumes PSSession is equivalent to 'WinRM session', which is not longer true. From what I can see this dependency is only in PSSessionOption, but there may be other places. We need to have an Issue to fix this.

All 2 comments

@PaulHigin Have you thoughts about:

PS sh> TerminatingError(New-PSSessionOption): "A parameter cannot be found that matches parameter name 'Culture'."
>> TerminatingError(New-PSSessionOption): "A parameter cannot be found that matches parameter name 'Culture'."
>> TerminatingError(Get-PSImplicitRemotingSession): "A parameter cannot be found that matches parameter name 'Culture'."
>> TerminatingError(): "Exception calling "GetSteppablePipeline" with "1" argument(s): "A parameter cannot be found that matches parameter name 'Culture'.""
>> TerminatingError(): "Exception calling "GetSteppablePipeline" with "1" argument(s): "A parameter cannot be found that matches parameter name 'Culture'.""

PowerShell implicit remoting is currently incompatible with SSH remoting because it contains WinRM specific code that doesn't apply to SSH. It assumes PSSession is equivalent to 'WinRM session', which is not longer true. From what I can see this dependency is only in PSSessionOption, but there may be other places. We need to have an Issue to fix this.

Was this page helpful?
0 / 5 - 0 ratings