How are differing path separators handled? How are differing path separators handled? powershell powershell

How are differing path separators handled?


I would suggest to shift responsibility for handling directory separator character to the underlying .Net platform. Something like this:

Get-ChildItem -Recurse |Where-Object { $_.FullName.Split([IO.Path]::DirectorySeparatorChar) -notcontains "obj" } |ForEach-Object { $_.FullName }


From at least PowerShell v6.0.0-beta.2 $PSVersionTable has the additional properties GitCommitId, OS and Platform you could use to distinguish in your code albeit having only one version as in Mikhails answer is preferable.

$PSVersionTable                                                                                                                  Name                           Value                                                                                               ----                           -----                                                                                               PSVersion                      6.0.0-beta                                                                                          PSEdition                      Core                                                                                                BuildVersion                   3.0.0.0                                                                                             CLRVersion                                                                                                                         GitCommitId                    v6.0.0-beta.2                                                                                       OS                             Linux 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017                                  Platform                       Unix                                                                                                PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                             PSRemotingProtocolVersion      2.3                                                                                                 SerializationVersion           1.1.0.1                                                                                             WSManStackVersion              3.0