Skip to content

PowerShell Permissions Helpers Are Not Compatible with PSH 2.0 #758

Closed
@DarwinJS

Description

@DarwinJS

I originally commented in #721 under the heading "Installation Code Testing" that all PowerShell code should be tested on the target platforms of openssh, which I believe still includes Windows 7 / Server 2008 R2 RTM.

FYI - the code does appear to work for Nano.

FixHostFilePermissions, FixUserFilePermissions.ps1 and OpenSSHUtils.psm1 all have syntax or assumptions that are not compatible with PowerShell 2.0.

I fixed some, but I realized I don't have time to test if the scripts still actually perform their intended duties. I also noticed that some permissions do not seem to be updating after the below changes.

Here are the ones I know about:
FixHostFilePermissions, FixUserFilePermissions.ps1 = $psscriptroot was introduced in version 3.
Fixup - right under params block: If (!(Test-Path variable:PSScriptRoot)) {$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Definition}

OpenSSHUtils.psm1: '-in' operator is not in PSH 2
Untested Fixup: change $abc -in $xyzarray to $xyzarray -icontains $abc (unsure if this is a full emulation of -in)

OpenSSHUtils.psm1: '.contains' method is not in PSH 2 (string objects?)
Untested Fixup: change $abc.contains($somedata) to $abc -contains $somedata (unsure if this is working)

FYI - I personally avoid testing with "powershell.exe -version 2" for compatibility with Win 7 / Server 2008 R2. There are just too many other differences.

If these scripts can be made compatible with PSH 2.0 and a pull request made - I will grab the code from the pull request and include it in the chocolatey package for 0.0.15.0 as an override of the files in the zip archives.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions